Преглед на файлове

[struct starpu_codelet] : update deprecation of xxx_func fields

src/core/task.c: when both xxx_func and xxx_funcs are set, warn the
user and ignore xxx_func.

tests/core/deprecated.c: update the test accordingly
Nathalie Furmento преди 13 години
родител
ревизия
bc46f701b1
променени са 2 файла, в които са добавени 39 реда и са изтрити 3 реда
  1. 15 0
      src/core/task.c
  2. 24 3
      tests/core/deprecated.c

+ 15 - 0
src/core/task.c

@@ -224,6 +224,11 @@ int _starpu_submit_job(struct _starpu_job *j)
 void _starpu_codelet_check_deprecated_fields(struct starpu_codelet *cl)
 {
 	/* Check deprecated and unset fields */
+	if (cl && cl->cpu_func && cl->cpu_func != STARPU_MULTIPLE_CPU_IMPLEMENTATIONS && cl->cpu_funcs[0])
+	{
+		fprintf(stderr, "[warning] [struct starpu_codelet] both cpu_func and cpu_funcs are set. Ignoring cpu_func.\n");
+		cl->cpu_func = STARPU_MULTIPLE_CPU_IMPLEMENTATIONS;
+	}
 	if (cl && cl->cpu_func && cl->cpu_func != STARPU_MULTIPLE_CPU_IMPLEMENTATIONS)
 	{
 		cl->cpu_funcs[0] = cl->cpu_func;
@@ -234,6 +239,11 @@ void _starpu_codelet_check_deprecated_fields(struct starpu_codelet *cl)
 		cl->cpu_func = STARPU_MULTIPLE_CPU_IMPLEMENTATIONS;
 	}
 
+	if (cl && cl->cuda_func && cl->cuda_func != STARPU_MULTIPLE_CUDA_IMPLEMENTATIONS && cl->cuda_funcs[0])
+	{
+		fprintf(stderr, "[warning] [struct starpu_codelet] both cuda_func and cuda_funcs are set. Ignoring cuda_func.\n");
+		cl->cuda_func = STARPU_MULTIPLE_CUDA_IMPLEMENTATIONS;
+	}
 	if (cl && cl->cuda_func && cl->cuda_func != STARPU_MULTIPLE_CUDA_IMPLEMENTATIONS)
 	{
 		cl->cuda_funcs[0] = cl->cuda_func;
@@ -244,6 +254,11 @@ void _starpu_codelet_check_deprecated_fields(struct starpu_codelet *cl)
 		cl->cuda_func = STARPU_MULTIPLE_CUDA_IMPLEMENTATIONS;
 	}
 
+	if (cl && cl->opencl_func && cl->opencl_func != STARPU_MULTIPLE_OPENCL_IMPLEMENTATIONS && cl->opencl_funcs[0])
+	{
+		fprintf(stderr, "[warning] [struct starpu_codelet] both opencl_func and opencl_funcs are set. Ignoring opencl_func.\n");
+		cl->opencl_func = STARPU_MULTIPLE_OPENCL_IMPLEMENTATIONS;
+	}
 	if (cl && cl->opencl_func && cl->opencl_func != STARPU_MULTIPLE_OPENCL_IMPLEMENTATIONS)
 	{
 		cl->opencl_funcs[0] = cl->opencl_func;

+ 24 - 3
tests/core/deprecated.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011  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
@@ -25,6 +25,14 @@ void cpu_codelet(void *descr[], __attribute__ ((unused)) void *_args)
 	*valout = *valin;
 }
 
+void cpu2_codelet(void *descr[], __attribute__ ((unused)) void *_args)
+{
+	int *valin = (int *)STARPU_VARIABLE_GET_PTR(descr[0]);
+	int *valout = (int *)STARPU_VARIABLE_GET_PTR(descr[1]);
+
+	*valout = *valin*2;
+}
+
 struct starpu_codelet cl_cpu_funcs =
 {
 	.where = STARPU_CPU,
@@ -50,6 +58,15 @@ struct starpu_codelet cl_cpu_multiple =
 	.name = "cpu_multiple",
 };
 
+struct starpu_codelet cl_cpu_func_funcs =
+{
+	.where = STARPU_CPU,
+	.cpu_func = cpu2_codelet,
+	.cpu_funcs = {cpu_codelet, NULL},
+	.nbuffers = 2,
+	.name = "cpu_func_funcs",
+};
+
 int submit_codelet(struct starpu_codelet *cl)
 {
 	int x=42, y=14;
@@ -88,11 +105,15 @@ int main(int argc, char **argv)
 	ret = submit_codelet(&cl_cpu_func);
 	if (!ret)
 	{
-		submit_codelet(&cl_cpu_funcs);
+		ret = submit_codelet(&cl_cpu_funcs);
+	}
+	if (!ret)
+	{
+		ret = submit_codelet(&cl_cpu_multiple);
 	}
 	if (!ret)
 	{
-		submit_codelet(&cl_cpu_multiple);
+		ret = submit_codelet(&cl_cpu_func_funcs);
 	}
 
 	starpu_shutdown();