瀏覽代碼

rename starpu_conf::ignore_environment_variables into starpu_conf::precedence_over_environment_variables and complete test starpu_init
(followup to previous commit)

Nathalie Furmento 5 年之前
父節點
當前提交
5b1ad9865a

+ 1 - 1
ChangeLog

@@ -54,7 +54,7 @@ Small features:
   * Add STARPU_WORKERS_GETBIND environment variable.
   * Add STARPU_SCHED_SIMPLE_DECIDE_ALWAYS modular scheduler flag.
   * And STARPU_LIMIT_BANDWIDTH environment variable.
-  * Add field starpu_conf::ignore_environment_variables to ignore
+  * Add field starpu_conf::precedence_over_environment_variables to ignore
     environment variables when parameters are set directly in starpu_conf
 
 StarPU 1.3.3 (git revision 11afc5b007fe1ab1c729b55b47a5a98ef7f3cfad)

+ 2 - 2
include/starpu.h

@@ -130,11 +130,11 @@ struct starpu_conf
 	   also be set with environment variables, by default,
 	   StarPU chooses the value of the environment variable
 	   against the value set in starpu_conf. Setting the parameter
-	   starpu_conf::ignore_environment_variables to 1 allows to give precedence
+	   starpu_conf::precedence_over_environment_variables to 1 allows to give precedence
 	   to the value set in the structure over the environment
 	   variable.
 	 */
