Просмотр исходного кода

Rename starpu_mpi_init_with_driver to starpu_mpi_init_with_conf

and use it to make StarPU-MPI automatically reserve a core for its
progression thread.
Samuel Thibault лет назад: 6
Родитель
Сommit
be5815e5bb

+ 1 - 1
ChangeLog

@@ -41,7 +41,7 @@ New features:
     more, StarPU will make the appropriate calls as needed.
   * Add starpu_task_notify_ready_soon_register to be notified when it is
     determined when a task will be ready an estimated amount of time from now.
-  * New StarPU-MPI initialization function (starpu_mpi_init_with_driver)
+  * New StarPU-MPI initialization function (starpu_mpi_init_with_conf)
     which allows the user to give a StarPU driver to the StarPU-MPI
     communication layer, so that the MPI progression thread started by
     StarPU-MPI can also execute tasks and not only take care of

+ 3 - 3
doc/doxygen/chapters/410_mpi_support.doxy

@@ -857,11 +857,11 @@ execution with StarPU-MPI.  However, this could result in a loss of performance
 for applications that does not require an extreme reactivity to MPI
 communications.
 
-The starpu_mpi_init_with_driver() routine allows the user to give the
+The starpu_mpi_init_with_conf() routine allows the user to give the
 starpu_conf configuration structure of StarPU (usually given to the
 starpu_init() routine) to StarPU-MPI, so that StarPU-MPI reserves for its own
-use one of the CPU drivers of the current computing node, and then calls
-starpu_init() internally.
+use one of the CPU drivers of the current computing node, or one of the CPU
+cores, and then calls starpu_init() internally.
 
 This allows the MPI communication thread to call a StarPU CPU driver to run
 tasks when there is no active requests to take care of, and thus recover the

+ 2 - 2
doc/doxygen/chapters/501_environment_variables.doxy

@@ -632,7 +632,7 @@ It of course does not provide computation results and timing.
 \addindex __env__STARPU_MPI_DRIVER_CALL_FREQUENCY
 When set to a positive value, activates the interleaving of the execution of
 tasks with the progression of MPI communications (\ref MPISupport). The
-starpu_mpi_init_with_driver() function must have been called by the application
+starpu_mpi_init_with_conf() function must have been called by the application
 for that environment variable to be used. When set to 0, the MPI progression
 thread does not use at all the driver given by the user, and only focuses on
 making MPI communications progress.
@@ -645,7 +645,7 @@ making MPI communications progress.
 When set to a positive value, the interleaving of the execution of tasks with
 the progression of MPI communications mechanism to execute several tasks before
 checking communication requests again (\ref MPISupport). The
-starpu_mpi_init_with_driver() function must have been called by the application
+starpu_mpi_init_with_conf() function must have been called by the application
 for that environment variable to be used, and the
 STARPU_MPI_DRIVER_CALL_FREQUENCY environment variable set to a positive value.
 </dd>

+ 2 - 2
doc/doxygen/chapters/api/mpi.doxy

@@ -38,12 +38,12 @@ starpu_init() must be called before starpu_mpi_init_comm().
 \ingroup API_MPI_Support
 Call starpu_mpi_init_comm() with the MPI communicator \c MPI_COMM_WORLD.
 
-\fn int starpu_mpi_init_with_driver(int *argc, char ***argv, int initialize_mpi, struct starpu_conf *conf)
+\fn int starpu_mpi_init_with_conf(int *argc, char ***argv, int initialize_mpi, struct starpu_conf *conf)
 \ingroup API_MPI_Support
 Call starpu_mpi_init_comm() with the MPI communicator MPI_COMM_WORLD,
 and keeps the CPU driver 0 for the MPI thread. This driver will be run
 and so execute tasks some times when the MPI thread has no requests to
-handle. starpu_mpi_init_with_driver() also calls starpu_init() internally.
+handle. starpu_mpi_init_with_conf() also calls starpu_init() internally.
 
 \fn int starpu_mpi_initialize(void)
 \deprecated

+ 2 - 2
mpi/include/starpu_mpi.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2012,2014-2017                      Université de Bordeaux
+ * Copyright (C) 2009-2012,2014-2018                      Université de Bordeaux
  * Copyright (C) 2010-2018                                CNRS
  * Copyright (C) 2016                                     Inria
  *
