Selaa lähdekoodia

port r14265 from 1.1: Fix which simgrid host threads get started on

Samuel Thibault 10 vuotta sitten
vanhempi
commit
1e7a70e4aa
5 muutettua tiedostoa jossa 40 lisäystä ja 25 poistoa
  1. 2 2
      include/starpu_thread.h
  2. 6 16
      src/common/thread.c
  3. 24 0
      src/core/simgrid.c
  4. 2 1
      src/core/simgrid.h
  5. 6 6
      src/core/workers.c

+ 2 - 2
include/starpu_thread.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2012-2014  Université de Bordeaux
+ * Copyright (C) 2010, 2012-2015  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -42,7 +42,7 @@ extern "C"
 typedef msg_process_t starpu_pthread_t;
 typedef int starpu_pthread_attr_t;
 
-int starpu_pthread_create_on(char *name, starpu_pthread_t *thread, const starpu_pthread_attr_t *attr, void *(*start_routine) (void *), void *arg, int where);
+int starpu_pthread_create_on(char *name, starpu_pthread_t *thread, const starpu_pthread_attr_t *attr, void *(*start_routine) (void *), void *arg, msg_host_t host);
 int starpu_pthread_create(starpu_pthread_t *thread, const starpu_pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
 int starpu_pthread_join(starpu_pthread_t thread, void **retval);
 int starpu_pthread_exit(void *retval);

+ 6 - 16
src/common/thread.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010, 2012-2014  Université de Bordeaux
+ * Copyright (C) 2010, 2012-2015  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014  Centre National de la Recherche Scientifique
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -42,30 +42,20 @@ static int _starpu_futex_wake = FUTEX_WAKE;
 
 extern int _starpu_simgrid_thread_start(int argc, char *argv[]);
 
-int starpu_pthread_create_on(char *name, starpu_pthread_t *thread, const starpu_pthread_attr_t *attr, void *(*start_routine) (void *), void *arg, int where)
+int starpu_pthread_create_on(char *name, starpu_pthread_t *thread, const starpu_pthread_attr_t *attr, void *(*start_routine) (void *), void *arg, msg_host_t host)
 {
 	struct _starpu_pthread_args *_args = malloc(sizeof(*_args));
-	xbt_dynar_t _hosts;
 	_args->f = start_routine;
 	_args->arg = arg;
-	if (_starpu_simgrid_running_smpi())
-	{
-		char asname[32];
-		STARPU_ASSERT(starpu_mpi_world_rank);
-		snprintf(asname, sizeof(asname), STARPU_MPI_AS_PREFIX"%u", starpu_mpi_world_rank());
-		_hosts = MSG_environment_as_get_hosts(_starpu_simgrid_get_as_by_name(asname));
-	}
-	else
-		_hosts = MSG_hosts_as_dynar();
-	*thread = MSG_process_create(name, _starpu_simgrid_thread_start, _args,
-			   xbt_dynar_get_as(_hosts, (where), msg_host_t));
-	xbt_dynar_free(&_hosts);
+	if (!host)
+		host = MSG_get_host_by_name("MAIN");
+	*thread = MSG_process_create(name, _starpu_simgrid_thread_start, _args, host);
 	return 0;
 }
 
 int starpu_pthread_create(starpu_pthread_t *thread, const starpu_pthread_attr_t *attr, void *(*start_routine) (void *), void *arg)
 {
-	return starpu_pthread_create_on("", thread, attr, start_routine, arg, 0);
+	return starpu_pthread_create_on("", thread, attr, start_routine, arg, NULL);
 }
 
 int starpu_pthread_join(starpu_pthread_t thread, void **retval)

+ 24 - 0
src/core/simgrid.c

@@ -148,6 +148,30 @@ msg_host_t _starpu_simgrid_get_host_by_name(const char *name)
 		return MSG_get_host_by_name(name);
 }
 
