Browse Source

When submitting a task to a specific worker, we also check that this worker is
able to perform the task.

Cédric Augonnet 15 years ago
parent
commit
d5e905e7c9
3 changed files with 69 additions and 1 deletions
  1. 4 1
      src/core/jobs.c
  2. 4 0
      tests/Makefile.am
  3. 61 0
      tests/errorcheck/invalid_tasks.c

+ 4 - 1
src/core/jobs.c

@@ -287,7 +287,10 @@ struct starpu_job_s *_starpu_pop_local_task(struct starpu_worker_s *worker)
 
 int _starpu_push_local_task(struct starpu_worker_s *worker, struct starpu_job_s *j)
 {
-	/* TODO check that the worker is able to execute the task ! */
+	/* Check that the worker is able to execute the task ! */
+	STARPU_ASSERT(j->task && j->task->cl);
+	if (STARPU_UNLIKELY(!(worker->worker_mask & j->task->cl->where)))
+		return -ENODEV;
 
 	pthread_mutex_lock(&worker->local_jobs_mutex);
 

+ 4 - 0
tests/Makefile.am

@@ -95,6 +95,7 @@ check_PROGRAMS += 				\
 	datawizard/sync_with_data_with_mem_non_blocking\
 	errorcheck/starpu_init_noworker		\
 	errorcheck/invalid_blocking_calls	\
+	errorcheck/invalid_tasks		\
 	helper/cublas_init			\
 	helper/pinned_memory			\
 	helper/execute_on_all			\
@@ -179,6 +180,9 @@ errorcheck_starpu_init_noworker_SOURCES =	\
 errorcheck_invalid_blocking_calls_SOURCES =	\
 	errorcheck/invalid_blocking_calls.c
 
+errorcheck_invalid_tasks_SOURCES =		\
+	errorcheck/invalid_tasks.c
+
 helper_cublas_init_SOURCES =			\
 	helper/cublas_init.c
 

+ 61 - 0
tests/errorcheck/invalid_tasks.c

@@ -0,0 +1,61 @@
+/*
+ * StarPU
+ * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
+ *
+ * This program 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.
+ *
+ * This program 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 <starpu.h>
+
+static void dummy_func(void *descr[], void *arg)
+{
+}
+
+static starpu_codelet cuda_only_cl = 
+{
+	.where = STARPU_CUDA,
+	.cuda_func = dummy_func,
+	.model = NULL,
+	.nbuffers = 0
+};
+
+int main(int argc, char **argv)
+{
+	int ret;
+
+	/* We force StarPU to use 1 CPU only */
+	struct starpu_conf conf;
+	memset(&conf, 0, sizeof(conf));
+	conf.ncpus = 1;
+
+	starpu_init(&conf);
+
+	struct starpu_task *task = starpu_task_create();
+	task->cl = &cuda_only_cl;
+
+	/* Only a CUDA device could execute that task ! */
+	ret = starpu_submit_task(task);
+	STARPU_ASSERT(ret == -ENODEV);
+
+	struct starpu_task *task_specific = starpu_task_create();
+	task_specific->cl = &cuda_only_cl;
+	task_specific->execute_on_a_specific_worker = 1;
+	task_specific->workerid = 0;
+
+	/* Only a CUDA device could execute that task ! */
+	ret = starpu_submit_task(task_specific);
+	STARPU_ASSERT(ret == -ENODEV);
+
+	starpu_shutdown();
+
+	return 0;
+}