瀏覽代碼

Add RAM-to-RAM support to the interface test code.

Cyril Roelandt 13 年之前
父節點
當前提交
65ff88747f

+ 10 - 0
tests/datawizard/interfaces/multiformat/multiformat_interface.c

@@ -27,7 +27,10 @@ extern void test_multiformat_opencl_func(void *buffers[], void *args);
 #endif
 
 static struct point array_of_structs[N_ELEMENTS];
+static struct point array_of_structs_dummy[N_ELEMENTS];
+
 static starpu_data_handle_t multiformat_handle;
+static starpu_data_handle_t multiformat_dummy_handle;
 
 struct test_config multiformat_config = {
 	.cpu_func      = test_multiformat_cpu_func,
@@ -38,6 +41,7 @@ struct test_config multiformat_config = {
 	.opencl_func   = test_multiformat_opencl_func,
 #endif
 	.handle        = &multiformat_handle,
+	.dummy_handle  = &multiformat_dummy_handle,
 	.copy_failed   = 0,
 	.name          = "multiformat_interface"
 };
@@ -107,12 +111,18 @@ register_data(void)
 					 &array_of_structs,
 					 N_ELEMENTS,
 					 &format_ops);
+	starpu_multiformat_data_register(&multiformat_dummy_handle,
+					 0,
+					 &array_of_structs,
+					 N_ELEMENTS,
+					 &format_ops);
 }
 
 static void
 unregister_data(void)
 {
 	starpu_data_unregister(multiformat_handle);
+	starpu_data_unregister(multiformat_dummy_handle);
 }
 
 int

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

