浏览代码

Permit to disable sequential consistency for a given task.

Samuel Thibault 12 年之前
父节点
当前提交
5b3d87d1c3
共有 7 个文件被更改,包括 112 次插入2 次删除
  1. 1 0
      ChangeLog
  2. 7 1
      doc/chapters/basic-api.texi
  3. 5 0
      include/starpu_task.h
  4. 4 1
      src/core/dependencies/implicit_data_deps.c
  5. 2 0
      src/core/task.c
  6. 1 0
      tests/Makefile.am
  7. 92 0
      tests/main/deploop.c

+ 1 - 0
ChangeLog

@@ -118,6 +118,7 @@ Small features:
   * starpu_perfmodel_plot can now directly draw GFlops curves.
   * starpu_perfmodel_plot can now directly draw GFlops curves.
   * New configure option --enable-mpi-progression-hook to enable the
   * New configure option --enable-mpi-progression-hook to enable the
     activity polling method for StarPU-MPI.
     activity polling method for StarPU-MPI.
+  * Permit to disable sequential consistency for a given task.
 
 
 Changes:
 Changes:
   * Fix the block filter functions.
   * Fix the block filter functions.

+ 7 - 1
doc/chapters/basic-api.texi

@@ -1805,9 +1805,15 @@ contained in the @code{tag_id} field. Tag allow the application to synchronize
 with the task and to express task dependencies easily.
 with the task and to express task dependencies easily.
 
 
 @item @code{starpu_tag_t tag_id}
 @item @code{starpu_tag_t tag_id}
-This fields contains the tag associated to the task if the @code{use_tag} field
+This field contains the tag associated to the task if the @code{use_tag} field
 was set, it is ignored otherwise.
 was set, it is ignored otherwise.
 
 
