Переглянути джерело

Factorize calls to MSG_process_sleep

Samuel Thibault 5 роки тому
батько
коміт
7da3610c7b

+ 1 - 1
src/common/thread.c

@@ -99,7 +99,7 @@ int starpu_pthread_join(starpu_pthread_t thread STARPU_ATTRIBUTE_UNUSED, void **
 	MSG_process_unref(thread);
 #endif
 #else
-	MSG_process_sleep(1);
+	starpu_sleep(1);
 #endif
 	return 0;
 }

+ 2 - 2
src/common/thread.h

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2012,2013                                Inria
  * Copyright (C) 2010-2017                                CNRS
- * Copyright (C) 2010-2014,2016,2017                      Université de Bordeaux
+ * Copyright (C) 2010-2014,2016,2017, 2019                      Université de Bordeaux
  *
  * 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
@@ -53,7 +53,7 @@ static inline int _starpu_pthread_spin_lock(starpu_pthread_spinlock_t *lock)
 		}
 		/* Give hand to another thread, hopefully the one which has the
 		 * spinlock and probably just has also a short-lived mutex. */
-		MSG_process_sleep(0.000001);
+		starpu_sleep(0.000001);
 		STARPU_UYIELD();
 	}
 #elif defined(STARPU_LINUX_SYS) && defined(STARPU_HAVE_XCHG)

+ 8 - 8
src/core/simgrid.c

