Explorar o código

examples: Update towards new codelet/task interface which defines access modes for data handles into starpu_codelet and no longer in starpu_task

Nathalie Furmento %!s(int64=13) %!d(string=hai) anos
pai
achega
671ab6cd76

+ 1 - 1
examples/basic_examples/vector_scal.c

@@ -19,7 +19,7 @@
  * This example demonstrates how to use StarPU to scale an array by a factor.
  * It shows how to manipulate data with StarPU's data management library.
  *  1- how to declare a piece of data to StarPU (starpu_vector_data_register)
- *  2- how to describe which data are accessed by a task (task->buffers[0])
+ *  2- how to describe which data are accessed by a task (task->handles[0])
  *  3- how a kernel can manipulate the data (buffers[0].vector.ptr)
  */
 

+ 2 - 2
examples/basic_examples/vector_scal_c.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  * Copyright (C) 2011  Université de Bordeaux 1
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
  * This example demonstrates how to use StarPU to scale an array by a factor.
  * It shows how to manipulate data with StarPU's data management library.
  *  1- how to declare a piece of data to StarPU (starpu_vector_data_register)
- *  2- how to describe which data are accessed by a task (task->buffers[0])
+ *  2- how to describe which data are accessed by a task (task->handles[0])
  *  3- how a kernel can manipulate the data (buffers[0].vector.ptr)
  *
  * This is a variant of vector_scal.c which shows it can be integrated with fortran.

+ 9 - 9
examples/basic_examples/vector_scal_cpu.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * 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
@@ -24,23 +24,23 @@
 #endif
 
 /* This kernel takes a buffer and scales it by a constant factor */
-void scal_cpu_func(void *buffers[], void *cl_arg)
+void scal_cpu_func(void *handles[], void *cl_arg)
 {
 	unsigned i;
 	float *factor = (float *) cl_arg;
 
 	/*
-	 * The "buffers" array matches the task->buffers array: for instance
-	 * task->buffers[0].handle is a handle that corresponds to a data with
+	 * The "handles" array matches the task->handles array: for instance
+	 * task->handles[0].handle is a handle that corresponds to a data with
 	 * vector "interface", so that the first entry of the array in the
 	 * codelet  is a pointer to a structure describing such a vector (ie.
 	 * struct starpu_vector_interface *). Here, we therefore manipulate
-	 * the buffers[0] element as a vector: nx gives the number of elements
+	 * the handles[0] element as a vector: nx gives the number of elements
 	 * in the array, ptr gives the location of the array (that was possibly
 	 * migrated/replicated), and elemsize gives the size of each elements.
 	 */
 
-	struct starpu_vector_interface *vector = (struct starpu_vector_interface *) buffers[0];
+	struct starpu_vector_interface *vector = (struct starpu_vector_interface *) handles[0];
 
 	/* length of the vector */
 	unsigned n = STARPU_VECTOR_GET_NX(vector);
@@ -56,10 +56,10 @@ void scal_cpu_func(void *buffers[], void *cl_arg)
 }
 
 #ifdef __SSE__
-void scal_sse_func(void *buffers[], void *cl_arg)
+void scal_sse_func(void *handles[], void *cl_arg)
 {
-	float *vector = (float *) STARPU_VECTOR_GET_PTR(buffers[0]);
-	unsigned int n = STARPU_VECTOR_GET_NX(buffers[0]);
+	float *vector = (float *) STARPU_VECTOR_GET_PTR(handles[0]);
+	unsigned int n = STARPU_VECTOR_GET_NX(handles[0]);
 	unsigned int n_iterations = n/4;
 
 	__m128 *VECTOR = (__m128*) vector;

+ 4 - 5
examples/opt/pi/pi.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2010-2011  Université de Bordeaux 1
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * 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
@@ -132,6 +132,7 @@ int main(int argc, char **argv)
 		.cuda_funcs = {cuda_kernel, NULL},
 #endif
 		.nbuffers = 2,
+		.modes = {STARPU_R, STARPU_W},
 		.model = &model
 	};
 
@@ -148,10 +149,8 @@ int main(int argc, char **argv)
 
 		STARPU_ASSERT(starpu_data_get_sub_data(cnt_array_handle, 1, i));
 
