Browse Source

starpu_data_cpy now takes a callback function which is executed when the handle
has been copied.

Cédric Augonnet 15 years ago
parent
commit
9b8fbfae0a
3 changed files with 8 additions and 3 deletions
  1. 2 1
      include/starpu_util.h
  2. 5 1
      src/util/starpu_data_cpy.c
  3. 1 1
      tests/helper/starpu_data_cpy.c

+ 2 - 1
include/starpu_util.h

@@ -164,7 +164,8 @@ void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t
  * asynchronous call, it is possible to synchronize with the termination of
  * this operation either by the means of implicit dependencies (if enabled) or
  * by calling starpu_task_wait_for_all(). */
-int starpu_data_cpy(starpu_data_handle dst_handle, starpu_data_handle src_handle, int asynchronous);
+int starpu_data_cpy(starpu_data_handle dst_handle, starpu_data_handle src_handle,
+			int asynchronous, void (*callback_func)(void*), void *callback_arg);
 
 /* Constants used by the starpu_insert_task helper to determine the different types of argument */
 #define STARPU_VALUE		(1<<3)	/* Pointer to a constant value */

+ 5 - 1
src/util/starpu_data_cpy.c

@@ -66,7 +66,8 @@ static starpu_codelet copy_cl = {
 	.model = &copy_model
 };
 
-int starpu_data_cpy(starpu_data_handle dst_handle, starpu_data_handle src_handle, int asynchronous)
+int starpu_data_cpy(starpu_data_handle dst_handle, starpu_data_handle src_handle,
+			int asynchronous, void (*callback_func)(void*), void *callback_arg)
 {
 	const struct starpu_data_copy_methods *copy_methods = dst_handle->ops->copy_methods;
 
@@ -76,6 +77,9 @@ int starpu_data_cpy(starpu_data_handle dst_handle, starpu_data_handle src_handle
 	task->cl = &copy_cl;
 	task->cl_arg = (void *)copy_methods;
 
+	task->callback_func = callback_func;
+	task->callback_arg = callback_arg;
+
 	task->buffers[0].handle = dst_handle;
 	task->buffers[0].mode = STARPU_RW;
 	task->buffers[1].handle = src_handle;

+ 1 - 1
tests/helper/starpu_data_cpy.c

@@ -29,7 +29,7 @@ int main(int argc, char **argv)
 	starpu_variable_data_register(&var1_handle, 0, (uintptr_t)&var1, sizeof(var1));
 	starpu_variable_data_register(&var2_handle, 0, (uintptr_t)&var2, sizeof(var2));
 
-	starpu_data_cpy(var2_handle, var1_handle, 0);
+	starpu_data_cpy(var2_handle, var1_handle, 0, NULL, NULL);
 
 	starpu_data_acquire(var2_handle, STARPU_R);
 	STARPU_ASSERT(var2 == 42);