@@ -284,7 +284,7 @@ static int main_ret;
 int do_starpu_main(int argc, char *argv[])
 {
 	/* FIXME: Ugly work-around for bug in simgrid: the MPI context is not properly set at MSG process startup */
-	MSG_process_sleep(0.000001);
+	starpu_sleep(0.000001);
 
 	main_ret = starpu_main(argc, argv);
 	return main_ret;
@@ -455,7 +455,7 @@ void _starpu_simgrid_deinit(void)
 #if SIMGRID_VERSION >= 31400
 				MSG_process_join(t->runner, 1000000);
 #else
-				MSG_process_sleep(1);
+				starpu_sleep(1);
 #endif
 				STARPU_ASSERT(t->first_transfer == NULL);
 				STARPU_ASSERT(t->last_transfer == NULL);
@@ -472,7 +472,7 @@ void _starpu_simgrid_deinit(void)
 #if SIMGRID_VERSION >= 31400
 		MSG_process_join(w->runner, 1000000);
 #else
-		MSG_process_sleep(1);
+		starpu_sleep(1);
 #endif
 		STARPU_ASSERT(w->first_task == NULL);
 		STARPU_ASSERT(w->last_task == NULL);
@@ -508,7 +508,7 @@ struct task
 static int task_execute(int argc STARPU_ATTRIBUTE_UNUSED, char *argv[] STARPU_ATTRIBUTE_UNUSED)
 {
 	/* FIXME: Ugly work-around for bug in simgrid: the MPI context is not properly set at MSG process startup */
-	MSG_process_sleep(0.000001);
+	starpu_sleep(0.000001);
 
 	unsigned workerid = (uintptr_t) STARPU_PTHREAD_GETSPECIFIC(0);
 	struct worker_runner *w = &worker_runner[workerid];
@@ -616,7 +616,7 @@ void _starpu_simgrid_submit_job(int workerid, struct _starpu_job *j, struct star
 		task->next = NULL;
 		/* Sleep 10µs for the GPU task queueing */
 		if (_starpu_simgrid_queue_malloc_cost())
-			MSG_process_sleep(0.000010);
+			starpu_sleep(0.000010);
 		if (w->last_task)
 		{
 			/* Already running a task, queue */
@@ -754,7 +754,7 @@ static void transfer_queue(struct transfer *transfer)
 static int transfer_execute(int argc STARPU_ATTRIBUTE_UNUSED, char *argv[] STARPU_ATTRIBUTE_UNUSED)
 {
 	/* FIXME: Ugly work-around for bug in simgrid: the MPI context is not properly set at MSG process startup */
-	MSG_process_sleep(0.000001);
+	starpu_sleep(0.000001);
 
 	unsigned src_dst = (uintptr_t) STARPU_PTHREAD_GETSPECIFIC(0);
 	unsigned src = src_dst >> 16;
@@ -976,7 +976,7 @@ int _starpu_simgrid_transfer(size_t size, unsigned src_node, unsigned dst_node,
 
 	/* Sleep 10µs for the GPU transfer queueing */
 	if (_starpu_simgrid_queue_malloc_cost())
-		MSG_process_sleep(0.000010);
+		starpu_sleep(0.000010);
 	transfer_submit(transfer);
 	/* Note: from here, transfer might be already freed */
 
@@ -1007,7 +1007,7 @@ _starpu_simgrid_thread_start(int argc STARPU_ATTRIBUTE_UNUSED, char *argv[])
 	void *arg = (void*) (uintptr_t) strtol(argv[1], NULL, 16);
 
 	/* FIXME: Ugly work-around for bug in simgrid: the MPI context is not properly set at MSG process startup */
-	MSG_process_sleep(0.000001);
+	starpu_sleep(0.000001);
 
 	/* _args is freed with process context */
 	f(arg);

+ 2 - 2
src/core/simgrid.h

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2016,2017                                Inria
  * Copyright (C) 2013,2017                                CNRS
- * Copyright (C) 2012-2018                                Université de Bordeaux
+ * Copyright (C) 2012-2019                                Université de Bordeaux
  * Copyright (C) 2013                                     Thibaut Lambert
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -99,7 +99,7 @@ void _starpu_simgrid_xbt_thread_create(const char *name, void_f_pvoid_t code,
 #define _SIMGRID_TIMER_END		\
 		if (__timer) {		\
 			xbt_os_threadtimer_stop(__timer);		\
-			MSG_process_sleep(xbt_os_timer_elapsed(__timer));\
+			starpu_sleep(xbt_os_timer_elapsed(__timer));\
 			xbt_os_timer_free(__timer);		\
 		}	\
 	}

+ 2 - 2
src/core/simgrid_cpp.cpp

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2016,2017                                CNRS
- * Copyright (C) 2012-2018                                Université de Bordeaux
+ * Copyright (C) 2012-2019                                Université de Bordeaux
  * Copyright (C) 2016,2017                                Inria
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -52,7 +52,7 @@ static int _starpu_simgrid_xbt_thread_create_wrapper(int argc STARPU_ATTRIBUTE_U
 #endif
 {
 	/* FIXME: Ugly work-around for bug in simgrid: the MPI context is not properly set at MSG process startup */
-	MSG_process_sleep(0.000001);
+	starpu_sleep(0.000001);
 
 #ifdef HAVE_SMX_ACTOR_T
 	smx_actor_t

+ 1 - 1
src/core/task.c

@@ -738,7 +738,7 @@ int _starpu_task_submit(struct starpu_task *task, int nodeps)
 	ret = _starpu_submit_job(j, nodeps);
 #ifdef STARPU_SIMGRID
 	if (_starpu_simgrid_task_submit_cost())
-		MSG_process_sleep(0.000001);
+		starpu_sleep(0.000001);
 #endif
 
 	if (is_sync)

+ 2 - 2
src/datawizard/coherency.c

@@ -1138,7 +1138,7 @@ int _starpu_fetch_task_input(struct starpu_task *task, struct _starpu_job *j, in
 					_starpu_fetch_task_input_cb, worker, 0, "_starpu_fetch_task_input");
 #ifdef STARPU_SIMGRID
 			if (_starpu_simgrid_fetching_input_cost())
-				MSG_process_sleep(0.000001);
+				starpu_sleep(0.000001);
 #endif
 			if (STARPU_UNLIKELY(ret))
 			{
@@ -1153,7 +1153,7 @@ int _starpu_fetch_task_input(struct starpu_task *task, struct _starpu_job *j, in
 			ret = fetch_data(handle, node, local_replicate, mode, 0);
 #ifdef STARPU_SIMGRID
 			if (_starpu_simgrid_fetching_input_cost())
-				MSG_process_sleep(0.000001);
+				starpu_sleep(0.000001);
 #endif
 			if (STARPU_UNLIKELY(ret))
 				goto enomem;

+ 2 - 2
src/datawizard/data_request.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2008-2017                                Université de Bordeaux
+ * Copyright (C) 2008-2017, 2019                                Université de Bordeaux
  * Copyright (C) 2011,2016,2017                           Inria
  * Copyright (C) 2018                                     Federal University of Rio Grande do Sul (UFRGS)
  * Copyright (C) 2010-2019                                CNRS
@@ -664,7 +664,7 @@ static int __starpu_handle_node_data_requests(struct _starpu_data_request_prio_l
 			 * rather have the caller block, and explicitly wait
 			 * for eviction to happen.
 			 */
-			MSG_process_sleep(0.000001);
+			starpu_sleep(0.000001);
 			_starpu_wake_all_blocked_workers_on_node(src_node);
 		}
 #elif !defined(STARPU_NON_BLOCKING_DRIVERS)

+ 2 - 2
src/datawizard/datawizard.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2016,2017                                Inria
  * Copyright (C) 2010,2011,2013,2015,2017                 CNRS
- * Copyright (C) 2009-2018                                Université de Bordeaux
+ * Copyright (C) 2009-2019                                Université de Bordeaux
  *
  * 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
@@ -34,7 +34,7 @@ int ___starpu_datawizard_progress(unsigned memory_node, unsigned may_alloc, unsi
 
 #ifdef STARPU_SIMGRID
 	/* XXX */
-	MSG_process_sleep(0.000001);
+	starpu_sleep(0.000001);
 #endif
 	STARPU_UYIELD();
 

+ 1 - 1
src/datawizard/malloc.c

@@ -200,7 +200,7 @@ int _starpu_malloc_flags_on_node(unsigned dst_node, void **A, size_t dim, int fl
 		 * instead of computing an average value.
 		 */
 			if (_starpu_simgrid_cuda_malloc_cost())
-				MSG_process_sleep((float) dim * 0.000650 / 1048576.);
+				starpu_sleep((float) dim * 0.000650 / 1048576.);
 #else /* STARPU_SIMGRID */
 #ifdef STARPU_USE_CUDA
 #ifdef STARPU_HAVE_CUDA_MEMCPY_PEER

+ 2 - 2
src/drivers/cpu/driver_cpu.c

@@ -139,7 +139,7 @@ static int execute_job_on_cpu(struct _starpu_job *j, struct starpu_task *worker_
 		{
 			/* Wait for other threads to exit barrier_wait so we
 			 * can safely drop the job structure */
-			MSG_process_sleep(0.0000001);
+			starpu_sleep(0.0000001);
 			j->after_work_busy_barrier = 0;
 		}
 #else
@@ -331,7 +331,7 @@ int _starpu_cpu_driver_run_once(struct _starpu_worker *cpu_worker)
 	}
   #else
 	/* Previous simgrid versions don't really permit to use wait_timedwait in C */
-	MSG_process_sleep(0.001);
+	starpu_sleep(0.001);
   #endif
  #endif
 #endif

+ 2 - 2
src/drivers/cuda/driver_cuda.c

@@ -1471,7 +1471,7 @@ uintptr_t _starpu_cuda_malloc_on_node(unsigned dst_node, size_t size, int flags)
 	/* Sleep for the allocation */
 	STARPU_PTHREAD_MUTEX_LOCK(&cuda_alloc_mutex);
 	if (_starpu_simgrid_cuda_malloc_cost())
-		MSG_process_sleep(0.000175);
+		starpu_sleep(0.000175);
 	if (!last[dst_node])
 		last[dst_node] = 1<<10;
 	addr = last[dst_node];
@@ -1520,7 +1520,7 @@ void _starpu_cuda_free_on_node(unsigned dst_node, uintptr_t addr, size_t size, i
 	STARPU_PTHREAD_MUTEX_LOCK(&cuda_alloc_mutex);
 	/* Sleep for the free */
 	if (_starpu_simgrid_cuda_malloc_cost())
-		MSG_process_sleep(0.000750);
+		starpu_sleep(0.000750);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&cuda_alloc_mutex);
 	/* CUDA also synchronizes roughly everything on cudaFree */
 	_starpu_simgrid_sync_gpus();

+ 2 - 2
src/drivers/opencl/driver_opencl.c

@@ -1293,7 +1293,7 @@ uintptr_t _starpu_opencl_malloc_on_node(unsigned dst_node, size_t size, int flag
 	/* Sleep for the allocation */
 	STARPU_PTHREAD_MUTEX_LOCK(&opencl_alloc_mutex);
 	if (_starpu_simgrid_cuda_malloc_cost())
-		MSG_process_sleep(0.000175);
+		starpu_sleep(0.000175);
 	if (!last[dst_node])
 		last[dst_node] = 1<<10;
 	addr = last[dst_node];
@@ -1326,7 +1326,7 @@ void _starpu_opencl_free_on_node(unsigned dst_node, uintptr_t addr, size_t size,
 	STARPU_PTHREAD_MUTEX_LOCK(&opencl_alloc_mutex);
 	/* Sleep for the free */
 	if (_starpu_simgrid_cuda_malloc_cost())
-		MSG_process_sleep(0.000750);
+		starpu_sleep(0.000750);
 	STARPU_PTHREAD_MUTEX_UNLOCK(&opencl_alloc_mutex);
 #else
 	cl_int err;