Bläddra i källkod

Fix cases where implementation 0 is not provided but others are

Samuel Thibault 10 år sedan
förälder
incheckning
b7015fd90d
2 ändrade filer med 53 tillägg och 10 borttagningar
  1. 52 9
      src/core/task.c
  2. 1 1
      src/core/workers.c

+ 52 - 9
src/core/task.c

@@ -369,6 +369,7 @@ void _starpu_codelet_check_deprecated_fields(struct starpu_codelet *cl)
 		return;
 
 	int is_where_unset = cl->where == 0;
+	unsigned i, some_impl;
 
 	/* Check deprecated and unset fields (where, <device>_func,
  	 * <device>_funcs) */
@@ -384,11 +385,18 @@ void _starpu_codelet_check_deprecated_fields(struct starpu_codelet *cl)
 		cl->cpu_funcs[0] = cl->cpu_func;
 		cl->cpu_func = STARPU_MULTIPLE_CPU_IMPLEMENTATIONS;
 	}
-	if (cl->cpu_funcs[0] && cl->cpu_func == 0)
+	some_impl = 0;
+	for (i = 0; i < STARPU_MAXIMPLEMENTATIONS; i++)
+		if (cl->cpu_funcs[i])
+		{
+			some_impl = 1;
+			break;
+		}
+	if (some_impl && cl->cpu_func == 0)
 	{
 		cl->cpu_func = STARPU_MULTIPLE_CPU_IMPLEMENTATIONS;
 	}
-	if (cl->cpu_funcs[0] && is_where_unset)
+	if (some_impl && is_where_unset)
 	{
 		cl->where |= STARPU_CPU;
 	}
@@ -404,11 +412,18 @@ void _starpu_codelet_check_deprecated_fields(struct starpu_codelet *cl)
 		cl->cuda_funcs[0] = cl->cuda_func;
 		cl->cuda_func = STARPU_MULTIPLE_CUDA_IMPLEMENTATIONS;
 	}
-	if (cl->cuda_funcs[0] && cl->cuda_func == 0)
+	some_impl = 0;
+	for (i = 0; i < STARPU_MAXIMPLEMENTATIONS; i++)
+		if (cl->cuda_funcs[i])
+		{
+			some_impl = 1;
+			break;
+		}
+	if (some_impl && cl->cuda_func == 0)
 	{
 		cl->cuda_func = STARPU_MULTIPLE_CUDA_IMPLEMENTATIONS;
 	}
-	if (cl->cuda_funcs[0] && is_where_unset)
+	if (some_impl && is_where_unset)
 	{
 		cl->where |= STARPU_CUDA;
 	}
@@ -424,26 +439,54 @@ void _starpu_codelet_check_deprecated_fields(struct starpu_codelet *cl)
 		cl->opencl_funcs[0] = cl->opencl_func;
 		cl->opencl_func = STARPU_MULTIPLE_OPENCL_IMPLEMENTATIONS;
 	}
-	if (cl->opencl_funcs[0] && cl->opencl_func == 0)
+	some_impl = 0;
+	for (i = 0; i < STARPU_MAXIMPLEMENTATIONS; i++)
+		if (cl->opencl_funcs[i])
+		{
+			some_impl = 1;
+			break;
+		}
+	if (some_impl && cl->opencl_func == 0)
 	{
 		cl->opencl_func = STARPU_MULTIPLE_OPENCL_IMPLEMENTATIONS;
 	}
-	if (cl->opencl_funcs[0] && is_where_unset)
+	if (some_impl && is_where_unset)
 	{
 		cl->where |= STARPU_OPENCL;
 	}
 
-	if (cl->mic_funcs[0] && is_where_unset)
+	some_impl = 0;
+	for (i = 0; i < STARPU_MAXIMPLEMENTATIONS; i++)
+		if (cl->mic_funcs[i])
+		{
+			some_impl = 1;
+			break;
+		}
+	if (some_impl && is_where_unset)
 	{
 		cl->where |= STARPU_MIC;
 	}
 
-	if (cl->scc_funcs[0] && is_where_unset)
+	some_impl = 0;
+	for (i = 0; i < STARPU_MAXIMPLEMENTATIONS; i++)
+		if (cl->scc_funcs[i])
+		{
+			some_impl = 1;
+			break;
+		}
+	if (some_impl && is_where_unset)
 	{
 		cl->where |= STARPU_SCC;
 	}
 
-	if (cl->cpu_funcs_name[0] && is_where_unset)
+	some_impl = 0;
+	for (i = 0; i < STARPU_MAXIMPLEMENTATIONS; i++)
+		if (cl->cpu_funcs_name[i])
+		{
+			some_impl = 1;
+			break;
+		}
+	if (some_impl && is_where_unset)
 	{
 		cl->where |= STARPU_MIC|STARPU_SCC;
 	}

+ 1 - 1
src/core/workers.c

@@ -144,7 +144,7 @@ static uint32_t _starpu_worker_exists_and_can_execute(struct starpu_task *task,
 			}
 
 			if (!test_implementation)
-				break;
+				continue;
 
 			if (task->cl->can_execute)
 				return task->cl->can_execute(i, task, impl);