소스 검색

The starpu_create_sync_task helper function creates an empty task which is a
synchronization point.

Cédric Augonnet 15 년 전
부모
커밋
b3b1dc5ad0
3개의 변경된 파일43개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      include/starpu-util.h
  2. 1 0
      src/Makefile.am
  3. 37 0
      src/util/starpu_create_sync_task.c

+ 5 - 0
include/starpu-util.h

@@ -22,6 +22,7 @@
 #include <string.h>
 #include <assert.h>
 #include <starpu_config.h>
+#include <starpu-task.h>
 
 #ifdef USE_CUDA
 #include <cuda.h>
@@ -220,6 +221,10 @@ void starpu_helper_shutdown_cublas(void);
  * */
 void starpu_execute_on_each_worker(void (*func)(void *), void *arg, uint32_t where);
 
+/* This creates (and submits) an empty task that unlocks a tag once all its
+ * dependencies are fulfilled. */
+void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t *deps);
+
 #ifdef USE_CUDA
 /* In case the application is using streams, these functions will
  * repespectively create, and return, a unique stream for every GPU worker. */

+ 1 - 0
src/Makefile.am

@@ -132,6 +132,7 @@ libstarpu_la_SOURCES = 						\
 	datawizard/interfaces/vector_filters.c			\
 	util/malloc.c						\
 	util/execute_on_all.c					\
+	util/starpu_create_sync_task.c				\
 	util/starpu_get_local_cuda_stream.c			\
 	util/starpu_cublas.c
 	

+ 37 - 0
src/util/starpu_create_sync_task.c

@@ -0,0 +1,37 @@
+/*
+ * StarPU
+ * Copyright (C) INRIA 2008-2010 (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>
+#include <common/config.h>
+
+/* This creates (and submits) an empty task that unlocks a tag once all its
+ * dependencies are fulfilled. */
+void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t *deps)
+{
+	starpu_tag_declare_deps_array(sync_tag, ndeps, deps);
+
+	/* We create an empty task */
+	struct starpu_task *sync_task = starpu_task_create();
+
+	sync_task->use_tag = 1;
+	sync_task->tag_id = sync_tag;
+
+	/* This task does nothing */
+	sync_task->cl = NULL;
+
+	int sync_ret = starpu_submit_task(sync_task);
+	STARPU_ASSERT(!sync_ret);
+}