|
@@ -662,7 +662,7 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
|
|
|
#if defined(STARPU_USE_CPU) || defined(STARPU_SIMGRID)
|
|
|
case STARPU_CPU_WORKER:
|
|
|
driver.id.cpu_id = workerarg->devid;
|
|
|
- if (_starpu_may_launch_driver(pconfig->conf, &driver))
|
|
|
+ if (_starpu_may_launch_driver(&pconfig->conf, &driver))
|
|
|
{
|
|
|
STARPU_PTHREAD_CREATE_ON(
|
|
|
workerarg->name,
|
|
@@ -714,7 +714,7 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
|
|
|
worker_set->workers = workerarg;
|
|
|
worker_set->set_is_initialized = 0;
|
|
|
|
|
|
- if (!_starpu_may_launch_driver(pconfig->conf, &driver))
|
|
|
+ if (!_starpu_may_launch_driver(&pconfig->conf, &driver))
|
|
|
{
|
|
|
workerarg->run_by_starpu = 0;
|
|
|
break;
|
|
@@ -746,7 +746,7 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
|
|
|
case STARPU_OPENCL_WORKER:
|
|
|
#ifndef STARPU_SIMGRID
|
|
|
starpu_opencl_get_device(workerarg->devid, &driver.id.opencl_id);
|
|
|
- if (!_starpu_may_launch_driver(pconfig->conf, &driver))
|
|
|
+ if (!_starpu_may_launch_driver(&pconfig->conf, &driver))
|
|
|
{
|
|
|
workerarg->run_by_starpu = 0;
|
|
|
break;
|
|
@@ -845,7 +845,7 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
|
|
|
{
|
|
|
case STARPU_CPU_WORKER:
|
|
|
driver.id.cpu_id = workerarg->devid;
|
|
|
- if (!_starpu_may_launch_driver(pconfig->conf, &driver))
|
|
|
+ if (!_starpu_may_launch_driver(&pconfig->conf, &driver))
|
|
|
break;
|
|
|
_STARPU_DEBUG("waiting for worker %u initialization\n", worker);
|
|
|
STARPU_PTHREAD_MUTEX_LOCK(&workerarg->mutex);
|
|
@@ -860,7 +860,7 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
|
|
|
case STARPU_OPENCL_WORKER:
|
|
|
#ifndef STARPU_SIMGRID
|
|
|
starpu_opencl_get_device(workerarg->devid, &driver.id.opencl_id);
|
|
|
- if (!_starpu_may_launch_driver(pconfig->conf, &driver))
|
|
|
+ if (!_starpu_may_launch_driver(&pconfig->conf, &driver))
|
|
|
break;
|
|
|
#endif
|
|
|
_STARPU_DEBUG("waiting for worker %u initialization\n", worker);
|
|
@@ -1180,24 +1180,37 @@ int starpu_initialize(struct starpu_conf *user_conf, int *argc, char ***argv)
|
|
|
/* store the pointer to the user explicit configuration during the
|
|
|
* initialization */
|
|
|
if (user_conf == NULL)
|
|
|
+ starpu_conf_init(&config.conf);
|
|
|
+ else
|
|
|
{
|
|
|
- struct starpu_conf *conf = malloc(sizeof(struct starpu_conf));
|
|
|
- starpu_conf_init(conf);
|
|
|
- config.conf = conf;
|
|
|
- config.default_conf = 1;
|
|
|
+ if (user_conf->magic != 42)
|
|
|
+ {
|
|
|
+ _STARPU_DISP("starpu_conf structure needs to be initialized with starpu_conf_init\n");
|
|
|
+ return -EINVAL;
|
|
|
+ }
|
|
|
+ config.conf = *user_conf;
|
|
|
}
|
|
|
- else
|
|
|
+ /* Make a copy of arrays */
|
|
|
+ if (config.conf.sched_policy_name)
|
|
|
+ config.conf.sched_policy_name = strdup(config.conf.sched_policy_name);
|
|
|
+ if (config.conf.mic_sink_program_path)
|
|
|
+ config.conf.mic_sink_program_path = strdup(config.conf.mic_sink_program_path);
|
|
|
+ if (config.conf.n_cuda_opengl_interoperability)
|
|
|
{
|
|
|
- if (user_conf->magic != 42)
|
|
|
- {
|
|
|
- _STARPU_DISP("starpu_conf structure needs to be initialized with starpu_conf_init\n");
|
|
|
- return -EINVAL;
|
|
|
- }
|
|
|
- config.conf = user_conf;
|
|
|
- config.default_conf = 0;
|
|
|
+ size_t size = config.conf.n_cuda_opengl_interoperability * sizeof(*config.conf.cuda_opengl_interoperability);
|
|
|
+ unsigned *copy = malloc(size);
|
|
|
+ memcpy(copy, config.conf.cuda_opengl_interoperability, size);
|
|
|
+ config.conf.cuda_opengl_interoperability = copy;
|
|
|
+ }
|
|
|
+ if (config.conf.n_not_launched_drivers)
|
|
|
+ {
|
|
|
+ size_t size = config.conf.n_not_launched_drivers * sizeof(*config.conf.not_launched_drivers);
|
|
|
+ struct starpu_driver *copy = malloc(size);
|
|
|
+ memcpy(copy, config.conf.not_launched_drivers, size);
|
|
|
+ config.conf.not_launched_drivers = copy;
|
|
|
}
|
|
|
|
|
|
- _starpu_conf_check_environment(config.conf);
|
|
|
+ _starpu_conf_check_environment(&config.conf);
|
|
|
|
|
|
_starpu_init_all_sched_ctxs(&config);
|
|
|
_starpu_init_progression_hooks();
|
|
@@ -1205,7 +1218,7 @@ int starpu_initialize(struct starpu_conf *user_conf, int *argc, char ***argv)
|
|
|
_starpu_init_tags();
|
|
|
|
|
|
#ifdef STARPU_USE_FXT
|
|
|
- _starpu_fxt_init_profiling(config.conf->trace_buffer_size);
|
|
|
+ _starpu_fxt_init_profiling(config.conf.trace_buffer_size);
|
|
|
#endif
|
|
|
|
|
|
_starpu_open_debug_logfile();
|
|
@@ -1254,8 +1267,8 @@ int starpu_initialize(struct starpu_conf *user_conf, int *argc, char ***argv)
|
|
|
|
|
|
if (!is_a_sink)
|
|
|
{
|
|
|
- struct starpu_sched_policy *selected_policy = _starpu_select_sched_policy(&config, config.conf->sched_policy_name);
|
|
|
- _starpu_create_sched_ctx(selected_policy, NULL, -1, 1, "init", (config.conf->global_sched_ctx_min_priority != -1), config.conf->global_sched_ctx_min_priority, (config.conf->global_sched_ctx_min_priority != -1), config.conf->global_sched_ctx_max_priority, 1, config.conf->sched_policy_init);
|
|
|
+ struct starpu_sched_policy *selected_policy = _starpu_select_sched_policy(&config, config.conf.sched_policy_name);
|
|
|
+ _starpu_create_sched_ctx(selected_policy, NULL, -1, 1, "init", (config.conf.global_sched_ctx_min_priority != -1), config.conf.global_sched_ctx_min_priority, (config.conf.global_sched_ctx_min_priority != -1), config.conf.global_sched_ctx_max_priority, 1, config.conf.sched_policy_init);
|
|
|
}
|
|
|
|
|
|
_starpu_initialize_registered_performance_models();
|
|
@@ -1436,7 +1449,7 @@ unsigned _starpu_worker_can_block(unsigned memnode STARPU_ATTRIBUTE_UNUSED, stru
|
|
|
default:
|
|
|
goto always_launch;
|
|
|
}
|
|
|
- if (!_starpu_may_launch_driver(config.conf, &driver))
|
|
|
+ if (!_starpu_may_launch_driver(&config.conf, &driver))
|
|
|
return 0;
|
|
|
|
|
|
always_launch:
|
|
@@ -1560,9 +1573,13 @@ void starpu_shutdown(void)
|
|
|
STARPU_PTHREAD_COND_SIGNAL(&init_cond);
|
|
|
STARPU_PTHREAD_MUTEX_UNLOCK(&init_mutex);
|
|
|
|
|
|
- /* Clear memory if it was allocated by StarPU */
|
|
|
- if (config.default_conf)
|
|
|
- free(config.conf);
|
|
|
+ /* Clear memory */
|
|
|
+ free((char*) config.conf.sched_policy_name);
|
|
|
+ free(config.conf.mic_sink_program_path);
|
|
|
+ if (config.conf.n_cuda_opengl_interoperability)
|
|
|
+ free(config.conf.cuda_opengl_interoperability);
|
|
|
+ if (config.conf.n_not_launched_drivers)
|
|
|
+ free(config.conf.not_launched_drivers);
|
|
|
|
|
|
#ifdef HAVE_AYUDAME_H
|
|
|
if (AYU_event) AYU_event(AYU_FINISH, 0, NULL);
|
|
@@ -1638,22 +1655,22 @@ unsigned starpu_opencl_worker_get_count(void)
|
|
|
|
|
|
int starpu_asynchronous_copy_disabled(void)
|
|
|
{
|
|
|
- return config.conf->disable_asynchronous_copy;
|
|
|
+ return config.conf.disable_asynchronous_copy;
|
|
|
}
|
|
|
|
|
|
int starpu_asynchronous_cuda_copy_disabled(void)
|
|
|
{
|
|
|
- return config.conf->disable_asynchronous_cuda_copy;
|
|
|
+ return config.conf.disable_asynchronous_cuda_copy;
|
|
|
}
|
|
|
|
|
|
int starpu_asynchronous_opencl_copy_disabled(void)
|
|
|
{
|
|
|
- return config.conf->disable_asynchronous_opencl_copy;
|
|
|
+ return config.conf.disable_asynchronous_opencl_copy;
|
|
|
}
|
|
|
|
|
|
int starpu_asynchronous_mic_copy_disabled(void)
|
|
|
{
|
|
|
- return config.conf->disable_asynchronous_mic_copy;
|
|
|
+ return config.conf.disable_asynchronous_mic_copy;
|
|
|
}
|
|
|
|
|
|
unsigned starpu_mic_worker_get_count(void)
|