Browse Source

mpi/examples/reduction: print node doing the computation

Nathalie Furmento 13 years ago
parent
commit
e6eb09e53f

+ 10 - 8
mpi/examples/reduction/mpi_reduction.c

@@ -17,8 +17,7 @@
 #include <starpu_mpi.h>
 #include <math.h>
 
-#define X         5
-#define Y         3
+#define X         7
 
 int display = 0;
 
@@ -30,14 +29,16 @@ static struct starpu_codelet init_codelet =
 {
 	.where = STARPU_CPU,
 	.cpu_funcs = {init_cpu_func, NULL},
-	.nbuffers = 1
+	.nbuffers = 1,
+	.name = "init_codelet"
 };
 
 static struct starpu_codelet redux_codelet =
 {
 	.where = STARPU_CPU,
 	.cpu_funcs = {redux_cpu_func, NULL},
-	.nbuffers = 2
+	.nbuffers = 2,
+	.name = "redux_codelet"
 };
 
 static struct starpu_codelet dot_codelet =
@@ -45,7 +46,8 @@ static struct starpu_codelet dot_codelet =
 	.where = STARPU_CPU,
 	.cpu_funcs = {dot_cpu_func, NULL},
 	.nbuffers = 2,
-	.modes = {STARPU_R, STARPU_REDUX}
+	.modes = {STARPU_R, STARPU_REDUX},
+	.name = "dot_codelet"
 };
 
 static void parse_args(int argc, char **argv)
@@ -71,7 +73,7 @@ int main(int argc, char **argv)
         int my_rank, size, x;
         int value=0;
         unsigned vector[X];
-	unsigned dot, sum=0;
+	unsigned dot=0, sum=0;
         starpu_data_handle_t handles[X];
 	starpu_data_handle_t dot_handle;
 
@@ -81,8 +83,8 @@ int main(int argc, char **argv)
 
         for(x = 0; x < X; x++)
 	{
-		vector[x] = x;
-		sum += x;
+		vector[x] = x+1;
+		sum += x+1;
         }
 
         for(x = 0; x < X; x++)

+ 9 - 0
mpi/examples/reduction/mpi_reduction_kernels.c

@@ -15,6 +15,12 @@
  */
 
 #include <starpu.h>
+#include <mpi.h>
+
+#define _DISPLAY(fmt, args ...) { \
+		int rank; MPI_Comm_rank(MPI_COMM_WORLD, &rank);		\
+		fprintf(stderr, "[%d][%s] " fmt , rank, __func__ ,##args); \
+		fflush(stderr); }
 
 /*
  *	Codelet to create a neutral element
@@ -23,6 +29,7 @@ void init_cpu_func(void *descr[], void *cl_arg)
 {
 	int *dot = (int *)STARPU_VARIABLE_GET_PTR(descr[0]);
 	*dot = 0.0f;
+	_DISPLAY("Init dot\n");
 }
 
 /*
@@ -33,6 +40,7 @@ void redux_cpu_func(void *descr[], void *cl_arg)
 	int *dota = (int *)STARPU_VARIABLE_GET_PTR(descr[0]);
 	int *dotb = (int *)STARPU_VARIABLE_GET_PTR(descr[1]);
 
+	_DISPLAY("Calling redux %d %d\n", *dota, *dotb);
 	*dota = *dota + *dotb;
 }
 
@@ -45,5 +53,6 @@ void dot_cpu_func(void *descr[], void *cl_arg)
 	int *dot = (int *)STARPU_VARIABLE_GET_PTR(descr[1]);
 
 	*dot += *local_x;
+	_DISPLAY("Calling dot %d %d\n", *dot, *local_x);
 }