Explorar o código

struct starpu_task: add a magic field which is set when initialising the task. starpu_task_submit will fail if the field does not have the right value. This will hence avoid submitting tasks which have not been properly initialised.

Nathalie Furmento %!s(int64=13) %!d(string=hai) anos
pai
achega
75fbf9ee3a
Modificáronse 2 ficheiros con 6 adicións e 2 borrados
  1. 4 2
      include/starpu_task.h
  2. 2 0
      src/core/task.c

+ 4 - 2
include/starpu_task.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010, 2011  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
  * Copyright (C) 2011  Télécom-SudParis
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -195,6 +195,7 @@ struct starpu_task
 	 * by hand (without starpu_task_create), this field should be set to
 	 * NULL. */
 	void *starpu_private;
+	int magic;
 };
 
 /* It is possible to initialize statically allocated tasks with this value.
@@ -219,7 +220,8 @@ struct starpu_task
 	.profiling_info = NULL,				\
 	.predicted = -1.0,				\
 	.predicted_transfer = -1.0,			\
-	.starpu_private = NULL				\
+	.starpu_private = NULL,				\
+	.magic = 42                  			\
 };
 
 /*

+ 2 - 0
src/core/task.c

@@ -78,6 +78,7 @@ void starpu_task_init(struct starpu_task *task)
 	task->predicted_transfer = -1.0;
 
 	task->starpu_private = NULL;
+	task->magic = 42;
 }
 
 /* Free all the ressources allocated for a task, without deallocating the task
@@ -335,6 +336,7 @@ void _starpu_task_check_deprecated_fields(struct starpu_task *task)
 int starpu_task_submit(struct starpu_task *task)
 {
 	STARPU_ASSERT(task);
+	STARPU_ASSERT(task->magic == 42);
 
 	int ret;
 	unsigned is_sync = task->synchronous;