+@item @code{unsigned sequential_consistency}
+If this flag is set (which is the default), sequential consistency is enforced
+for the data parameters of this task for which sequential consistency is
+enabled. Clearing this flag permits to disable sequential consistency for this
+task, even if data have it enabled.
+
 @item @code{unsigned synchronous}
 @item @code{unsigned synchronous}
 If this flag is set, the @code{starpu_task_submit} function is blocking and
 If this flag is set, the @code{starpu_task_submit} function is blocking and
 returns only when the task has been executed (or if no worker is able to
 returns only when the task has been executed (or if no worker is able to

+ 5 - 0
include/starpu_task.h

@@ -129,9 +129,14 @@ struct starpu_task
 	void (*callback_func)(void *);
 	void (*callback_func)(void *);
 	void *callback_arg;
 	void *callback_arg;
 
 
+	/* Whether tag_id should be considered */
 	unsigned use_tag;
 	unsigned use_tag;
+	/* Tag associated with this task */
 	starpu_tag_t tag_id;
 	starpu_tag_t tag_id;
 
 
+	/* Whether we should enforce sequential consistency for this task */
+	unsigned sequential_consistency;
+
 	/* options for the task execution */
 	/* options for the task execution */
 	unsigned synchronous; /* if set, a call to push is blocking */
 	unsigned synchronous; /* if set, a call to push is blocking */
 	int priority; /* STARPU_MAX_PRIO = most important; STARPU_MIN_PRIO = least important */
 	int priority; /* STARPU_MAX_PRIO = most important; STARPU_MIN_PRIO = least important */

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

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  *
- * Copyright (C) 2010-2012  Université de Bordeaux 1
+ * Copyright (C) 2010-2013  Université de Bordeaux 1
  * Copyright (C) 2010, 2011, 2013  Centre National de la Recherche Scientifique
  * Copyright (C) 2010, 2011, 2013  Centre National de la Recherche Scientifique
  *
  *
  * StarPU is free software; you can redistribute it and/or modify
  * StarPU is free software; you can redistribute it and/or modify
@@ -307,6 +307,9 @@ void _starpu_detect_implicit_data_deps(struct starpu_task *task)
 	STARPU_ASSERT(task->cl);
 	STARPU_ASSERT(task->cl);
         _STARPU_LOG_IN();
         _STARPU_LOG_IN();
 
 
+	if (!task->sequential_consistency)
+		return;
+
 	/* We don't want to enforce a sequential consistency for tasks that are
 	/* We don't want to enforce a sequential consistency for tasks that are
 	 * not visible to the application. */
 	 * not visible to the application. */
 	struct _starpu_job *j = _starpu_get_job_associated_to_task(task);
 	struct _starpu_job *j = _starpu_get_job_associated_to_task(task);

+ 2 - 0
src/core/task.c

@@ -57,6 +57,8 @@ void starpu_task_init(struct starpu_task *task)
 	 * everywhere */
 	 * everywhere */
 	memset(task, 0, sizeof(struct starpu_task));
 	memset(task, 0, sizeof(struct starpu_task));
 
 
+	task->sequential_consistency = 1;
+
 	/* Now we can initialise fields which recquire custom value */
 	/* Now we can initialise fields which recquire custom value */
 #if STARPU_DEFAULT_PRIO != 0
 #if STARPU_DEFAULT_PRIO != 0
 	task->priority = STARPU_DEFAULT_PRIO;
 	task->priority = STARPU_DEFAULT_PRIO;

+ 1 - 0
tests/Makefile.am

@@ -103,6 +103,7 @@ noinst_PROGRAMS =				\
 	main/deprecated_buffer			\
 	main/deprecated_buffer			\
 	main/driver_api/init_run_deinit         \
 	main/driver_api/init_run_deinit         \
 	main/driver_api/run_driver              \
 	main/driver_api/run_driver              \
+	main/deploop                            \
 	main/restart				\
 	main/restart				\
 	main/execute_on_a_specific_worker	\
 	main/execute_on_a_specific_worker	\
 	main/insert_task			\
 	main/insert_task			\

+ 92 - 0
tests/main/deploop.c

@@ -0,0 +1,92 @@
+/* StarPU --- Runtime system for heterogeneous multicore architectures.
+ *
+ * Copyright (C) 2010-2011, 2013  Université de Bordeaux 1
+ * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
+ *
+ * StarPU 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.
+ *
+ * StarPU 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.
+ */
+
+/*
+ * Create task A and B such that
+ * - B depends on A by tag dependency.
+ * - A would depend on B by data dependency, but we disable that.
+ */
+
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <starpu.h>
+#include "../helper.h"
+
+static void dummy_func(void *descr[] __attribute__ ((unused)), void *arg __attribute__ ((unused)))
+{
+	FPRINTF(stderr,"executing task %p\n", starpu_task_get_current());
+}
+
+static struct starpu_codelet dummy_codelet = 
+{
+	.cpu_funcs = {dummy_func, NULL},
+	.cuda_funcs = {dummy_func, NULL},
+	.opencl_funcs = {dummy_func, NULL},
+	.model = NULL,
+	.nbuffers = 1,
+	.modes = { STARPU_RW }
+};
+
+int main(int argc, char **argv)
+{
+	int ret;
+	starpu_data_handle_t handle;
+
+	ret = starpu_init(NULL);
+	if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
+
+	starpu_void_data_register(&handle);
+
+	struct starpu_task *taskA, *taskB;
+
+	/* Make B depend on A */
+	starpu_tag_declare_deps(1, 1, (starpu_tag_t) 0);
+
+	taskA = starpu_task_create();
+	taskA->cl = &dummy_codelet;
+	taskA->tag_id = 0;
+	taskA->use_tag = 1;
+	taskA->handles[0] = handle;
+	taskA->sequential_consistency = 0;
+	FPRINTF(stderr,"A is %p\n", taskA);
+
+	taskB = starpu_task_create();
+	taskB->cl = &dummy_codelet;
+	taskB->tag_id = 1;
+	taskB->use_tag = 1;
+	taskB->handles[0] = handle;
+	FPRINTF(stderr,"B is %p\n", taskB);
+
+	ret = starpu_task_submit(taskB);
+	if (ret == -ENODEV)
+		return STARPU_TEST_SKIPPED;
+	ret = starpu_task_submit(taskA);
+	if (ret == -ENODEV)
+		return STARPU_TEST_SKIPPED;
+
+	ret = starpu_task_wait_for_all();
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
+
+	starpu_data_unregister(handle);
+
+	starpu_shutdown();
+
+	return EXIT_SUCCESS;
+}