浏览代码

revert @7765 and 7766. field cl_arg_size of struct starpu_task is needed for other drivers

Nathalie Furmento 12 年之前
父节点
当前提交
be0c2c22ac

+ 2 - 0
doc/chapters/advanced-examples.texi

@@ -256,6 +256,7 @@ for (i=0; i<starpu_data_get_nb_children(handle); i++) @{
     task->cl = &cl;
     task->synchronous = 1;
     task->cl_arg = &factor;
+    task->cl_arg_size = sizeof(factor);
 
     starpu_task_submit(task);
 @}
@@ -606,6 +607,7 @@ starpu_codelet_pack_args(&arg_buffer, &arg_buffer_size,
                     STARPU_VALUE, &ffactor, sizeof(ffactor),
                     0);
 task->cl_arg = arg_buffer;
+task->cl_arg_size = arg_buffer_size;
 int ret = starpu_task_submit(task);
 @end smallexample
 

+ 5 - 1
doc/chapters/basic-examples.texi

@@ -221,6 +221,7 @@ int main(int argc, char **argv)
 
     struct params params = @{ 1, 2.0f @};
     task->cl_arg = &params;
+    task->cl_arg_size = sizeof(params);
 
     task->callback_func = callback_func;
     task->callback_arg = 0x42;
@@ -256,7 +257,8 @@ kernel should be offloaded on the different architectures, and the task
 structure is a wrapper containing a codelet and the piece of data on which the
 codelet should operate.
 
-The optional @code{cl_arg} field is a pointer to a buffer with some parameters for the kernel
+The optional @code{cl_arg} field is a pointer to a buffer (of size
+@code{cl_arg_size}) with some parameters for the kernel
 described by the codelet. For instance, if a codelet implements a computational
 kernel that multiplies its input vector by a constant, the constant could be
 specified by the means of this buffer, instead of registering it as a StarPU
@@ -625,6 +627,7 @@ struct starpu_task *task = starpu_task_create();
 task->cl = &cl;                      /* @b{Pointer to the codelet defined below} */
 task->handles[0] = vector_handle;    /* @b{First parameter of the codelet} */
 task->cl_arg = &factor;
+task->cl_arg_size = sizeof(factor);
 task->synchronous = 1;
 
 starpu_task_submit(task);
@@ -885,6 +888,7 @@ int main(int argc, char **argv)
     task->cl = &cl;
     task->handles[0] = vector_handle;
     task->cl_arg = &factor;
+    task->cl_arg_size = sizeof(factor);
 @end smallexample
 @end cartouche
 

+ 1 - 0
doc/chapters/vector_scal_c.texi

@@ -94,6 +94,7 @@ int main(int argc, char **argv)
      * READ-ONLY buffer and that the codelet may be given a pointer to a
      * COPY of the argument */
     task->cl_arg = &factor;
+    task->cl_arg_size = sizeof(factor);
 
     /* execute the task on any eligible computational ressource */
     starpu_task_submit(task);

+ 2 - 1
doc/tutorial/hello_world.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  * Copyright (C) 2010, 2011  Université de Bordeaux 1
  *
  * Redistribution  and  use  in  source and binary forms, with or without
@@ -65,6 +65,7 @@ int main(int argc, char **argv)
 
     struct params params = { 1, 2.0f };
     task->cl_arg = &params;
+    task->cl_arg_size = sizeof(params);
 
     task->callback_func = callback_func;
     task->callback_arg = 0x42;

+ 1 - 0
doc/tutorial/vector_scal.c

@@ -114,6 +114,7 @@ int main(int argc, char **argv)
      * READ-ONLY buffer and that the codelet may be given a pointer to a
      * COPY of the argument */
     task->cl_arg = &factor;
+    task->cl_arg_size = sizeof(factor);
 
     /* execute the task on any eligible computational ressource */
     starpu_task_submit(task);

+ 1 - 0
examples/basic_examples/block.c

