Преглед на файлове

The starpu_conf_init function now only sets the different fields of the
configuration structure to default value in case there is no environment
variable that already define the different parameters. (eg. if STARPU_NCUDA=3,
the .ncuda field is set to 3 explicitely).

Cédric Augonnet преди 14 години
родител
ревизия
5a5d594f4e
променени са 2 файла, в които са добавени 19 реда и са изтрити 10 реда
  1. 6 1
      doc/starpu.texi
  2. 13 9
      src/core/workers.c

+ 6 - 1
doc/starpu.texi

@@ -2375,7 +2375,12 @@ variable when it is set.
 @subsection @code{starpu_conf_init} -- Initialize starpu_conf structure
 @table @asis
 
-This function initializes the @code{starpu_conf} structure passed as argument with the default values.
+This function initializes the @code{starpu_conf} structure passed as argument
+with the default values. In case some configuration parameters are already
+specified through environment variables, @code{starpu_conf_init} initializes
+the fields of the structure according to the environment variables. For
+instance if @code{STARPU_CALIBRATE} is set, its value is put in the
+@code{.ncuda} field of the structure passed as argument.
 
 @item @emph{Return value}:
 Upon successful completion, this function returns 0. Otherwise, @code{-EINVAL}

+ 13 - 9
src/core/workers.c

@@ -271,16 +271,20 @@ int starpu_conf_init(struct starpu_conf *conf)
 	if (!conf)
 		return -EINVAL;
 
-	conf->sched_policy_name = NULL;
+	conf->sched_policy_name = getenv("STARPU_SCHED");
 	conf->sched_policy = NULL;
-	conf->ncpus = -1;
-	conf->ncuda = -1;
-	conf->nopencl = -1;
-	conf->nspus = -1;
-	conf->use_explicit_workers_bindid = 0;
-	conf->use_explicit_workers_cuda_gpuid = 0;
-	conf->use_explicit_workers_opencl_gpuid = 0;
-	conf->calibrate = -1;
+
+	/* Note that starpu_get_env_number returns -1 in case the variable is
+	 * not defined */
+	conf->ncpus = starpu_get_env_number("STARPU_NCPUS");
+	conf->ncuda = starpu_get_env_number("STARPU_NCUDA");
+	conf->nopencl = starpu_get_env_number("STARPU_NOPENCL");
+	conf->nspus = starpu_get_env_number("STARPU_NGORDON");
+	conf->calibrate = starpu_get_env_number("STARPU_CALIBRATE");
+
+	conf->use_explicit_workers_bindid = 0; /* TODO */
+	conf->use_explicit_workers_cuda_gpuid = 0; /* TODO */
+	conf->use_explicit_workers_opencl_gpuid = 0; /* TODO */
 
 	return 0;
 };