Sfoglia il codice sorgente

Fix reduction codelets modes further

Samuel Thibault 12 anni fa
parent
commit
02d4168c57

+ 2 - 2
examples/cg/cg_kernels.c

@@ -178,7 +178,7 @@ struct starpu_codelet bzero_variable_cl =
 #ifdef STARPU_USE_CUDA
 	.cuda_funcs = {bzero_variable_cuda, NULL},
 #endif
-	.modes = {STARPU_R},
+	.modes = {STARPU_W},
 	.nbuffers = 1,
 	.model = &bzero_variable_model
 };
@@ -216,7 +216,7 @@ struct starpu_codelet bzero_vector_cl =
 #ifdef STARPU_USE_CUDA
 	.cuda_funcs = {bzero_vector_cuda, NULL},
 #endif
-	.modes = {STARPU_R},
+	.modes = {STARPU_W},
 	.nbuffers = 1,
 	.model = &bzero_vector_model
 };

+ 1 - 1
examples/pi/pi_redux.c

@@ -234,7 +234,7 @@ static struct starpu_codelet init_codelet =
 #ifdef STARPU_HAVE_CURAND
         .cuda_funcs = {init_cuda_func, NULL},
 #endif
-	.modes = {STARPU_R},
+	.modes = {STARPU_W},
         .nbuffers = 1
 };
 

+ 1 - 1
examples/reductions/dot_product.c

@@ -114,7 +114,7 @@ static struct starpu_codelet init_codelet =
 #ifdef STARPU_USE_OPENCL
 	.opencl_funcs = {init_opencl_func, NULL},
 #endif
-	.modes = {STARPU_R},
+	.modes = {STARPU_W},
 	.nbuffers = 1
 };
 

+ 1 - 1
examples/reductions/minmax_reduction.c

@@ -58,7 +58,7 @@ static void minmax_neutral_cpu_func(void *descr[], void *cl_arg)
 static struct starpu_codelet minmax_init_codelet =
 {
 	.cpu_funcs = {minmax_neutral_cpu_func, NULL},
-	.modes = {STARPU_R},
+	.modes = {STARPU_W},
 	.nbuffers = 1
 };
 

+ 1 - 1
mpi/tests/mpi_reduction.c

@@ -51,7 +51,7 @@ static struct starpu_codelet display_codelet =
 {
 	.cpu_funcs = {display_cpu_func, NULL},
 	.nbuffers = 1,
-	.modes = {STARPU_R},
+	.modes = {STARPU_W},
 	.name = "display_codelet"
 };
 

+ 10 - 9
src/datawizard/reduction.c

@@ -278,10 +278,9 @@ void _starpu_data_end_reduction_mode(starpu_data_handle_t handle)
 
 			redux_task->cl = handle->init_cl;
 			STARPU_ASSERT(redux_task->cl);
-#ifdef STARPU_DEVEL
-#  warning the mode should already be set in the codelet. Only check they are valid?
-#endif
-			redux_task->cl->modes[0] = STARPU_W;
+			if (!redux_task->cl->modes[0])
+				redux_task->cl->modes[0] = STARPU_W;
+			STARPU_ASSERT_MSG(redux_task->cl->modes[0] == STARPU_W, "Parameter of initialization codelet has to be W");
 			redux_task->handles[0] = handle;
 
 			int ret = _starpu_task_submit_internally(redux_task);
@@ -304,11 +303,13 @@ void _starpu_data_end_reduction_mode(starpu_data_handle_t handle)
 			redux_task->cl = handle->redux_cl;
 			STARPU_ASSERT(redux_task->cl);
 
-#ifdef STARPU_DEVEL
-#  warning the modes should already be set in the codelet. Only check they are valid?
-#endif
-			redux_task->cl->modes[0] = STARPU_RW;
-			redux_task->cl->modes[1] = STARPU_R;
+			if (!redux_task->cl->modes[0])
+				redux_task->cl->modes[0] = STARPU_RW;
+			if (!redux_task->cl->modes[1])
+				redux_task->cl->modes[1] = STARPU_R;
+
+			STARPU_ASSERT_MSG(redux_task->cl->modes[0] == STARPU_RW, "First parameter of reduction codelet has to be RW");
+			STARPU_ASSERT_MSG(redux_task->cl->modes[1] == STARPU_R, "Second parameter of reduction codelet has to be R");
 
 			redux_task->handles[0] = handle;
 			redux_task->handles[1] = replicate_array[replicate];

+ 1 - 1
tests/datawizard/increment_redux.c

@@ -139,7 +139,7 @@ static struct starpu_codelet neutral_cl =
 	.opencl_funcs = {neutral_opencl_kernel, NULL},
 #endif
 	.cpu_funcs = {neutral_cpu_kernel, NULL},
-	.modes = {STARPU_R},
+	.modes = {STARPU_W},
 	.nbuffers = 1
 };
 

+ 1 - 1
tests/datawizard/increment_redux_v2.c

@@ -138,7 +138,7 @@ static struct starpu_codelet neutral_cl =
 	.opencl_funcs = {neutral_opencl_kernel, NULL},
 #endif
 	.cpu_funcs = {neutral_cpu_kernel, NULL},
-	.modes = {STARPU_R},
+	.modes = {STARPU_W},
 	.nbuffers = 1
 };