Browse Source

merge functions _starpu_cuda_init() and _starpu_init_cuda()

Nathalie Furmento 6 years ago
parent
commit
418ef40489
3 changed files with 16 additions and 22 deletions
  1. 8 10
      src/core/topology.c
  2. 7 11
      src/drivers/cuda/driver_cuda.c
  3. 1 1
      src/drivers/cuda/driver_cuda.h

+ 8 - 10
src/core/topology.c

@@ -485,9 +485,7 @@ static void _starpu_initialize_workers_cuda_gpuid(struct _starpu_machine_config
 	struct _starpu_machine_topology *topology = &config->topology;
 	struct starpu_conf *uconf = &config->conf;
 
-        _starpu_initialize_workers_deviceid(uconf->use_explicit_workers_cuda_gpuid == 0
-					    ? NULL
-					    : (int *)uconf->workers_cuda_gpuid,
+        _starpu_initialize_workers_deviceid(uconf->use_explicit_workers_cuda_gpuid == 0 ? NULL : (int *)uconf->workers_cuda_gpuid,
 					    &(config->current_cuda_gpuid),
 					    (int *)topology->workers_cuda_gpuid,
 					    "STARPU_WORKERS_CUDAID",
@@ -1076,7 +1074,7 @@ unsigned _starpu_topology_get_nhwcpu(struct _starpu_machine_config *config)
 #endif
 #if defined(STARPU_USE_CUDA) || defined(STARPU_SIMGRID)
 	if (config->conf.ncuda != 0)
-		_starpu_init_cuda();
+		_starpu_cuda_init();
 #endif
 	_starpu_init_topology(config);
 
@@ -1091,7 +1089,7 @@ unsigned _starpu_topology_get_nhwpu(struct _starpu_machine_config *config)
 #endif
 #if defined(STARPU_USE_CUDA) || defined(STARPU_SIMGRID)
 	if (config->conf.ncuda != 0)
-		_starpu_init_cuda();
+		_starpu_cuda_init();
 #endif
 	_starpu_init_topology(config);
 
@@ -1106,7 +1104,7 @@ unsigned _starpu_topology_get_nnumanodes(struct _starpu_machine_config *config S
 #endif
 #if defined(STARPU_USE_CUDA) || defined(STARPU_SIMGRID)
 	if (config->conf.ncuda != 0)
-		_starpu_init_cuda();
+		_starpu_cuda_init();
 #endif
         _starpu_init_topology(config);
 
@@ -1459,7 +1457,7 @@ static int _starpu_init_machine_config(struct _starpu_machine_config *config, in
 #endif
 #if defined(STARPU_USE_CUDA) || defined(STARPU_SIMGRID)
 	if (config->conf.ncuda != 0)
-		_starpu_init_cuda();
+		_starpu_cuda_init();
 #endif
 	_starpu_init_topology(config);
 
@@ -1497,7 +1495,7 @@ static int _starpu_init_machine_config(struct _starpu_machine_config *config, in
 	{
 		/* The user did not disable CUDA. We need to initialize CUDA
  		 * early to count the number of devices */
-		_starpu_init_cuda();
+		_starpu_cuda_init();
 		int nb_devices = _starpu_get_cuda_device_count();
 
 		STARPU_ASSERT_MSG(ncuda >= -1, "ncuda can not be negative and different from -1 (is is %d)", ncuda);
@@ -1891,7 +1889,7 @@ int _starpu_bind_thread_on_cpu(int cpuid STARPU_ATTRIBUTE_UNUSED, int workerid S
 #endif
 #ifdef STARPU_USE_CUDA
 	if (config->conf.ncuda != 0)
-		_starpu_init_cuda();
+		_starpu_cuda_init();
 #endif
 	_starpu_init_topology(config);
 
@@ -2008,7 +2006,7 @@ void _starpu_bind_thread_on_cpus(struct _starpu_combined_worker *combined_worker
 #endif
 #ifdef STARPU_USE_CUDA
 	if (config->conf.ncuda != 0)
-		_starpu_init_cuda();
+		_starpu_cuda_init();
 #endif
 	_starpu_init_topology(config);
 

+ 7 - 11
src/drivers/cuda/driver_cuda.c

@@ -85,16 +85,6 @@ static int cuda_device_users[STARPU_MAXCUDADEVS];
 static starpu_pthread_mutex_t cuda_device_init_mutex[STARPU_MAXCUDADEVS];
 static starpu_pthread_cond_t cuda_device_init_cond[STARPU_MAXCUDADEVS];
 
-void _starpu_cuda_init(void)
-{
-	unsigned i;
-	for (i = 0; i < STARPU_MAXCUDADEVS; i++)
-	{
-		STARPU_PTHREAD_MUTEX_INIT(&cuda_device_init_mutex[i], NULL);
-		STARPU_PTHREAD_COND_INIT(&cuda_device_init_cond[i], NULL);
-	}
-}
-
 static size_t _starpu_cuda_get_global_mem_size(unsigned devid)
 {
 	return global_mem[devid];
@@ -475,8 +465,14 @@ unsigned _starpu_get_cuda_device_count(void)
 }
 
 /* This is run from initialize to determine the number of CUDA devices */
-void _starpu_init_cuda(void)
+void _starpu_cuda_init(void)
 {
+	unsigned i;
+	for (i = 0; i < STARPU_MAXCUDADEVS; i++)
+	{
+		STARPU_PTHREAD_MUTEX_INIT(&cuda_device_init_mutex[i], NULL);
+		STARPU_PTHREAD_COND_INIT(&cuda_device_init_cond[i], NULL);
+	}
 	if (ncudagpus < 0)
 	{
 		ncudagpus = _starpu_get_cuda_device_count();

+ 1 - 1
src/drivers/cuda/driver_cuda.h

@@ -40,7 +40,7 @@ extern int _starpu_cuda_bus_ids[STARPU_MAXCUDADEVS+STARPU_MAXNUMANODES][STARPU_M
 
 #if defined(STARPU_USE_CUDA) || defined(STARPU_SIMGRID)
 void _starpu_cuda_discover_devices (struct _starpu_machine_config *);
-void _starpu_init_cuda(void);
+void _starpu_cuda_init(void);
 void *_starpu_cuda_worker(void *);
 #else
 #  define _starpu_cuda_discover_devices(config) ((void) config)