Sfoglia il codice sorgente

Replace starpu_force_bus_sampling with bus_calibrate configuration option, as calibration should done carefully during starpu initialization, and not after initialization

Samuel Thibault 13 anni fa
parent
commit
f30a1170aa

+ 6 - 5
doc/chapters/basic-api.texi

@@ -129,6 +129,11 @@ calibration. If the value is equal to @code{2}, the existing performance
 models will be overwritten. This can also be specified with the
 @code{STARPU_CALIBRATE} environment variable.
 
+@item @code{int bus_calibrate} (default = 0)
+If this flag is set, StarPU will recalibrate the bus.  If this value is equal
+to @code{-1}, the default value is used.  This can also be specified with the
+@code{STARPU_BUS_CALIBRATE} environment variable.
+
 @item @code{int single_combined_worker} (default = 0)
 By default, StarPU executes parallel tasks concurrently.
 Some parallel libraries (e.g. most OpenMP implementations) however do
@@ -168,7 +173,7 @@ 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.
+@code{.calibrate} field of the structure passed as argument.
 
 Upon successful completion, this function returns 0. Otherwise, @code{-EINVAL}
 indicates that the argument was NULL.
@@ -1965,10 +1970,6 @@ returns the path to the debugging information for the performance model.
 returns the architecture name for @var{arch}.
 @end deftypefun
 
-@deftypefun void starpu_force_bus_sampling (void)
-forces sampling the bus performance model again.
-@end deftypefun
-
 @deftypefun {enum starpu_perf_archtype} starpu_worker_get_perf_archtype (int @var{workerid})
 returns the architecture type of a given worker.
 @end deftypefun

+ 6 - 0
doc/chapters/configuration.texi

@@ -343,6 +343,7 @@ Let the user give a hint to StarPU about which how many workers
 @menu
 * STARPU_SCHED::                Scheduling policy
 * STARPU_CALIBRATE::            Calibrate performance models
+* STARPU_BUS_CALIBRATE::        Calibrate bus
 * STARPU_PREFETCH::             Use data prefetch
 * STARPU_SCHED_ALPHA::          Computation factor
 * STARPU_SCHED_BETA::           Communication factor
@@ -366,6 +367,11 @@ is the default behaviour.
 
 Note: this currently only applies to @code{dm}, @code{dmda} and @code{heft} scheduling policies.
 
+@node STARPU_BUS_CALIBRATE
+@subsubsection @code{STARPU_BUS_CALIBRATE} -- Calibrate bus
+
+If this variable is set to 1, the bus is recalibrated during intialization.
+
 @node STARPU_PREFETCH
 @subsubsection @code{STARPU_PREFETCH} -- Use data prefetch
 

+ 3 - 0
include/starpu.h

@@ -113,6 +113,9 @@ struct starpu_conf
 	unsigned use_explicit_workers_opencl_gpuid;
 	unsigned workers_opencl_gpuid[STARPU_NMAXWORKERS];
 
+	/* calibrate bus (-1 for default) */
+	int bus_calibrate;
+
 	/* calibrate performance models, if any (-1 for default) */
 	int calibrate;
 

+ 0 - 1
include/starpu_perfmodel.h

@@ -211,7 +211,6 @@ int starpu_list_models(FILE *output);
 
 void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *, enum starpu_perf_archtype arch, unsigned cpuid, unsigned nimpl, double measured);
 
-void starpu_force_bus_sampling(void);
 void starpu_bus_print_bandwidth(FILE *f);
 void starpu_bus_print_affinity(FILE *f);
 

+ 9 - 5
src/core/perfmodel/perfmodel_bus.c

@@ -46,6 +46,8 @@
 
 #define MAXCPUS	32
 