@@ -53,6 +53,7 @@ int execute_on(uint32_t where, device_func func, float *block, int pnx, int pny,
         task->callback_func = NULL;
         task->handles[0] = block_handle;
 	task->cl_arg = &multiplier;
+	task->cl_arg_size = sizeof(multiplier);
 
         int ret = starpu_task_submit(task);
         if (STARPU_UNLIKELY(ret == -ENODEV))

+ 1 - 0
examples/basic_examples/hello_world.c

@@ -100,6 +100,7 @@ int main(int argc, char **argv)
 	 * of the buffer.  For this reason, a buffer passed as a codelet
 	 * argument (cl_arg) is NOT a valid synchronization medium! */
 	task->cl_arg = &params;
+	task->cl_arg_size = sizeof(params);
 
 	/* once the task has been executed, callback_func(0x42)
 	 * will be called on a CPU */

+ 1 - 0
examples/basic_examples/multiformat.c

@@ -160,6 +160,7 @@ create_and_submit_task(unsigned int dev)
 	task->synchronous = 1;
 	task->handles[0] = array_of_structs_handle;
 	task->cl_arg = NULL;
+	task->cl_arg_size = 0;
 	return starpu_task_submit(task);
 }
 

+ 1 - 0
examples/basic_examples/vector_scal.c

@@ -154,6 +154,7 @@ int main(int argc, char **argv)
 	 * READ-ONLY buffer and that the codelet may be given a pointer to a
 	 * COPY of the argument */
 	task->cl_arg = &factor;
+	task->cl_arg_size = sizeof(factor);
 
 	/* execute the task on any eligible computational ressource */
 	ret = starpu_task_submit(task);

+ 1 - 0
examples/basic_examples/vector_scal_c.c

@@ -94,6 +94,7 @@ int compute_(int *F_NX, float *vector)
 	 * READ-ONLY buffer and that the codelet may be given a pointer to a
 	 * COPY of the argument */
 	task->cl_arg = &factor;
+	task->cl_arg_size = sizeof(factor);
 
 	/* execute the task on any eligible computational ressource */
 	ret = starpu_task_submit(task);

+ 1 - 0
examples/filters/fmatrix.c

@@ -93,6 +93,7 @@ int main(int argc, char **argv)
                 task->cl = &cl;
                 task->synchronous = 1;
                 task->cl_arg = &factor;
+                task->cl_arg_size = sizeof(factor);
 
 		ret = starpu_task_submit(task);
 		if (ret == -ENODEV) goto enodev;

+ 1 - 0
examples/filters/fvector.c

@@ -83,6 +83,7 @@ int main(int argc, char **argv)
                 task->cl = &cl;
                 task->synchronous = 1;
                 task->cl_arg = &factor;
+                task->cl_arg_size = sizeof(factor);
 
 		ret = starpu_task_submit(task);
 		if (ret == -ENODEV) goto enodev;

+ 1 - 0
examples/openmp/vector_scal.c

@@ -102,6 +102,7 @@ int main(int argc, char **argv)
 
 		task->handles[0] = vector_handle;
 		task->cl_arg = &factor;
+		task->cl_arg_size = sizeof(factor);
 
 		ret = starpu_task_submit(task);
 		STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");

+ 1 - 0
examples/spmd/vector_scal_spmd.c

@@ -125,6 +125,7 @@ int main(int argc, char **argv)
 
 		task->handles[0] = vector_handle;
 		task->cl_arg = &factor;