@@ -56,7 +56,7 @@ int starpu_mpi_irecv_detached_sequential_consistency(starpu_data_handle_t data_h
 
 int starpu_mpi_init_comm(int *argc, char ***argv, int initialize_mpi, MPI_Comm comm);
 int starpu_mpi_init(int *argc, char ***argv, int initialize_mpi);
-int starpu_mpi_init_with_driver(int *argc, char ***argv, int initialize_mpi, struct starpu_conf *conf);
+int starpu_mpi_init_with_conf(int *argc, char ***argv, int initialize_mpi, struct starpu_conf *conf);
 int starpu_mpi_initialize(void) STARPU_DEPRECATED;
 int starpu_mpi_initialize_extended(int *rank, int *world_size) STARPU_DEPRECATED;
 int starpu_mpi_shutdown(void);

+ 6 - 6
mpi/src/mpi/starpu_mpi_mpi.c

@@ -1599,14 +1599,14 @@ void _starpu_mpi_driver_init(struct starpu_conf *conf)
 	 * STARPU_MPI_DRIVER_CALL_FREQUENCY is defined by the user. If this environment
 	 * variable is not defined or defined at a value lower than or equal to zero,
 	 * StarPU-MPI will not use a driver. */
-	char *driver_env = starpu_getenv("STARPU_MPI_DRIVER_CALL_FREQUENCY");
-	if (driver_env && atoi(driver_env) > 0)
+	int driver_env = starpu_get_env_number_default("STARPU_MPI_DRIVER_CALL_FREQUENCY", 0);
+	if (driver_env > 0)
 	{
 #ifdef STARPU_SIMGRID
 		_STARPU_DISP("Warning: MPI driver is not supported with simgrid, this will be disabled");
 		return;
 #endif
-		mpi_driver_call_freq = atoi(driver_env);
+		mpi_driver_call_freq = driver_env;
 
 		_STARPU_MALLOC(mpi_driver, sizeof(struct starpu_driver));
 		mpi_driver->type = STARPU_CPU_WORKER;
@@ -1615,9 +1615,9 @@ void _starpu_mpi_driver_init(struct starpu_conf *conf)
 		conf->not_launched_drivers = mpi_driver;
 		conf->n_not_launched_drivers = 1;
 
-		char *tasks_freq_env = starpu_getenv("STARPU_MPI_DRIVER_TASK_FREQUENCY");
-		if (tasks_freq_env)
-			mpi_driver_task_freq = atoi(tasks_freq_env);
+		int tasks_freq_env = starpu_get_env_number_default("STARPU_MPI_DRIVER_TASK_FREQUENCY", 0);
+		if (tasks_freq_env > 0)
+			mpi_driver_task_freq = tasks_freq_env;
 	}
 }
 

+ 10 - 1
mpi/src/starpu_mpi_init.c

@@ -178,11 +178,20 @@ int starpu_mpi_initialize_extended(int *rank, int *world_size)
 #endif
 }
 
-int starpu_mpi_init_with_driver(int *argc, char ***argv, int initialize_mpi, struct starpu_conf *conf)
+int starpu_mpi_init_with_conf(int *argc, char ***argv, int initialize_mpi, struct starpu_conf *conf)
 {
 #if defined(STARPU_USE_MPI_MPI)
 	_starpu_mpi_driver_init(conf);
+
+	if (starpu_get_env_number_default("STARPU_MPI_DRIVER_CALL_FREQUENCY", 0) <= 0)
 #endif
+	{
+		/* Reserve a core for our progression thread */
+		if (conf->reserve_ncpus == -1)
+			conf->reserve_ncpus = 1;
+		else
+			conf->reserve_ncpus++;
+	}
 
 	int ret = starpu_init(conf);
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");

+ 2 - 2
mpi/tests/driver.c

@@ -33,8 +33,8 @@ int main(int argc, char **argv)
 	MPI_INIT_THREAD(&argc, &argv, MPI_THREAD_SERIALIZED, &mpi_init);
 
 	starpu_conf_init(&conf);
-	ret = starpu_mpi_init_with_driver(&argc, &argv, mpi_init, &conf);
-	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init_with_driver");
+	ret = starpu_mpi_init_with_conf(&argc, &argv, mpi_init, &conf);
+	STARPU_CHECK_RETURN_VALUE(ret, "starpu_mpi_init_with_conf");
 
 	starpu_mpi_comm_rank(MPI_COMM_WORLD, &rank);
 	starpu_mpi_comm_size(MPI_COMM_WORLD, &size);