-	int ignore_environment_variables;
+	int precedence_over_environment_variables;
 
 	/**
 	   Number of CPU cores that StarPU can use. This can also be

+ 1 - 1
socl/src/init.c

@@ -57,7 +57,7 @@ int socl_init_starpu(void)
 	STARPU_PTHREAD_MUTEX_UNLOCK(&_socl_mutex);
 
 	starpu_conf_init(&conf);
-	conf.ignore_environment_variables = 1;
+	conf.precedence_over_environment_variables = 1;
 	conf.ncuda = 0;
 	conf.ncpus = 0;
 

+ 15 - 15
src/core/workers.c

@@ -1148,9 +1148,9 @@ int starpu_conf_init(struct starpu_conf *conf)
 	return 0;
 }
 
-static void _starpu_conf_set_value_against_environment(char *name, int *value, int ignore_env)
+static void _starpu_conf_set_value_against_environment(char *name, int *value, int precedence_over_env)
 {
-	if (ignore_env == 0)
+	if (precedence_over_env == 0)
 	{
 		int number;
 		number = starpu_get_env_number(name);
@@ -1169,16 +1169,16 @@ void _starpu_conf_check_environment(struct starpu_conf *conf)
 		conf->sched_policy_name = sched;
 	}
 
-	_starpu_conf_set_value_against_environment("STARPU_NCPUS", &conf->ncpus, conf->ignore_environment_variables);
-	_starpu_conf_set_value_against_environment("STARPU_NCPU", &conf->ncpus, conf->ignore_environment_variables);
-	_starpu_conf_set_value_against_environment("STARPU_RESERVE_NCPU", &conf->reserve_ncpus, conf->ignore_environment_variables);
+	_starpu_conf_set_value_against_environment("STARPU_NCPUS", &conf->ncpus, conf->precedence_over_environment_variables);
+	_starpu_conf_set_value_against_environment("STARPU_NCPU", &conf->ncpus, conf->precedence_over_environment_variables);
+	_starpu_conf_set_value_against_environment("STARPU_RESERVE_NCPU", &conf->reserve_ncpus, conf->precedence_over_environment_variables);
 	int main_thread_bind = starpu_get_env_number_default("STARPU_MAIN_THREAD_BIND", 0);
 	if (main_thread_bind)
 		conf->reserve_ncpus++;
-	_starpu_conf_set_value_against_environment("STARPU_NCUDA", &conf->ncuda, conf->ignore_environment_variables);
-	_starpu_conf_set_value_against_environment("STARPU_NOPENCL", &conf->nopencl, conf->ignore_environment_variables);
-	_starpu_conf_set_value_against_environment("STARPU_CALIBRATE", &conf->calibrate, conf->ignore_environment_variables);
-	_starpu_conf_set_value_against_environment("STARPU_BUS_CALIBRATE", &conf->bus_calibrate, conf->ignore_environment_variables);
+	_starpu_conf_set_value_against_environment("STARPU_NCUDA", &conf->ncuda, conf->precedence_over_environment_variables);
+	_starpu_conf_set_value_against_environment("STARPU_NOPENCL", &conf->nopencl, conf->precedence_over_environment_variables);
+	_starpu_conf_set_value_against_environment("STARPU_CALIBRATE", &conf->calibrate, conf->precedence_over_environment_variables);
+	_starpu_conf_set_value_against_environment("STARPU_BUS_CALIBRATE", &conf->bus_calibrate, conf->precedence_over_environment_variables);
 #ifdef STARPU_SIMGRID
 	if (conf->calibrate == 2)
 	{
@@ -1189,12 +1189,12 @@ void _starpu_conf_check_environment(struct starpu_conf *conf)
 		_STARPU_DISP("Warning: Bus calibration will be cleared due to bus_calibrate or STARPU_BUS_CALIBRATE being set. This will prevent simgrid from having data transfer simulation times!");
 	}
 #endif
-	_starpu_conf_set_value_against_environment("STARPU_SINGLE_COMBINED_WORKER", &conf->single_combined_worker, conf->ignore_environment_variables);
-	_starpu_conf_set_value_against_environment("STARPU_DISABLE_ASYNCHRONOUS_COPY", &conf->disable_asynchronous_copy, conf->ignore_environment_variables);
-	_starpu_conf_set_value_against_environment("STARPU_DISABLE_ASYNCHRONOUS_CUDA_COPY", &conf->disable_asynchronous_cuda_copy, conf->ignore_environment_variables);
-	_starpu_conf_set_value_against_environment("STARPU_DISABLE_ASYNCHRONOUS_OPENCL_COPY", &conf->disable_asynchronous_opencl_copy, conf->ignore_environment_variables);
-	_starpu_conf_set_value_against_environment("STARPU_DISABLE_ASYNCHRONOUS_MIC_COPY", &conf->disable_asynchronous_mic_copy, conf->ignore_environment_variables);
-	_starpu_conf_set_value_against_environment("STARPU_DISABLE_ASYNCHRONOUS_MPI_MS_COPY", &conf->disable_asynchronous_mpi_ms_copy, conf->ignore_environment_variables);
+	_starpu_conf_set_value_against_environment("STARPU_SINGLE_COMBINED_WORKER", &conf->single_combined_worker, conf->precedence_over_environment_variables);
+	_starpu_conf_set_value_against_environment("STARPU_DISABLE_ASYNCHRONOUS_COPY", &conf->disable_asynchronous_copy, conf->precedence_over_environment_variables);
+	_starpu_conf_set_value_against_environment("STARPU_DISABLE_ASYNCHRONOUS_CUDA_COPY", &conf->disable_asynchronous_cuda_copy, conf->precedence_over_environment_variables);
+	_starpu_conf_set_value_against_environment("STARPU_DISABLE_ASYNCHRONOUS_OPENCL_COPY", &conf->disable_asynchronous_opencl_copy, conf->precedence_over_environment_variables);
+	_starpu_conf_set_value_against_environment("STARPU_DISABLE_ASYNCHRONOUS_MIC_COPY", &conf->disable_asynchronous_mic_copy, conf->precedence_over_environment_variables);
+	_starpu_conf_set_value_against_environment("STARPU_DISABLE_ASYNCHRONOUS_MPI_MS_COPY", &conf->disable_asynchronous_mpi_ms_copy, conf->precedence_over_environment_variables);
 }
 
 struct starpu_tree* starpu_workers_get_tree(void)

+ 1 - 1
tests/disk/disk_copy.c

@@ -65,7 +65,7 @@ int dotest(struct starpu_disk_ops *ops, void *param)
 	ret = starpu_conf_init(&conf);
 	if (ret == -EINVAL)
 		return EXIT_FAILURE;
-	conf.ignore_environment_variables = 1;
+	conf.precedence_over_environment_variables = 1;
 	conf.ncpus = 1;
 	conf.ncuda = 0;
 	conf.nopencl = 0;

+ 1 - 1
tests/disk/disk_copy_unpack.c

@@ -53,7 +53,7 @@ int dotest(struct starpu_disk_ops *ops, void *param)
 	ret = starpu_conf_init(&conf);
 	if (ret == -EINVAL)
 		return EXIT_FAILURE;
-	conf.ignore_environment_variables = 1;
+	conf.precedence_over_environment_variables = 1;
 	conf.ncuda = 0;
 	conf.nopencl = 0;
 	conf.nmic = 0;

+ 1 - 1
tests/disk/disk_pack.c

@@ -65,7 +65,7 @@ int dotest(struct starpu_disk_ops *ops, char *base)
 	int ret = starpu_conf_init(&conf);
 	if (ret == -EINVAL)
 		return EXIT_FAILURE;
-	conf.ignore_environment_variables = 1;
+	conf.precedence_over_environment_variables = 1;
 	conf.ncuda = 0;
 	conf.nopencl = 0;
 	conf.nmic = 0;

+ 1 - 1
tests/disk/mem_reclaim.c

@@ -158,7 +158,7 @@ int dotest(struct starpu_disk_ops *ops, char *base, void (*vector_data_register)
 	int ret = starpu_conf_init(&conf);
 	if (ret == -EINVAL)
 		return EXIT_FAILURE;
-	conf.ignore_environment_variables = 1;
+	conf.precedence_over_environment_variables = 1;
 	conf.ncuda = 0;
 	conf.nopencl = 0;
 	conf.nmic = 0;

+ 1 - 1
tests/errorcheck/invalid_tasks.c

@@ -50,7 +50,7 @@ int main(void)
 	/* We force StarPU to use 1 CPU only */
 	struct starpu_conf conf;
 	starpu_conf_init(&conf);
