ソースを参照

Allows users to disable asynchronous copies. This should be done when using OpenCL AMD implementation as it is known to fail when asynchronously copying data.

Nathalie Furmento 13 年 前
コミット
dc071405ca
共有4 個のファイルを変更した41 個の追加1 個の削除を含む
  1. 5 0
      include/starpu.h
  2. 17 0
      src/core/workers.c
  3. 4 1
      src/core/workers.h
  4. 15 0
      src/datawizard/interfaces/data_interface.c

+ 5 - 0
include/starpu.h

@@ -80,6 +80,9 @@ struct starpu_conf
 
 	/* Create only one combined worker, containing all CPU workers */
 	int single_combined_worker;
+
+        /* indicate if the asynchronous copies should be disabled */
+	int disable_asynchronous_copy;
 };
 
 /* Initialize a starpu_conf structure with default values. */
@@ -104,6 +107,8 @@ unsigned starpu_cuda_worker_get_count(void);
 unsigned starpu_spu_worker_get_count(void);
 unsigned starpu_opencl_worker_get_count(void);
 
+int starpu_disable_asynchronous_copy();
+
 /* Return the identifier of the thread in case this is associated to a worker.
  * This will return -1 if this function is called directly from the application
  * or if it is some SPU worker where a single thread controls different SPUs. */

+ 17 - 0
src/core/workers.c

@@ -368,6 +368,8 @@ int starpu_conf_init(struct starpu_conf *conf)
 
 	conf->single_combined_worker = starpu_get_env_number("STARPU_SINGLE_COMBINED_WORKER");
 
+	conf->disable_asynchronous_copy = starpu_get_env_number("STARPU_DISABLE_ASYNCHRONOUS_COPY");
+
 	return 0;
 }
 
@@ -444,6 +446,16 @@ int starpu_init(struct starpu_conf *user_conf)
 	 * initialization */
 	config.user_conf = user_conf;
 
+	if (user_conf)
+	{
+	     config.disable_asynchronous_copy = (user_conf->disable_asynchronous_copy == 1);
+	}
+	else
+	{
+	     int disable_asynchronous_copy = starpu_get_env_number("STARPU_DISABLE_ASYNCHRONOUS_COPY");
+	     config.disable_asynchronous_copy = (disable_asynchronous_copy == 1);
+	}
+
 	ret = _starpu_build_topology(&config);
 	if (ret)
 	{
@@ -689,6 +701,11 @@ unsigned starpu_spu_worker_get_count(void)
 	return config.topology.ngordon_spus;
 }
 
+int starpu_disable_asynchronous_copy()
+{
+	return config.disable_asynchronous_copy;
+}
+
 /* When analyzing performance, it is useful to see what is the processing unit
  * that actually performed the task. This function returns the id of the
  * processing unit actually executing it, therefore it makes no sense to use it

+ 4 - 1
src/core/workers.h

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2009-2012  Université de Bordeaux 1
- * Copyright (C) 2010, 2011  Centre National de la Recherche Scientifique
+ * 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
@@ -157,6 +157,9 @@ struct _starpu_machine_config
 
 	/* this flag is set until the runtime is stopped */
 	unsigned running;
+
+        /* indicate if the asynchronous copies should be disabled */
+        int disable_asynchronous_copy;
 };
 
 /* Has starpu_shutdown already been called ? */

+ 15 - 0
src/datawizard/interfaces/data_interface.c

@@ -288,6 +288,21 @@ void starpu_data_register(starpu_data_handle_t *handleptr, uint32_t home_node,
 	*handleptr = handle;
 	handle->mf_node = home_node;
 
+	int disable_asynchronous_copy = starpu_disable_asynchronous_copy();
+	if (STARPU_UNLIKELY(disable_asynchronous_copy))
+	{
+#ifdef STARPU_USE_CUDA
+	     ((struct starpu_data_copy_methods *)ops->copy_methods)->ram_to_cuda_async = NULL;
+	     ((struct starpu_data_copy_methods *)ops->copy_methods)->cuda_to_ram_async = NULL;
+	     ((struct starpu_data_copy_methods *)ops->copy_methods)->cuda_to_cuda_async = NULL;
+#endif
+#ifdef STARPU_USE_OPENCL
+	     ((struct starpu_data_copy_methods *)ops->copy_methods)->ram_to_opencl_async = NULL;
+	     ((struct starpu_data_copy_methods *)ops->copy_methods)->opencl_to_ram_async = NULL;
+	     ((struct starpu_data_copy_methods *)ops->copy_methods)->opencl_to_opencl_async = NULL;
+#endif
+	}
+
 	/* fill the interface fields with the appropriate method */
 	STARPU_ASSERT(ops->register_data_handle);
 	ops->register_data_handle(handle, home_node, data_interface);