瀏覽代碼

Add hook for MPI to detect write submissions

Samuel Thibault 7 年之前
父節點
當前提交
8d41716ebc
共有 2 個文件被更改,包括 17 次插入2 次删除
  1. 13 1
      src/core/dependencies/implicit_data_deps.c
  2. 4 1
      src/core/dependencies/implicit_data_deps.h

+ 13 - 1
src/core/dependencies/implicit_data_deps.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2012,2016                                Inria
- * Copyright (C) 2010-2017                                Université de Bordeaux
+ * Copyright (C) 2010-2018                                Université de Bordeaux
  * Copyright (C) 2010-2013,2015-2017                      CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -29,6 +29,14 @@
 # define _STARPU_DEP_DEBUG(fmt, ...)
 #endif
 
+static void (*write_hook)(starpu_data_handle_t);
+
+void _starpu_implicit_data_deps_write_hook(void (*func)(starpu_data_handle_t))
+{
+	STARPU_ASSERT_MSG(!write_hook || write_hook == func, "only one implicit data deps hook at a time\n");
+	write_hook = func;
+}
+
 static void _starpu_add_ghost_dependency(starpu_data_handle_t handle STARPU_ATTRIBUTE_UNUSED, unsigned long previous STARPU_ATTRIBUTE_UNUSED, struct starpu_task *next STARPU_ATTRIBUTE_UNUSED)
 {
 	struct _starpu_job *next_job = _starpu_get_job_associated_to_task(next);
@@ -212,7 +220,11 @@ struct starpu_task *_starpu_detect_implicit_data_deps_with_handle(struct starpu_
 		struct _starpu_job *post_sync_job = _starpu_get_job_associated_to_task(post_sync_task);
 
 		if (mode & STARPU_W || mode == STARPU_REDUX)
+		{
 			handle->initialized = 1;
+			if (write_hook)
+				write_hook(handle);
+		}
 
 		/* Skip tasks that are associated to a reduction phase so that
 		 * they do not interfere with the application. */

+ 4 - 1
src/core/dependencies/implicit_data_deps.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2012,2014-2015,2017                 Université de Bordeaux
+ * Copyright (C) 2010-2012,2014-2015,2017-2018            Université de Bordeaux
  * Copyright (C) 2010-2011,2013,2015,2017                 CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -31,6 +31,9 @@ void _starpu_release_task_enforce_sequential_consistency(struct _starpu_job *j);
 void _starpu_add_post_sync_tasks(struct starpu_task *post_sync_task, starpu_data_handle_t handle);
 void _starpu_unlock_post_sync_tasks(starpu_data_handle_t handle);
 
+/* Register a hook to be called when a write is submitted */
+void _starpu_implicit_data_deps_write_hook(void (*func)(starpu_data_handle_t));
+
 /* This function blocks until the handle is available in the requested mode */
 int _starpu_data_wait_until_available(starpu_data_handle_t handle, enum starpu_data_access_mode mode, const char *sync_name);