浏览代码

Set reduction codelet modes in codelet, not at execution

Samuel Thibault 12 年之前
父节点
当前提交
ad0f7bbef7

+ 4 - 0
examples/cg/cg_kernels.c

@@ -98,6 +98,7 @@ struct starpu_codelet accumulate_variable_cl =
 #ifdef STARPU_USE_CUDA
 	.cuda_funcs = {accumulate_variable_cuda, NULL},
 #endif
+	.modes = {STARPU_RW, STARPU_R},
 	.nbuffers = 2,
 	.model = &accumulate_variable_model
 };
@@ -136,6 +137,7 @@ struct starpu_codelet accumulate_vector_cl =
 #ifdef STARPU_USE_CUDA
 	.cuda_funcs = {accumulate_vector_cuda, NULL},
 #endif
+	.modes = {STARPU_RW, STARPU_R},
 	.nbuffers = 2,
 	.model = &accumulate_vector_model
 };
@@ -176,6 +178,7 @@ struct starpu_codelet bzero_variable_cl =
 #ifdef STARPU_USE_CUDA
 	.cuda_funcs = {bzero_variable_cuda, NULL},
 #endif
+	.modes = {STARPU_R},
 	.nbuffers = 1,
 	.model = &bzero_variable_model
 };
@@ -213,6 +216,7 @@ struct starpu_codelet bzero_vector_cl =
 #ifdef STARPU_USE_CUDA
 	.cuda_funcs = {bzero_vector_cuda, NULL},
 #endif
+	.modes = {STARPU_R},
 	.nbuffers = 1,
 	.model = &bzero_vector_model
 };

+ 3 - 1
examples/pi/pi_redux.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2012  Université de Bordeaux 1
+ * Copyright (C) 2010-2013  Université de Bordeaux 1
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -234,6 +234,7 @@ static struct starpu_codelet init_codelet =
 #ifdef STARPU_HAVE_CURAND
         .cuda_funcs = {init_cuda_func, NULL},
 #endif
+	.modes = {STARPU_R},
         .nbuffers = 1
 };
 
@@ -271,6 +272,7 @@ static struct starpu_codelet redux_codelet =
 #ifdef STARPU_HAVE_CURAND
 	.cuda_funcs = {redux_cuda_func, NULL},
 #endif
+	.modes = {STARPU_RW, STARPU_R},
 	.nbuffers = 2
 };
 

+ 3 - 1
examples/reductions/dot_product.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2012  Université de Bordeaux 1
+ * Copyright (C) 2010-2013  Université de Bordeaux 1
  * Copyright (C) 2012 inria
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -114,6 +114,7 @@ static struct starpu_codelet init_codelet =
 #ifdef STARPU_USE_OPENCL
 	.opencl_funcs = {init_opencl_func, NULL},
 #endif
+	.modes = {STARPU_R},
 	.nbuffers = 1
 };
 
@@ -194,6 +195,7 @@ static struct starpu_codelet redux_codelet =
 #ifdef STARPU_USE_OPENCL
 	.opencl_funcs = {redux_opencl_func, NULL},
 #endif
+	.modes = {STARPU_RW, STARPU_R},
 	.nbuffers = 2
 };
 

+ 3 - 1
examples/reductions/minmax_reduction.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010  Université de Bordeaux 1
+ * Copyright (C) 2010, 2013  Université de Bordeaux 1
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -58,6 +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},
 	.nbuffers = 1
 };
 
@@ -84,6 +85,7 @@ void minmax_redux_cpu_func(void *descr[], void *cl_arg)
 static struct starpu_codelet minmax_redux_codelet =
 {
 	.cpu_funcs = {minmax_redux_cpu_func, NULL},
+	.modes = {STARPU_RW, STARPU_R},
 	.nbuffers = 2
 };
 

+ 3 - 0
mpi/tests/mpi_reduction.c

@@ -1,5 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
+ * Copyright (C) 2013  Université de Bordeaux 1
  * Copyright (C) 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -26,12 +27,14 @@ static struct starpu_codelet init_codelet =
 {
 	.cpu_funcs = {init_cpu_func, NULL},
 	.nbuffers = 1,
+	.modes = {STARPU_R},
 	.name = "init_codelet"
 };
 
 static struct starpu_codelet redux_codelet =
 {
 	.cpu_funcs = {redux_cpu_func, NULL},
+	.modes = {STARPU_RW, STARPU_R},
 	.nbuffers = 2,
 	.name = "redux_codelet"
 };

+ 7 - 3
src/datawizard/reduction.c

@@ -217,12 +217,16 @@ void _starpu_data_end_reduction_mode(starpu_data_handle_t handle)
 
 					redux_task->cl = handle->redux_cl;
 					STARPU_ASSERT(redux_task->cl);
+					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;
 
-					redux_task->handles[0] = replicate_array[i];
-					redux_task->cl->modes[0] = STARPU_RW;
+					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] = replicate_array[i];
 					redux_task->handles[1] = replicate_array[i+step];
-					redux_task->cl->modes[1] = STARPU_R;
 
 					int ndeps = 0;
 					struct starpu_task *task_deps[2];

+ 3 - 1
tests/datawizard/increment_redux.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2012  Université de Bordeaux 1
+ * Copyright (C) 2010, 2012-2013  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -126,6 +126,7 @@ static struct starpu_codelet redux_cl =
 	.opencl_funcs = {redux_opencl_kernel, NULL},
 #endif
 	.cpu_funcs = {redux_cpu_kernel, NULL},
+	.modes = {STARPU_RW, STARPU_R},
 	.nbuffers = 2
 };
 
@@ -138,6 +139,7 @@ static struct starpu_codelet neutral_cl =
 	.opencl_funcs = {neutral_opencl_kernel, NULL},
 #endif
 	.cpu_funcs = {neutral_cpu_kernel, NULL},
+	.modes = {STARPU_R},
 	.nbuffers = 1
 };
 

+ 3 - 1
tests/datawizard/increment_redux_lazy.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2012  Université de Bordeaux 1
+ * Copyright (C) 2010, 2012-2013  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -112,6 +112,7 @@ static struct starpu_codelet redux_cl =
 	.opencl_funcs = {redux_opencl_kernel, NULL},
 #endif
 	.cpu_funcs = {redux_cpu_kernel, NULL},
+	.modes = {STARPU_RW, STARPU_R},
 	.nbuffers = 2
 };
 
@@ -124,6 +125,7 @@ static struct starpu_codelet neutral_cl =
 	.opencl_funcs = {neutral_opencl_kernel, NULL},
 #endif
 	.cpu_funcs = {neutral_cpu_kernel, NULL},
+	.modes = {STARPU_W},
 	.nbuffers = 1
 };
 

+ 3 - 1
tests/datawizard/increment_redux_v2.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011-2012  Université de Bordeaux 1
+ * Copyright (C) 2011-2013  Université de Bordeaux 1
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -125,6 +125,7 @@ static struct starpu_codelet redux_cl =
 	.opencl_funcs = {redux_opencl_kernel, NULL},
 #endif
 	.cpu_funcs = {redux_cpu_kernel, NULL},
+	.modes = {STARPU_RW, STARPU_R},
 	.nbuffers = 2
 };
 
@@ -137,6 +138,7 @@ static struct starpu_codelet neutral_cl =
 	.opencl_funcs = {neutral_opencl_kernel, NULL},
 #endif
 	.cpu_funcs = {neutral_cpu_kernel, NULL},
+	.modes = {STARPU_R},
 	.nbuffers = 1
 };