浏览代码

Fix missing destruction of tasks with cl == NULL

Samuel Thibault 13 年之前
父节点
当前提交
1d27ea2bcb
共有 2 个文件被更改,包括 21 次插入1 次删除
  1. 8 1
      src/core/dependencies/tags.c
  2. 13 0
      src/core/task.c

+ 8 - 1
src/core/dependencies/tags.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009, 2010, 2011  Université de Bordeaux 1
+ * Copyright (C) 2009-2012  Université de Bordeaux 1
  * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -176,8 +176,15 @@ void _starpu_tag_set_ready(struct _starpu_tag *tag)
 	/* enforce data dependencies */
 	_starpu_enforce_deps_starting_from_task(j, 1);
 
+	int must_destroy = j->submitted && j->terminated > 0 && j->task->destroy && j->task->detach;
+
 	_STARPU_PTHREAD_MUTEX_UNLOCK(&j->sync_mutex);
 
+	/* If the task terminated immediately (cl == NULL), we have to destroy it ourself */
+
+	if (must_destroy)
+		starpu_task_destroy(j->task);
+
 	_starpu_spin_lock(&tag->lock);
 }
 

+ 13 - 0
src/core/task.c

@@ -211,9 +211,15 @@ int _starpu_submit_job(struct _starpu_job *j)
 	j->submitted = 1;
 
 	int ret = _starpu_enforce_deps_and_schedule(j, 1);
+	int must_destroy = j->submitted && j->terminated > 0 && j->task->destroy && j->task->detach;
 
 	_STARPU_PTHREAD_MUTEX_UNLOCK(&j->sync_mutex);
 
+	/* If the task terminated immediately (cl == NULL), we have to destroy it ourself */
+
+	if (must_destroy)
+		starpu_task_destroy(j->task);
+
         _STARPU_LOG_OUT();
         return ret;
 }
@@ -458,8 +464,15 @@ int _starpu_task_submit_nodeps(struct starpu_task *task)
 
 	ret = _starpu_push_task(j, 1);
 
+	int must_destroy = j->terminated > 0 && j->task->destroy && j->task->detach;
+
 	_STARPU_PTHREAD_MUTEX_UNLOCK(&j->sync_mutex);
 
+	/* If the task terminated immediately (cl == NULL), we have to destroy it ourself */
+
+	if (must_destroy)
+		starpu_task_destroy(j->task);
+
 	return ret;
 }