@@ -71,6 +71,9 @@ enum_to_string(exit_code)
 
 struct data_interface_test_summary {
 	int success;
+#ifdef STARPU_USE_CPU
+	int cpu_to_cpu;
+#endif
 #ifdef STARPU_USE_CUDA
 	int cpu_to_cuda;
 	int cuda_to_cuda;
@@ -95,7 +98,6 @@ void data_interface_test_summary_print(FILE *f,
 
 	FPRINTF(f, "%s : %s\n",
 		current_config->name, enum_to_string(s->success));
-
 	FPRINTF(f, "Asynchronous :\n");
 #ifdef STARPU_USE_CUDA
 	FPRINTF(f, "\tCPU    -> CUDA   : %s\n",
@@ -127,6 +129,10 @@ void data_interface_test_summary_print(FILE *f,
 	FPRINTF(f, "\tOpenCl -> CPU    : %s\n",
 		enum_to_string(s->opencl_to_cpu));
 #endif /* !STARPU_USE_OPENCL */
+#ifdef STARPU_USE_CPU
+	(void) fprintf(f, "CPU    -> CPU    : %s\n",
+			enum_to_string(s->cpu_to_cpu));
+#endif /* !STARPU_USE_CPU */
 }
 
 int
@@ -153,6 +159,10 @@ get_field(struct data_interface_test_summary *s, int async, enum operation op)
 {
 	switch (op)
 	{
+#ifdef STARPU_USE_CPU
+	case CPU_TO_CPU:
+		return &s->cpu_to_cpu;
+#endif
 #ifdef STARPU_USE_CUDA
 	case CPU_TO_CUDA:
 		return async?&s->cpu_to_cuda_async:&s->cpu_to_cuda;
@@ -201,6 +211,9 @@ set_field(struct data_interface_test_summary *s, int async,
 }
 
 static struct data_interface_test_summary summary = {
+#ifdef STARPU_USE_CPU
+	.cpu_to_cpu            = UNTESTED,
+#endif
 #ifdef STARPU_USE_CUDA
 	.cpu_to_cuda           = UNTESTED,
 	.cuda_to_cuda          = UNTESTED,
@@ -492,6 +505,40 @@ run_opencl(int async)
 }
 #endif /* !STARPU_USE_OPENCL */
 
+#ifdef STARPU_USE_CPU
+static void
+ram_to_ram(void)
+{
+	int err;
+	struct starpu_task *task;
+	starpu_data_handle_t src, dst;
+
+	src = *current_config->handle;
+	dst = *current_config->dummy_handle;
+	starpu_data_cpy(dst, src, 1, NULL, NULL);
+
+	err = create_task(&task, STARPU_CPU_WORKER, -1);
+	if (err != 0)
+		goto out;
+
+	task->buffers[0].handle = dst;
+	err = starpu_task_submit(task);
+	if (err != 0)
+	{
+		err = TASK_SUBMISSION_FAILURE;
+		goto out;
+	}
+
+
+	
+	fprintf(stderr, "[%s] : %d\n", __func__, current_config->copy_failed);
+	err = current_config->copy_failed;
+
+out:
+	set_field(&summary, 0, CPU_TO_CPU, err);
+}
+#endif /* !STARPU_USE_CPU */
+
 static void
 run_async(void)
 {
@@ -544,6 +591,7 @@ load_conf(struct test_config *config)
 	if (!config ||
 #ifdef STARPU_USE_CPU
 	    !config->cpu_func ||
+	    !config->dummy_handle ||
 #endif
 #ifdef STARPU_USE_CUDA
 	    !config->cuda_func ||
@@ -560,6 +608,7 @@ load_conf(struct test_config *config)
 	return 0;
 }
 
+
 data_interface_test_summary*
 run_tests(struct test_config *conf)
 {
@@ -570,5 +619,10 @@ run_tests(struct test_config *conf)
 	}
 	run_async();
 	run_sync();
+
+#ifdef STARPU_USE_CPU
+	ram_to_ram();
+#endif
+
 	return &summary;
 }

+ 6 - 1
tests/datawizard/interfaces/test_interfaces.h

@@ -17,9 +17,14 @@
 #define TEST_INTERFACES_H
 
 struct test_config {
-	/* A pointer to a valid handle */
+	/* A pointer to a registered handle */
 	starpu_data_handle_t *handle;
 
+	/* A pointer to a registered handle, that will be used to test
+	 * RAM to RAM copy. The values it points to should be different from
+	 * the ones pointed to by the previous handle. */
+	starpu_data_handle_t *dummy_handle;
+
 	/* Unregisters data, frees memory, tidies your room */
 	void (*cleanup)(void);
 

+ 14 - 6
tests/datawizard/interfaces/variable/variable_interface.c

@@ -17,7 +17,9 @@
 #include "../test_interfaces.h"
 
 static int variable;
+static int variable2;
 static starpu_data_handle_t variable_handle;
+static starpu_data_handle_t variable2_handle;
 
 /* Codelets */
 #ifdef STARPU_USE_CPU
@@ -33,17 +35,18 @@ static void test_variable_opencl_func(void *buffers[], void *args);
 struct test_config variable_config =
 {
 #ifdef STARPU_USE_CPU
-	.cpu_func    = test_variable_cpu_func,
+	.cpu_func     = test_variable_cpu_func,
 #endif
 #ifdef STARPU_USE_CUDA
-	.cuda_func   = test_variable_cuda_func,
+	.cuda_func    = test_variable_cuda_func,
 #endif
 #ifdef STARPU_USE_OPENCL
-	.opencl_func = test_variable_opencl_func,
+	.opencl_func  = test_variable_opencl_func,
 #endif
-	.handle      = &variable_handle,
-	.copy_failed = 0,
-	.name        = "variable_interface"
+	.handle       = &variable_handle,
+	.dummy_handle = &variable2_handle,
+	.copy_failed  = 0,
+	.name         = "variable_interface"
 };
 
 static void
@@ -66,14 +69,19 @@ static
 void register_data(void)
 {
 	variable = 42;
+	variable2 = 12;
+
 	starpu_variable_data_register(&variable_handle, 0,
 				      (uintptr_t) &variable, sizeof(variable));
+	starpu_variable_data_register(&variable2_handle, 0,
+				      (uintptr_t) &variable2, sizeof(variable2));
 }
 
 static
 void unregister_data(void)
 {
 	starpu_data_unregister(variable_handle);
+	starpu_data_unregister(variable2_handle);
 }
 
 int

+ 9 - 0
tests/datawizard/interfaces/vector/test_vector_interface.c

@@ -29,6 +29,7 @@ extern void test_vector_opencl_func(void *buffers[], void *args);
 
 
 static starpu_data_handle_t vector_handle;
+static starpu_data_handle_t vector2_handle;
 
 struct test_config vector_config = {
 	.cpu_func      = test_vector_cpu_func,
@@ -39,12 +40,14 @@ struct test_config vector_config = {
 	.opencl_func   = test_vector_opencl_func,
 #endif
 	.handle        = &vector_handle,
+	.dummy_handle  = &vector2_handle,
 	.copy_failed   = 0,
 	.name          = "vector_interface"
 };
 
 #define VECTOR_SIZE 123
 static int vector[VECTOR_SIZE];
+static int vector2[VECTOR_SIZE];
 
 static void
 register_data(void)
@@ -60,12 +63,18 @@ register_data(void)
                                     (uintptr_t)vector,
 				    VECTOR_SIZE,
 				    sizeof(int));
+	starpu_vector_data_register(&vector2_handle,
+                                    0,
+                                    (uintptr_t)vector2,
+				    VECTOR_SIZE,
+				    sizeof(int));
 }
 
 static void
 unregister_data(void)
 {
 	starpu_data_unregister(vector_handle);
+	starpu_data_unregister(vector2_handle);
 }
 
 static void test_vector_cpu_func(void *buffers[], void *args)