Przeglądaj źródła

Add support for NULL codelets in starpu_insert_task

Sylvain Henry 12 lat temu
rodzic
commit
a5c0165de1

+ 4 - 1
src/util/starpu_insert_task_utils.c

@@ -209,6 +209,8 @@ int _starpu_insert_task_create_and_submit(char *arg_buffer, size_t arg_buffer_si
 
 			enum starpu_access_mode mode = (enum starpu_access_mode) arg_type;
 
+         STARPU_ASSERT(cl != NULL);
+
 			(*task)->handles[current_buffer] = handle;
 			if (cl->modes[current_buffer])
 				STARPU_ASSERT(cl->modes[current_buffer] == mode);
@@ -283,7 +285,7 @@ int _starpu_insert_task_create_and_submit(char *arg_buffer, size_t arg_buffer_si
 
 	va_end(varg_list);
 
-	STARPU_ASSERT(current_buffer == cl->nbuffers);
+	STARPU_ASSERT(cl == NULL || current_buffer == cl->nbuffers);
 
 	(*task)->cl = cl;
 	(*task)->cl_arg = arg_buffer;
@@ -300,6 +302,7 @@ int _starpu_insert_task_create_and_submit(char *arg_buffer, size_t arg_buffer_si
 	{
 		fprintf(stderr, "submission of task %p wih codelet %p failed (symbol `%s') (err: ENODEV)\n",
 			*task, (*task)->cl,
+			(cl == NULL) ? "none" :
 			(*task)->cl->name ? (*task)->cl->name :
 			((*task)->cl->model && (*task)->cl->model->symbol)?(*task)->cl->model->symbol:"none");
 		free(cl_arg_wrapper->arg_stack);

+ 1 - 0
tests/Makefile.am

@@ -130,6 +130,7 @@ noinst_PROGRAMS =				\
 	main/restart				\
 	main/execute_on_a_specific_worker	\
 	main/insert_task			\
+	main/insert_task_nullcodelet			\
 	main/insert_task_array			\
 	main/multithreaded			\
 	main/multithreaded_init			\

+ 46 - 0
tests/main/insert_task_nullcodelet.c

@@ -0,0 +1,46 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2011, 2012  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
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * StarPU is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * See the GNU Lesser General Public License in COPYING.LGPL for more details.
+ */
+
+#include <config.h>
+#include <starpu.h>
+#include "../helper.h"
+
+int main(int argc, char **argv)
+{
+        int  ret;
+
+	ret = starpu_init(NULL);
+	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+
+        ret = starpu_insert_task(NULL, 0);
+	if (ret == -ENODEV) goto enodev;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_insert_task");
+
+        ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
+
+	starpu_shutdown();
+
+	return EXIT_SUCCESS;
+
+enodev:
+	starpu_shutdown();
+	fprintf(stderr, "WARNING: No one can execute this task\n");
+	/* yes, we do not perform the computation but we did detect that no one
+ 	 * could perform the kernel, so this is not an error from StarPU */
+	return STARPU_TEST_SKIPPED;
+}