+static void starpu_force_bus_sampling(void);
+
 /* timing is in µs per byte (i.e. slowness, inverse of bandwidth) */
 struct dev_timing
 {
@@ -1169,21 +1171,23 @@ static void check_bus_config_file()
 {
         int res;
         char path[256];
+        struct _starpu_machine_config *config = _starpu_get_machine_config();
 
         get_config_path(path, 256);
         res = access(path, F_OK);
-        if (res)
+	if (res || config->conf->bus_calibrate > 0)
 	{
-		_STARPU_DISP("No performance model for the bus, calibrating...\n");
+		if (res)
+			_STARPU_DISP("No performance model for the bus, calibrating...\n");
 		starpu_force_bus_sampling();
-		_STARPU_DISP("... done\n");
+		if (res)
+			_STARPU_DISP("... done\n");
         }
         else
 	{
                 FILE *f;
                 int ret, read_cuda = -1, read_opencl = -1;
                 unsigned read_cpus = -1;
-                struct _starpu_machine_config *config = _starpu_get_machine_config();
 
                 // Loading configuration from file
                 f = fopen(path, "r");
@@ -1261,7 +1265,7 @@ static void generate_bus_config_file()
  *	Generic
  */
 
-void starpu_force_bus_sampling(void)
+static void starpu_force_bus_sampling(void)
 {
 	_starpu_create_sampling_directory_if_needed();
 

+ 5 - 0
src/core/workers.c

@@ -473,10 +473,14 @@ int starpu_conf_init(struct starpu_conf *conf)
 	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->bus_calibrate = starpu_get_env_number("STARPU_BUS_CALIBRATE");
 
 	if (conf->calibrate == -1)
 	     conf->calibrate = 0;
 
+	if (conf->bus_calibrate == -1)
+	     conf->bus_calibrate = 0;
+
 	conf->use_explicit_workers_bindid = 0; /* TODO */
 	conf->use_explicit_workers_cuda_gpuid = 0; /* TODO */
 	conf->use_explicit_workers_opencl_gpuid = 0; /* TODO */
@@ -516,6 +520,7 @@ static void _starpu_conf_check_environment(struct starpu_conf *conf)
 	_starpu_conf_set_value_against_environment("STARPU_NOPENCL", &conf->nopencl);
 	_starpu_conf_set_value_against_environment("STARPU_NGORDON", &conf->nspus);
 	_starpu_conf_set_value_against_environment("STARPU_CALIBRATE", &conf->calibrate);
+	_starpu_conf_set_value_against_environment("STARPU_BUS_CALIBRATE", &conf->bus_calibrate);
 	_starpu_conf_set_value_against_environment("STARPU_SINGLE_COMBINED_WORKER", &conf->single_combined_worker);
 	_starpu_conf_set_value_against_environment("STARPU_DISABLE_ASYNCHRONOUS_COPY", &conf->disable_asynchronous_copy);
 }

+ 5 - 6
tools/starpu_calibrate_bus.c

@@ -71,16 +71,15 @@ static void parse_args(int argc, char **argv)
 
 int main(int argc, char **argv)
 {
-#ifdef __MINGW32__
-	WSADATA wsadata;
-	WSAStartup(MAKEWORD(1,0), &wsadata);
-#endif
+	struct starpu_conf conf;
 
 	parse_args(argc, argv);
 
-	/* Note: do not initialize StarPU, to avoid perturbing measurements.  */
+	starpu_conf_init(&conf);
+	conf.bus_calibrate = 1;
 
-	starpu_force_bus_sampling();
+	starpu_init(&conf);
+	starpu_shutdown();
 
 	return 0;
 }

+ 7 - 7
tools/starpu_machine_display.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2011  Université de Bordeaux 1
+ * Copyright (C) 2011-2012  Université de Bordeaux 1
  *
  * 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
@@ -119,17 +119,17 @@ PROGNAME);
 int main(int argc, char **argv)
 {
 	int force = 0;
+	struct starpu_conf conf;
 
 	parse_args(argc, argv, &force);
 
+	starpu_conf_init(&conf);
+	if (force)
+		conf.bus_calibrate = 1;
+
 	/* Even if starpu_init returns -ENODEV, we should go on : we will just
 	 * print that we found no device. */
-	(void) starpu_init(NULL);
-
-	if (force)
-	{
-		starpu_force_bus_sampling();
-	}
+	(void) starpu_init(&conf);
 
 	unsigned ncpu = starpu_cpu_worker_get_count();
 	unsigned ncuda = starpu_cuda_worker_get_count();