|
@@ -383,7 +383,68 @@ static unsigned _starpu_may_launch_driver(struct starpu_conf *conf,
|
|
struct itimerval prof_itimer;
|
|
struct itimerval prof_itimer;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-void _starpu_worker_init(struct _starpu_worker *worker, unsigned fut_key)
|
|
|
|
|
|
+static void _starpu_worker_init(struct _starpu_worker *workerarg, struct _starpu_machine_config *pconfig)
|
|
|
|
+{
|
|
|
|
+ workerarg->config = pconfig;
|
|
|
|
+ STARPU_PTHREAD_MUTEX_INIT(&workerarg->mutex, NULL);
|
|
|
|
+ /* arch initialized by topology.c */
|
|
|
|
+ /* worker_mask initialized by topology.c */
|
|
|
|
+ /* perf_arch initialized by topology.c */
|
|
|
|
+ /* worker_thread initialized by _starpu_launch_drivers */
|
|
|
|
+ /* mp_nodeid initialized by topology.c */
|
|
|
|
+ /* devid initialized by topology.c */
|
|
|
|
+ /* bindid initialized by topology.c */
|
|
|
|
+ /* workerid initialized by topology.c */
|
|
|
|
+ workerarg->combined_workerid = workerarg->workerid;
|
|
|
|
+ workerarg->current_rank = 0;
|
|
|
|
+ workerarg->worker_size = 1;
|
|
|
|
+ STARPU_PTHREAD_COND_INIT(&workerarg->started_cond, NULL);
|
|
|
|
+ STARPU_PTHREAD_COND_INIT(&workerarg->ready_cond, NULL);
|
|
|
|
+ /* memory_node initialized by topology.c */
|
|
|
|
+ STARPU_PTHREAD_COND_INIT(&workerarg->sched_cond, NULL);
|
|
|
|
+ STARPU_PTHREAD_MUTEX_INIT(&workerarg->sched_mutex, NULL);
|
|
|
|
+ starpu_task_list_init(&workerarg->local_tasks);
|
|
|
|
+ workerarg->current_task = NULL;
|
|
|
|
+ workerarg->set = NULL;
|
|
|
|
+
|
|
|
|
+ /* if some codelet's termination cannot be handled directly :
|
|
|
|
+ * for instance in the Gordon driver, Gordon tasks' callbacks
|
|
|
|
+ * may be executed by another thread than that of the Gordon
|
|
|
|
+ * driver so that we cannot call the push_codelet_output method
|
|
|
|
+ * directly */
|
|
|
|
+ workerarg->terminated_jobs = _starpu_job_list_new();
|
|
|
|
+
|
|
|
|
+ workerarg->worker_is_running = 0;
|
|
|
|
+ workerarg->worker_is_initialized = 0;
|
|
|
|
+ workerarg->status = STATUS_INITIALIZING;
|
|
|
|
+ /* name initialized by driver */
|
|
|
|
+ /* short_name initialized by driver */
|
|
|
|
+ workerarg->run_by_starpu = 1;
|
|
|
|
+
|
|
|
|
+ workerarg->sched_ctx_list = NULL;
|
|
|
|
+ workerarg->nsched_ctxs = 0;
|
|
|
|
+ _starpu_barrier_counter_init(&workerarg->tasks_barrier, 0);
|
|
|
|
+
|
|
|
|
+ workerarg->has_prev_init = 0;
|
|
|
|
+
|
|
|
|
+ int ctx;
|
|
|
|
+ for(ctx = 0; ctx < STARPU_NMAX_SCHED_CTXS; ctx++)
|
|
|
|
+ workerarg->removed_from_ctx[ctx] = 0;
|
|
|
|
+
|
|
|
|
+ workerarg->spinning_backoff = 1;
|
|
|
|
+
|
|
|
|
+ STARPU_PTHREAD_COND_INIT(&workerarg->parallel_sect_cond, NULL);
|
|
|
|
+ STARPU_PTHREAD_MUTEX_INIT(&workerarg->parallel_sect_mutex, NULL);
|
|
|
|
+
|
|
|
|
+ workerarg->parallel_sect = 0;
|
|
|
|
+
|
|
|
|
+ for(ctx = 0; ctx < STARPU_NMAX_SCHED_CTXS; ctx++)
|
|
|
|
+ workerarg->shares_tasks_lists[ctx] = 0;
|
|
|
|
+
|
|
|
|
+ /* cpu_set/hwloc_cpu_set initialized in topology.c */
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void _starpu_worker_start(struct _starpu_worker *worker, unsigned fut_key)
|
|
{
|
|
{
|
|
(void) fut_key;
|
|
(void) fut_key;
|
|
int devid = worker->devid;
|
|
int devid = worker->devid;
|
|
@@ -445,64 +506,6 @@ static void _starpu_launch_drivers(struct _starpu_machine_config *pconfig)
|
|
unsigned mp_nodeid = workerarg->mp_nodeid;
|
|
unsigned mp_nodeid = workerarg->mp_nodeid;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
- workerarg->config = pconfig;
|
|
|
|
- STARPU_PTHREAD_MUTEX_INIT(&workerarg->mutex, NULL);
|
|
|
|
- /* arch initialized by topology.c */
|
|
|
|
- /* worker_mask initialized by topology.c */
|
|
|
|
- /* perf_arch initialized by topology.c */
|
|
|
|
- /* worker_thread initialized below */
|
|
|
|
- /* mp_nodeid initialized by topology.c */
|
|
|
|
- /* devid initialized by topology.c */
|
|
|
|
- /* bindid initialized by topology.c */
|
|
|
|
- /* workerid initialized by topology.c */
|
|
|
|
- workerarg->combined_workerid = workerarg->workerid;
|
|
|
|
- workerarg->current_rank = 0;
|
|
|
|
- workerarg->worker_size = 1;
|
|
|
|
- STARPU_PTHREAD_COND_INIT(&workerarg->started_cond, NULL);
|
|
|
|
- STARPU_PTHREAD_COND_INIT(&workerarg->ready_cond, NULL);
|
|
|
|
- /* memory_node initialized by topology.c */
|
|
|
|
- STARPU_PTHREAD_COND_INIT(&workerarg->sched_cond, NULL);
|
|
|
|
- STARPU_PTHREAD_MUTEX_INIT(&workerarg->sched_mutex, NULL);
|
|
|
|
- starpu_task_list_init(&workerarg->local_tasks);
|
|
|
|
- workerarg->current_task = NULL;
|
|
|
|
- workerarg->set = NULL;
|
|
|
|
-
|
|
|
|
- /* if some codelet's termination cannot be handled directly :
|
|
|
|
- * for instance in the Gordon driver, Gordon tasks' callbacks
|
|
|
|
- * may be executed by another thread than that of the Gordon
|
|
|
|
- * driver so that we cannot call the push_codelet_output method
|
|
|
|
- * directly */
|
|
|
|
- workerarg->terminated_jobs = _starpu_job_list_new();
|
|
|
|
-
|
|
|
|
- workerarg->worker_is_running = 0;
|
|
|
|
- workerarg->worker_is_initialized = 0;
|
|
|
|
- workerarg->status = STATUS_INITIALIZING;
|
|
|
|
- /* name initialized by driver */
|
|
|
|
- /* short_name initialized by driver */
|
|
|
|
- workerarg->run_by_starpu = 1;
|
|
|
|
-
|
|
|
|
- workerarg->sched_ctx_list = NULL;
|
|
|
|
- workerarg->nsched_ctxs = 0;
|
|
|
|
- _starpu_barrier_counter_init(&workerarg->tasks_barrier, 0);
|
|
|
|
-
|
|
|
|
- workerarg->has_prev_init = 0;
|
|
|
|
-
|
|
|
|
- int ctx;
|
|
|
|
- for(ctx = 0; ctx < STARPU_NMAX_SCHED_CTXS; ctx++)
|
|
|
|
- workerarg->removed_from_ctx[ctx] = 0;
|
|
|
|
-
|
|
|
|
- workerarg->spinning_backoff = 1;
|
|
|
|
-
|
|
|
|
- STARPU_PTHREAD_COND_INIT(&workerarg->parallel_sect_cond, NULL);
|
|
|
|
- STARPU_PTHREAD_MUTEX_INIT(&workerarg->parallel_sect_mutex, NULL);
|
|
|
|
-
|
|
|
|
- workerarg->parallel_sect = 0;
|
|
|
|
-
|
|
|
|
- for(ctx = 0; ctx < STARPU_NMAX_SCHED_CTXS; ctx++)
|
|
|
|
- workerarg->shares_tasks_lists[ctx] = 0;
|
|
|
|
-
|
|
|
|
- /* cpu_set/hwloc_cpu_set initialized in topology.c */
|
|
|
|
-
|
|
|
|
_STARPU_DEBUG("initialising worker %u/%u\n", worker, nworkers);
|
|
_STARPU_DEBUG("initialising worker %u/%u\n", worker, nworkers);
|
|
|
|
|
|
_starpu_init_worker_queue(workerarg);
|
|
_starpu_init_worker_queue(workerarg);
|
|
@@ -869,6 +872,7 @@ int starpu_initialize(struct starpu_conf *user_conf, int *argc, char ***argv)
|
|
{
|
|
{
|
|
int is_a_sink = 0; /* Always defined. If the MP infrastructure is not
|
|
int is_a_sink = 0; /* Always defined. If the MP infrastructure is not
|
|
* used, we cannot be a sink. */
|
|
* used, we cannot be a sink. */
|
|
|
|
+ unsigned worker;
|
|
#ifdef STARPU_USE_MP
|
|
#ifdef STARPU_USE_MP
|
|
_starpu_set_argc_argv(argc, argv);
|
|
_starpu_set_argc_argv(argc, argv);
|
|
|
|
|
|
@@ -1020,6 +1024,9 @@ int starpu_initialize(struct starpu_conf *user_conf, int *argc, char ***argv)
|
|
* threads */
|
|
* threads */
|
|
_starpu_initialize_current_task_key();
|
|
_starpu_initialize_current_task_key();
|
|
|
|
|
|
|
|
+ for (worker = 0; worker < config.topology.nworkers; worker++)
|
|
|
|
+ _starpu_worker_init(&config.workers[worker], &config);
|
|
|
|
+
|
|
if (!is_a_sink)
|
|
if (!is_a_sink)
|
|
{
|
|
{
|
|
struct starpu_sched_policy *selected_policy = _starpu_select_sched_policy(&config, config.conf->sched_policy_name);
|
|
struct starpu_sched_policy *selected_policy = _starpu_select_sched_policy(&config, config.conf->sched_policy_name);
|