LCOV - code coverage report
Current view: top level - mpi/examples/reduction - mpi_reduction_kernels.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 18 18 100.0 %
Date: 2012-03-27 Functions: 3 3 100.0 %
Branches: 2 2 100.0 %

           Branch data     Line data    Source code
       1                 :            : /* StarPU --- Runtime system for heterogeneous multicore architectures.
       2                 :            :  *
       3                 :            :  * Copyright (C) 2012  Centre National de la Recherche Scientifique
       4                 :            :  *
       5                 :            :  * StarPU is free software; you can redistribute it and/or modify
       6                 :            :  * it under the terms of the GNU Lesser General Public License as published by
       7                 :            :  * the Free Software Foundation; either version 2.1 of the License, or (at
       8                 :            :  * your option) any later version.
       9                 :            :  *
      10                 :            :  * StarPU is distributed in the hope that it will be useful, but
      11                 :            :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      12                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      13                 :            :  *
      14                 :            :  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
      15                 :            :  */
      16                 :            : 
      17                 :            : #include <starpu.h>
      18                 :            : #include <mpi.h>
      19                 :            : 
      20                 :            : #define _DISPLAY(fmt, args ...) do { \
      21                 :            :                 int _display_rank; MPI_Comm_rank(MPI_COMM_WORLD, &_display_rank);   \
      22                 :            :                 fprintf(stderr, "[%d][%s] " fmt , _display_rank, __func__ ,##args);   \
      23                 :            :                 fflush(stderr); } while(0)
      24                 :            : 
      25                 :            : /*
      26                 :            :  *      Codelet to create a neutral element
      27                 :            :  */
      28                 :         10 : void init_cpu_func(void *descr[], void *cl_arg)
      29                 :            : {
      30                 :         10 :         long int *dot = (long int *)STARPU_VARIABLE_GET_PTR(descr[0]);
      31                 :         10 :         *dot = 0;
      32                 :         10 :         _DISPLAY("Init dot\n");
      33                 :         10 : }
      34                 :            : 
      35                 :            : /*
      36                 :            :  *      Codelet to perform the reduction of two elements
      37                 :            :  */
      38                 :         10 : void redux_cpu_func(void *descr[], void *cl_arg)
      39                 :            : {
      40                 :         10 :         long int *dota = (long int *)STARPU_VARIABLE_GET_PTR(descr[0]);
      41                 :         10 :         long int *dotb = (long int *)STARPU_VARIABLE_GET_PTR(descr[1]);
      42                 :            : 
      43                 :         10 :         *dota = *dota + *dotb;
      44                 :         10 :         _DISPLAY("Calling redux %ld=%ld+%ld\n", *dota, *dota-*dotb, *dotb);
      45                 :         10 : }
      46                 :            : 
      47                 :            : /*
      48                 :            :  *      Dot product codelet
      49                 :            :  */
      50                 :       3997 : void dot_cpu_func(void *descr[], void *cl_arg)
      51                 :            : {
      52                 :       3997 :         long int *local_x = (long int *)STARPU_VECTOR_GET_PTR(descr[0]);
      53                 :       3997 :         unsigned n = STARPU_VECTOR_GET_NX(descr[0]);
      54                 :            : 
      55                 :       3997 :         long int *dot = (long int *)STARPU_VARIABLE_GET_PTR(descr[1]);
      56                 :            : 
      57                 :            : //      _DISPLAY("Before dot=%ld (adding %d elements...)\n", *dot, n);
      58                 :            :         unsigned i;
      59         [ +  + ]:      19973 :         for (i = 0; i < n; i++)
      60                 :            :         {
      61                 :            : //              _DISPLAY("Adding %ld\n", local_x[i]);
      62                 :      15976 :                 *dot += local_x[i];
      63                 :            :         }
      64                 :            : //      _DISPLAY("After dot=%ld\n", *dot);
      65                 :       3997 : }
      66                 :            : 

Generated by: LCOV version 1.9