-		task->buffers[0].handle = sobol_qrng_direction_handle;
-		task->buffers[0].mode   = STARPU_R;
-		task->buffers[1].handle = starpu_data_get_sub_data(cnt_array_handle, 1, i);
-		task->buffers[1].mode   = STARPU_W;
+		task->handles[0] = sobol_qrng_direction_handle;
+		task->handles[1] = starpu_data_get_sub_data(cnt_array_handle, 1, i);
 
 		int ret = starpu_task_submit(task);
 		STARPU_ASSERT(!ret);

+ 23 - 10
examples/opt/pi/pi_redux.c

@@ -214,6 +214,23 @@ static struct starpu_codelet pi_cl =
 	.cuda_funcs = {pi_func_cuda, NULL},
 #endif
 	.nbuffers = 2,
+	.modes    = {STARPU_SCRATCH, STARPU_RW},
+	.model = NULL
+};
+
+static struct starpu_codelet pi_cl_redux =
+{
+	.where =
+#ifdef STARPU_HAVE_CURAND
+		STARPU_CUDA|
+#endif
+		STARPU_CPU,
+	.cpu_funcs = {pi_func_cpu, NULL},
+#ifdef STARPU_HAVE_CURAND
+	.cuda_funcs = {pi_func_cuda, NULL},
+#endif
+	.nbuffers = 2,
+	.modes    = {STARPU_SCRATCH, STARPU_REDUX}
 	.model = NULL
 };
 
@@ -328,12 +345,10 @@ int main(int argc, char **argv)
 	{
 		struct starpu_task *task = starpu_task_create();
 
-		task->cl = &pi_cl;
+		task->cl = use_redux?&pi_cl_redux:&pi_cl;
 
-		task->buffers[0].handle = xy_scratchpad_handle;
-		task->buffers[0].mode   = STARPU_SCRATCH;
-		task->buffers[1].handle = shot_cnt_handle;
-		task->buffers[1].mode   = use_redux?STARPU_REDUX:STARPU_RW;
+		task->handles[0] = xy_scratchpad_handle;
+		task->handles[1] = shot_cnt_handle;
 
 		int ret = starpu_task_submit(task);
 		STARPU_ASSERT(!ret);
@@ -346,12 +361,10 @@ int main(int argc, char **argv)
 	{
 		struct starpu_task *task = starpu_task_create();
 
-		task->cl = &pi_cl;
+		task->cl = use_redux?&pi_cl_redux:&pi_cl;
 
-		task->buffers[0].handle = xy_scratchpad_handle;
-		task->buffers[0].mode   = STARPU_SCRATCH;
-		task->buffers[1].handle = shot_cnt_handle;
-		task->buffers[1].mode   = use_redux?STARPU_REDUX:STARPU_RW;
+		task->handles[0] = xy_scratchpad_handle;
+		task->handles[1] = shot_cnt_handle;
 
 		int ret = starpu_task_submit(task);
 		STARPU_ASSERT(!ret);

+ 7 - 9
examples/spmv/dw_block_spmv.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2009, 2010-2011  Université de Bordeaux 1
  * Copyright (C) 2010  Mehdi Juhoor <mjuhoor@gmail.com>
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  *
  * 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
@@ -148,7 +148,8 @@ struct starpu_codelet cl =
 #ifdef STARPU_USE_CUDA
 	.cuda_funcs = {cublas_block_spmv, NULL},
 #endif
-	.nbuffers = 3
+	.nbuffers = 3,
+	.modes = {STARPU_R, STARPU_R, STARPU_RW}
 };
 
 void launch_spmv_codelets(void)
@@ -208,13 +209,10 @@ void launch_spmv_codelets(void)
 
 				unsigned i = colind[index];
 				unsigned j = row;
-		
-				task->buffers[0].handle = starpu_data_get_sub_data(sparse_matrix, 1, part);
-				task->buffers[0].mode  = STARPU_R;
-				task->buffers[1].handle = starpu_data_get_sub_data(vector_in, 1, i);
-				task->buffers[1].mode = STARPU_R;
-				task->buffers[2].handle = starpu_data_get_sub_data(vector_out, 1, j);
-				task->buffers[2].mode = STARPU_RW;
+
+				task->handles[0] = starpu_data_get_sub_data(sparse_matrix, 1, part);
+				task->handles[1] = starpu_data_get_sub_data(vector_in, 1, i);
+				task->handles[2] = starpu_data_get_sub_data(vector_out, 1, j);
 
 				/* all tasks in the same row are dependant so that we don't wait too much for data 
 				 * we need to wait on the previous task if we are not the first task of a row */