-	conf.ignore_environment_variables = 1;
+	conf.precedence_over_environment_variables = 1;
 	conf.ncpus = 1;
 	conf.nopencl = 0;
 	conf.ncuda = 0;

+ 1 - 1
tests/errorcheck/starpu_init_noworker.c

@@ -32,7 +32,7 @@ int main(int argc, char **argv)
 	/* We try to initialize StarPU without any worker */
 	struct starpu_conf conf;
 	starpu_conf_init(&conf);
-	conf.ignore_environment_variables = 1;
+	conf.precedence_over_environment_variables = 1;
 	conf.ncpus = 0;
 	conf.ncuda = 0;
 	conf.nopencl = 0;

+ 1 - 1
tests/errorcheck/workers_cpuid.c

@@ -101,7 +101,7 @@ static int test_combination(long *combination, unsigned n)
 
 	struct starpu_conf conf;
 	starpu_conf_init(&conf);
-	conf.ignore_environment_variables = 1;
+	conf.precedence_over_environment_variables = 1;
 	conf.ncuda = 0;
 	conf.nopencl = 0;
 	conf.nmic = 0;

+ 1 - 1
tests/main/driver_api/init_run_deinit.c

@@ -228,7 +228,7 @@ static int test_opencl(void)
 		.id.opencl_id = device_id
 	};
 
-	conf.ignore_environment_variables = 1;
+	conf.precedence_over_environment_variables = 1;
 	conf.ncpus = 0;
 	conf.ncuda = 0;
 	conf.nopencl = 1;

+ 1 - 1
tests/main/driver_api/run_driver.c

@@ -220,7 +220,7 @@ static int test_opencl(void)
 	};
 
 	starpu_conf_init(&conf);
-	conf.ignore_environment_variables = 1;
+	conf.precedence_over_environment_variables = 1;
 	conf.n_not_launched_drivers = 1;
 	conf.not_launched_drivers = &d;
 	conf.ncpus = 1;

+ 15 - 4
tests/main/starpu_init.c

@@ -31,12 +31,11 @@ int main(void)
 }
 #else
 
-
-static int check_cpu(int env_cpu, int conf_cpu, int ignore_env, int expected_cpu, int *cpu)
+static int check_cpu(int env_cpu, int conf_cpu, int precedence_over_env, int expected_cpu, int *cpu)
 {
 	int ret;
 
-	FPRINTF(stderr, "\nTesting with env=%d - conf=%d - expected %d (ignore env %d)\n", env_cpu, conf_cpu, expected_cpu, ignore_env);
+	FPRINTF(stderr, "\nTesting with env=%d - conf=%d - expected %d (ignore env %d)\n", env_cpu, conf_cpu, expected_cpu, precedence_over_env);
 
 	if (env_cpu != -1)
 	{
@@ -47,7 +46,7 @@ static int check_cpu(int env_cpu, int conf_cpu, int ignore_env, int expected_cpu
 
 	struct starpu_conf user_conf;
 	starpu_conf_init(&user_conf);
-	user_conf.ignore_environment_variables = ignore_env;
+	user_conf.precedence_over_environment_variables = precedence_over_env;
 
 	if (conf_cpu != -1)
 	{
@@ -110,6 +109,7 @@ int main(void)
 	ret = check_cpu(cpu_test1, -1, 0, cpu_test1, &cpu);
 	if (ret) return ret;
 
+	// Do not set anything --> default value
 	ret = check_cpu(-1, -1, 0, -1, &cpu);
 	if (ret) return ret;
 	if (cpu != cpu_init)
@@ -118,15 +118,26 @@ int main(void)
 		return 1;
 	}
 
+	// Do not set environment variable, set starpu_conf::ncpus --> starpu_conf::ncpus
 	ret = check_cpu(-1, cpu_test2, 0, cpu_test2, &cpu);
 	if (ret) return ret;
 
+	// Set environment variable, and do not set starpu_conf::ncpus --> starpu_conf::ncpus
+	ret = check_cpu(cpu_test2, -1, 0, cpu_test2, &cpu);
+	if (ret) return ret;
+
+	// Set both environment variable and starpu_conf::ncpus --> environment variable
 	ret = check_cpu(cpu_test3, cpu_test1, 0, cpu_test3, &cpu);
 	if (ret) return ret;
 
+	// Set both environment variable and starpu_conf::ncpus AND prefer starpu_conf over env --> starpu_conf::ncpus
 	ret = check_cpu(cpu_test3, cpu_test1, 1, cpu_test1, &cpu);
 	if (ret) return ret;
 
+	// Set environment variable, and do no set starpu_conf, AND prefer starpu_conf over env --> environment variable
+	ret = check_cpu(cpu_test2, -1, 1, cpu_test2, &cpu);
+	if (ret) return ret;
+
 	return 0;
 }