+msg_host_t _starpu_simgrid_get_host_by_worker(struct _starpu_worker *worker)
+{
+	char *prefix;
+	char name[16];
+	msg_host_t host;
+	switch (worker->arch) {
+		case STARPU_CPU_WORKER:
+			prefix = "CPU";
+			break;
+		case STARPU_CUDA_WORKER:
+			prefix = "CUDA";
+			break;
+		case STARPU_OPENCL_WORKER:
+			prefix = "OpenCL";
+			break;
+		default:
+			STARPU_ASSERT(0);
+	}
+	snprintf(name, sizeof(name), "%s%d", prefix, worker->devid);
+	host =  _starpu_simgrid_get_host_by_name(name);
+	STARPU_ASSERT_MSG(host, "Could not find host %s!", name);
+	return host;
+}
+
 #ifdef STARPU_DEVEL
 #warning TODO: use another way to start main, when simgrid provides it, and then include the application-provided configuration for platform numbers
 #endif

+ 2 - 1
src/core/simgrid.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2012-2014  Université de Bordeaux
+ * Copyright (C) 2012-2015  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
@@ -41,6 +41,7 @@ int _starpu_simgrid_transfer(size_t size, unsigned src_node, unsigned dst_node,
 int _starpu_simgrid_get_nbhosts(const char *prefix);
 unsigned long long _starpu_simgrid_get_memsize(const char *prefix, unsigned devid);
 msg_host_t _starpu_simgrid_get_host_by_name(const char *name);
+msg_host_t _starpu_simgrid_get_host_by_worker(struct _starpu_worker *worker);
 void _starpu_simgrid_get_platform_path(char *path, size_t maxlen);
 msg_as_t _starpu_simgrid_get_as_by_name(const char *name);
 #pragma weak starpu_mpi_world_rank

+ 6 - 6
src/core/workers.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2014  Université de Bordeaux
+ * Copyright (C) 2009-2015  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2012, 2013, 2014  Centre National de la Recherche Scientifique
  * Copyright (C) 2010, 2011  Institut National de Recherche en Informatique et Automatique
  * Copyright (C) 2011  Télécom-SudParis
@@ -646,7 +646,7 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
 						NULL,
 						_starpu_cpu_worker,
 						workerarg,
-						worker+1);
+						_starpu_simgrid_get_host_by_worker(workerarg));
 #ifdef STARPU_USE_FXT
 					/* In tracing mode, make sure the
 					 * thread is really started before
@@ -699,7 +699,7 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
 					NULL,
 					_starpu_cuda_worker,
 					&cuda_worker_set[devid],
-					worker+1);
+					_starpu_simgrid_get_host_by_worker(workerarg));
 #ifdef STARPU_USE_FXT
 				STARPU_PTHREAD_MUTEX_LOCK(&workerarg->mutex);
 				while (!workerarg->worker_is_running)
@@ -731,7 +731,7 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
 					NULL,
 					_starpu_opencl_worker,
 					workerarg,
-					worker+1);
+					_starpu_simgrid_get_host_by_worker(workerarg));
 #ifdef STARPU_USE_FXT
 				STARPU_PTHREAD_MUTEX_LOCK(&workerarg->mutex);
 				while (!workerarg->worker_is_running)
@@ -764,7 +764,7 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
 						NULL,
 						_starpu_mic_src_worker,
 						&mic_worker_set[devid],
-						worker+1);
+						_starpu_simgrid_get_host_by_worker(workerarg));
 
 #ifdef STARPU_USE_FXT
 				STARPU_PTHREAD_MUTEX_LOCK(&workerarg->mutex);
@@ -792,7 +792,7 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
 						NULL,
 						_starpu_scc_src_worker,
 						workerarg,
-						worker+1);
+						_starpu_simgrid_get_host_by_worker(workerarg));
 
 #ifdef STARPU_USE_FXT
 				STARPU_PTHREAD_MUTEX_LOCK(&workerarg->mutex);