ソースを参照

the application may explicitely notify the termination of a tag

Cédric Augonnet 16 年 前
コミット
7ded07e8b9
共有2 個のファイルを変更した36 個の追加25 個の削除を含む
  1. 3 0
      include/starpu-task.h
  2. 33 25
      src/core/dependencies/tags.c

+ 3 - 0
include/starpu-task.h

@@ -154,6 +154,9 @@ void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t
 void starpu_tag_wait(starpu_tag_t id);
 void starpu_tag_wait_array(unsigned ntags, starpu_tag_t *id);
 
+/* it is possible that the application use tags explicitely */
+void starpu_tag_notify_from_apps(starpu_tag_t id);
+
 struct starpu_task *starpu_task_create(void);
 int starpu_submit_task(struct starpu_task *task);
 

+ 33 - 25
src/core/dependencies/tags.c

@@ -214,42 +214,51 @@ static void tag_add_succ(struct tag_s *tag, cg_t *cg)
 	pthread_spin_unlock(&tag->lock);
 }
 
-void notify_dependencies(struct job_s *j)
+static void notify_tag_dependencies(struct tag_s *tag)
 {
-	struct tag_s *tag;
 	unsigned nsuccs;
 	unsigned succ;
 
-	STARPU_ASSERT(j);
-	
-	if (j->task->use_tag) {
-		/* in case there are dependencies, wake up the proper tasks */
-		tag = j->tag;
+	pthread_spin_lock(&tag->lock);
 
-		pthread_spin_lock(&tag->lock);
+	tag->state = DONE;
+	TRACE_TASK_DONE(tag->id);
 
-		tag->state = DONE;
-		TRACE_TASK_DONE(tag->id);
+	nsuccs = tag->nsuccs;
 
-		nsuccs = tag->nsuccs;
+	for (succ = 0; succ < nsuccs; succ++)
+	{
+		struct _cg_t *cg = tag->succ[succ];
+		unsigned used_by_apps = cg->used_by_apps;
+		struct tag_s *cgtag = cg->tag;
 
-		for (succ = 0; succ < nsuccs; succ++)
-		{
-			struct _cg_t *cg = tag->succ[succ];
-			unsigned used_by_apps = cg->used_by_apps;
-			struct tag_s *cgtag = cg->tag;
+		if (!used_by_apps)
+			pthread_spin_lock(&cgtag->lock);
 
-			if (!used_by_apps)
-				pthread_spin_lock(&cgtag->lock);
+		notify_cg(cg);
 
-			notify_cg(cg);
+		if (!used_by_apps)
+			pthread_spin_unlock(&cgtag->lock);
+	}
 
-			if (!used_by_apps)
-				pthread_spin_unlock(&cgtag->lock);
-		}
+	pthread_spin_unlock(&tag->lock);
+}
 
-		pthread_spin_unlock(&tag->lock);
-	}
+void notify_dependencies(struct job_s *j)
+{
+	STARPU_ASSERT(j);
+	STARPU_ASSERT(j->task);
+	
+	/* in case there are dependencies, wake up the proper tasks */
+	if (j->task->use_tag)
+		notify_tag_dependencies(j->tag);
+}
+
+void starpu_tag_notify_from_apps(starpu_tag_t id)
+{
+	struct tag_s *tag = gettag_struct(id);
+
+	notify_tag_dependencies(tag);
 }
 
 void tag_declare(starpu_tag_t id, struct job_s *job)
@@ -389,4 +398,3 @@ void starpu_tag_wait(starpu_tag_t id)
 {
 	starpu_tag_wait_array(1, &id);
 }
-