+		task->cl_arg_size = sizeof(factor);
 
 		ret = starpu_task_submit(task);
 		if (ret == -ENODEV) {

+ 1 - 0
examples/top/hello_world_top.c

@@ -197,6 +197,7 @@ int main(int argc, char **argv)
 		 * argument (cl_arg) is NOT a valid synchronization medium! */
 		struct params params = { i, 2.0f };
 		task[i]->cl_arg = &params;
+		task[i]->cl_arg_size = sizeof(params);
 
 		/* once the task has been executed, callback_func(0x42)
 		 * will be called on a CPU */

+ 3 - 0
include/starpu_task.h

@@ -127,6 +127,8 @@ struct starpu_task
 
 	/* arguments not managed by the DSM are given as a buffer */
 	void *cl_arg;
+	/* in case the argument buffer has to be uploaded explicitely */
+	size_t cl_arg_size;
 
 	/* when the task is done, callback_func(callback_arg) is called */
 	void (*callback_func)(void *);
@@ -207,6 +209,7 @@ struct starpu_task
 {							\
 	.cl = NULL,					\
 	.cl_arg = NULL,					\
+	.cl_arg_size = 0,				\
 	.callback_func = NULL,				\
 	.callback_arg = NULL,				\
 	.priority = STARPU_DEFAULT_PRIO,		\

+ 1 - 0
socl/src/cl_enqueuecopybuffer.c

@@ -71,6 +71,7 @@ cl_int command_copy_buffer_submit(command_copy_buffer cmd) {
 	}
 
 	task->cl_arg = cmd;
+	task->cl_arg_size = sizeof(*cmd);
 
 	cmd->dst_buffer->scratch = 0;
 

+ 1 - 0
socl/src/cl_enqueuendrangekernel.c

@@ -123,6 +123,7 @@ cl_int command_ndrange_kernel_submit(command_ndrange_kernel cmd) {
 	task->cl = &cmd->codelet;
 	task->cl->model = cmd->kernel->perfmodel;
 	task->cl_arg = cmd;
+	task->cl_arg_size = sizeof(cmd);
 
 	/* Execute the task on a specific worker? */
 	if (cmd->_command.cq->device != NULL) {

+ 1 - 0
socl/src/cl_enqueuereadbuffer.c

@@ -77,6 +77,7 @@ cl_int command_read_buffer_submit(command_read_buffer cmd) {
 	}
 
 	task->cl_arg = cmd;
+	task->cl_arg_size = sizeof(*cmd);
 
 	task_submit(task, cmd);
 

+ 1 - 0
socl/src/cl_enqueuewritebuffer.c

@@ -92,6 +92,7 @@ cl_int command_write_buffer_submit(command_write_buffer cmd) {
 		task->cl = &codelet_writebuffer;
 
 	task->cl_arg = cmd;
+	task->cl_arg_size = sizeof(*cmd);
 
 	/* Execute the task on a specific worker? */
 	if (cmd->_command.cq->device != NULL) {

+ 1 - 0
src/util/starpu_insert_task_utils.c

@@ -289,6 +289,7 @@ int _starpu_insert_task_create_and_submit(char *arg_buffer, size_t arg_buffer_si
 
 	(*task)->cl = cl;
 	(*task)->cl_arg = arg_buffer;
+	(*task)->cl_arg_size = arg_buffer_size;
 
 	/* The callback will free the argument stack and execute the
 	 * application's callback, if any. */

+ 1 - 0
tests/datawizard/interfaces/test_interfaces.c

@@ -368,6 +368,7 @@ create_task(struct starpu_task **taskp, enum starpu_archtype type, int id)
 	}
 	factor = -factor;
 	task->cl_arg = &factor;
+	task->cl_arg_size = sizeof(&factor);
 
 	*taskp = task;
 	return 0;

+ 4 - 3
tests/main/insert_task.c

@@ -97,10 +97,11 @@ int main(int argc, char **argv)
 	char *arg_buffer;
 	size_t arg_buffer_size;
 	starpu_codelet_pack_args(&arg_buffer, &arg_buffer_size,
-				 STARPU_VALUE, &ifactor, sizeof(ifactor),
-				 STARPU_VALUE, &ffactor, sizeof(ffactor),
-				 0);
+			    STARPU_VALUE, &ifactor, sizeof(ifactor),
+			    STARPU_VALUE, &ffactor, sizeof(ffactor),
+			    0);
 	task->cl_arg = arg_buffer;
+	task->cl_arg_size = arg_buffer_size;
 
 	ret = starpu_task_submit(task);
 	if (ret == -ENODEV) goto enodev;

+ 1 - 0
tests/main/starpu_task_bundle.c

@@ -81,6 +81,7 @@ int main(int argc, char **argv)
 			task[j]->cl = &codelet;
 
 			task[j]->cl_arg = &factors[i];
+			task[j]->cl_arg_size = sizeof(float);
 
 			task[j]->handles[0] = handles[i];