|
@@ -19,7 +19,7 @@
|
|
|
* See the GNU Lesser General Public License in COPYING.LGPL for more details.
|
|
|
*/
|
|
|
|
|
|
-#include <starpu_sched_node.h>
|
|
|
+#include <starpu_sched_component.h>
|
|
|
#include <core/workers.h>
|
|
|
|
|
|
#include <float.h>
|
|
@@ -71,7 +71,7 @@ struct _starpu_task_grid
|
|
|
* all the others use the pntasks that point to it
|
|
|
*
|
|
|
* when the counter reach 0, all the left and right member are set to NULL,
|
|
|
- * that mean that we will free that nodes.
|
|
|
+ * that mean that we will free that components.
|
|
|
*/
|
|
|
union
|
|
|
{
|
|
@@ -82,7 +82,7 @@ struct _starpu_task_grid
|
|
|
|
|
|
|
|
|
/* list->exp_start, list->exp_len, list-exp_end and list->ntasks
|
|
|
- * are updated by starpu_sched_node_worker_push_task(node, task) and pre_exec_hook
|
|
|
+ * are updated by starpu_sched_component_worker_push_task(component, task) and pre_exec_hook
|
|
|
*/
|
|
|
struct _starpu_worker_task_list
|
|
|
{
|
|
@@ -92,14 +92,14 @@ struct _starpu_worker_task_list
|
|
|
starpu_pthread_mutex_t mutex;
|
|
|
};
|
|
|
|
|
|
-enum _starpu_worker_node_status
|
|
|
+enum _starpu_worker_component_status
|
|
|
{
|
|
|
- NODE_STATUS_SLEEPING,
|
|
|
- NODE_STATUS_RESET,
|
|
|
- NODE_STATUS_CHANGED
|
|
|
+ COMPONENT_STATUS_SLEEPING,
|
|
|
+ COMPONENT_STATUS_RESET,
|
|
|
+ COMPONENT_STATUS_CHANGED
|
|
|
};
|
|
|
|
|
|
-struct _starpu_worker_node_data
|
|
|
+struct _starpu_worker_component_data
|
|
|
{
|
|
|
union
|
|
|
{
|
|
@@ -111,11 +111,11 @@ struct _starpu_worker_node_data
|
|
|
struct _starpu_combined_worker * combined_worker;
|
|
|
};
|
|
|
struct _starpu_worker_task_list * list;
|
|
|
- enum _starpu_worker_node_status status;
|
|
|
+ enum _starpu_worker_component_status status;
|
|
|
};
|
|
|
|
|
|
-/* this array store worker nodes */
|
|
|
-static struct starpu_sched_node * _worker_nodes[STARPU_NMAXWORKERS];
|
|
|
+/* this array store worker components */
|
|
|
+static struct starpu_sched_component * _worker_components[STARPU_NMAXWORKERS];
|
|
|
|
|
|
|
|
|
static struct _starpu_worker_task_list * _starpu_worker_task_list_create(void)
|
|
@@ -274,135 +274,135 @@ static inline struct starpu_task * _starpu_worker_task_list_pop(struct _starpu_w
|
|
|
|
|
|
|
|
|
|
|
|
-static struct starpu_sched_node * starpu_sched_node_worker_create(int workerid);
|
|
|
-static struct starpu_sched_node * starpu_sched_node_combined_worker_create(int workerid);
|
|
|
-struct starpu_sched_node * starpu_sched_node_worker_get(int workerid)
|
|
|
+static struct starpu_sched_component * starpu_sched_component_worker_create(int workerid);
|
|
|
+static struct starpu_sched_component * starpu_sched_component_combined_worker_create(int workerid);
|
|
|
+struct starpu_sched_component * starpu_sched_component_worker_get(int workerid)
|
|
|
{
|
|
|
STARPU_ASSERT(workerid >= 0 && workerid < STARPU_NMAXWORKERS);
|
|
|
/* we may need to take a mutex here */
|
|
|
- if(_worker_nodes[workerid])
|
|
|
- return _worker_nodes[workerid];
|
|
|
+ if(_worker_components[workerid])
|
|
|
+ return _worker_components[workerid];
|
|
|
else
|
|
|
{
|
|
|
- struct starpu_sched_node * node;
|
|
|
+ struct starpu_sched_component * component;
|
|
|
if(workerid < (int) starpu_worker_get_count())
|
|
|
- node = starpu_sched_node_worker_create(workerid);
|
|
|
+ component = starpu_sched_component_worker_create(workerid);
|
|
|
else
|
|
|
- node = starpu_sched_node_combined_worker_create(workerid);
|
|
|
- _worker_nodes[workerid] = node;
|
|
|
- return node;
|
|
|
+ component = starpu_sched_component_combined_worker_create(workerid);
|
|
|
+ _worker_components[workerid] = component;
|
|
|
+ return component;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-struct _starpu_worker * _starpu_sched_node_worker_get_worker(struct starpu_sched_node * worker_node)
|
|
|
+struct _starpu_worker * _starpu_sched_component_worker_get_worker(struct starpu_sched_component * worker_component)
|
|
|
{
|
|
|
- STARPU_ASSERT(starpu_sched_node_is_simple_worker(worker_node));
|
|
|
- struct _starpu_worker_node_data * data = worker_node->data;
|
|
|
+ STARPU_ASSERT(starpu_sched_component_is_simple_worker(worker_component));
|
|
|
+ struct _starpu_worker_component_data * data = worker_component->data;
|
|
|
return data->worker;
|
|
|
}
|
|
|
-struct _starpu_combined_worker * _starpu_sched_node_combined_worker_get_combined_worker(struct starpu_sched_node * worker_node)
|
|
|
+struct _starpu_combined_worker * _starpu_sched_component_combined_worker_get_combined_worker(struct starpu_sched_component * worker_component)
|
|
|
{
|
|
|
- STARPU_ASSERT(starpu_sched_node_is_combined_worker(worker_node));
|
|
|
- struct _starpu_worker_node_data * data = worker_node->data;
|
|
|
+ STARPU_ASSERT(starpu_sched_component_is_combined_worker(worker_component));
|
|
|
+ struct _starpu_worker_component_data * data = worker_component->data;
|
|
|
return data->combined_worker;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
-enum starpu_perfmodel_archtype starpu_sched_node_worker_get_perf_arch(struct starpu_sched_node * worker_node)
|
|
|
+enum starpu_perfmodel_archtype starpu_sched_component_worker_get_perf_arch(struct starpu_sched_component * worker_component)
|
|
|
{
|
|
|
- STARPU_ASSERT(starpu_sched_node_is_worker(worker_node));
|
|
|
- if(starpu_sched_node_is_simple_worker(worker_node))
|
|
|
- return _starpu_sched_node_worker_get_worker(worker_node)->perf_arch;
|
|
|
+ STARPU_ASSERT(starpu_sched_component_is_worker(worker_component));
|
|
|
+ if(starpu_sched_component_is_simple_worker(worker_component))
|
|
|
+ return _starpu_sched_component_worker_get_worker(worker_component)->perf_arch;
|
|
|
else
|
|
|
- return _starpu_sched_node_combined_worker_get_combined_worker(worker_node)->perf_arch;
|
|
|
+ return _starpu_sched_component_combined_worker_get_combined_worker(worker_component)->perf_arch;
|
|
|
}
|
|
|
*/
|
|
|
|
|
|
-static void _starpu_sched_node_worker_set_sleep_status(struct starpu_sched_node * worker_node)
|
|
|
+static void _starpu_sched_component_worker_set_sleep_status(struct starpu_sched_component * worker_component)
|
|
|
{
|
|
|
- STARPU_ASSERT(starpu_sched_node_is_worker(worker_node));
|
|
|
- struct _starpu_worker_node_data * data = worker_node->data;
|
|
|
- data->status = NODE_STATUS_SLEEPING;
|
|
|
+ STARPU_ASSERT(starpu_sched_component_is_worker(worker_component));
|
|
|
+ struct _starpu_worker_component_data * data = worker_component->data;
|
|
|
+ data->status = COMPONENT_STATUS_SLEEPING;
|
|
|
}
|
|
|
|
|
|
-static void _starpu_sched_node_worker_set_changed_status(struct starpu_sched_node * worker_node)
|
|
|
+static void _starpu_sched_component_worker_set_changed_status(struct starpu_sched_component * worker_component)
|
|
|
{
|
|
|
- STARPU_ASSERT(starpu_sched_node_is_worker(worker_node));
|
|
|
- struct _starpu_worker_node_data * data = worker_node->data;
|
|
|
- data->status = NODE_STATUS_CHANGED;
|
|
|
+ STARPU_ASSERT(starpu_sched_component_is_worker(worker_component));
|
|
|
+ struct _starpu_worker_component_data * data = worker_component->data;
|
|
|
+ data->status = COMPONENT_STATUS_CHANGED;
|
|
|
}
|
|
|
|
|
|
-static void _starpu_sched_node_worker_reset_status(struct starpu_sched_node * worker_node)
|
|
|
+static void _starpu_sched_component_worker_reset_status(struct starpu_sched_component * worker_component)
|
|
|
{
|
|
|
- STARPU_ASSERT(starpu_sched_node_is_worker(worker_node));
|
|
|
- struct _starpu_worker_node_data * data = worker_node->data;
|
|
|
- data->status = NODE_STATUS_RESET;
|
|
|
+ STARPU_ASSERT(starpu_sched_component_is_worker(worker_component));
|
|
|
+ struct _starpu_worker_component_data * data = worker_component->data;
|
|
|
+ data->status = COMPONENT_STATUS_RESET;
|
|
|
}
|
|
|
|
|
|
-static int _starpu_sched_node_worker_is_reset_status(struct starpu_sched_node * worker_node)
|
|
|
+static int _starpu_sched_component_worker_is_reset_status(struct starpu_sched_component * worker_component)
|
|
|
{
|
|
|
- STARPU_ASSERT(starpu_sched_node_is_worker(worker_node));
|
|
|
- struct _starpu_worker_node_data * data = worker_node->data;
|
|
|
- return (data->status == NODE_STATUS_RESET);
|
|
|
+ STARPU_ASSERT(starpu_sched_component_is_worker(worker_component));
|
|
|
+ struct _starpu_worker_component_data * data = worker_component->data;
|
|
|
+ return (data->status == COMPONENT_STATUS_RESET);
|
|
|
}
|
|
|
|
|
|
-static int _starpu_sched_node_worker_is_changed_status(struct starpu_sched_node * worker_node)
|
|
|
+static int _starpu_sched_component_worker_is_changed_status(struct starpu_sched_component * worker_component)
|
|
|
{
|
|
|
- STARPU_ASSERT(starpu_sched_node_is_worker(worker_node));
|
|
|
- struct _starpu_worker_node_data * data = worker_node->data;
|
|
|
- return (data->status == NODE_STATUS_CHANGED);
|
|
|
+ STARPU_ASSERT(starpu_sched_component_is_worker(worker_component));
|
|
|
+ struct _starpu_worker_component_data * data = worker_component->data;
|
|
|
+ return (data->status == COMPONENT_STATUS_CHANGED);
|
|
|
}
|
|
|
|
|
|
-static int _starpu_sched_node_worker_is_sleeping_status(struct starpu_sched_node * worker_node)
|
|
|
+static int _starpu_sched_component_worker_is_sleeping_status(struct starpu_sched_component * worker_component)
|
|
|
{
|
|
|
- STARPU_ASSERT(starpu_sched_node_is_worker(worker_node));
|
|
|
- struct _starpu_worker_node_data * data = worker_node->data;
|
|
|
- return (data->status == NODE_STATUS_SLEEPING);
|
|
|
+ STARPU_ASSERT(starpu_sched_component_is_worker(worker_component));
|
|
|
+ struct _starpu_worker_component_data * data = worker_component->data;
|
|
|
+ return (data->status == COMPONENT_STATUS_SLEEPING);
|
|
|
}
|
|
|
|
|
|
-void _starpu_sched_node_lock_worker(int workerid)
|
|
|
+void _starpu_sched_component_lock_worker(int workerid)
|
|
|
{
|
|
|
STARPU_ASSERT(0 <= workerid && workerid < (int) starpu_worker_get_count());
|
|
|
- struct _starpu_worker_node_data * data = starpu_sched_node_worker_create(workerid)->data;
|
|
|
+ struct _starpu_worker_component_data * data = starpu_sched_component_worker_create(workerid)->data;
|
|
|
STARPU_PTHREAD_MUTEX_LOCK(&data->lock);
|
|
|
}
|
|
|
-void _starpu_sched_node_unlock_worker(int workerid)
|
|
|
+void _starpu_sched_component_unlock_worker(int workerid)
|
|
|
{
|
|
|
STARPU_ASSERT(0 <= workerid && workerid < (int)starpu_worker_get_count());
|
|
|
- struct _starpu_worker_node_data * data = starpu_sched_node_worker_create(workerid)->data;
|
|
|
+ struct _starpu_worker_component_data * data = starpu_sched_component_worker_create(workerid)->data;
|
|
|
STARPU_PTHREAD_MUTEX_UNLOCK(&data->lock);
|
|
|
}
|
|
|
|
|
|
-static void simple_worker_available(struct starpu_sched_node * worker_node)
|
|
|
+static void simple_worker_can_pull(struct starpu_sched_component * worker_component)
|
|
|
{
|
|
|
- (void) worker_node;
|
|
|
- struct _starpu_worker * w = _starpu_sched_node_worker_get_worker(worker_node);
|
|
|
- _starpu_sched_node_lock_worker(w->workerid);
|
|
|
- if(_starpu_sched_node_worker_is_reset_status(worker_node))
|
|
|
- _starpu_sched_node_worker_set_changed_status(worker_node);
|
|
|
+ (void) worker_component;
|
|
|
+ struct _starpu_worker * w = _starpu_sched_component_worker_get_worker(worker_component);
|
|
|
+ _starpu_sched_component_lock_worker(w->workerid);
|
|
|
+ if(_starpu_sched_component_worker_is_reset_status(worker_component))
|
|
|
+ _starpu_sched_component_worker_set_changed_status(worker_component);
|
|
|
|
|
|
if(w->workerid == starpu_worker_get_id())
|
|
|
{
|
|
|
- _starpu_sched_node_unlock_worker(w->workerid);
|
|
|
+ _starpu_sched_component_unlock_worker(w->workerid);
|
|
|
return;
|
|
|
}
|
|
|
- if(_starpu_sched_node_worker_is_sleeping_status(worker_node))
|
|
|
+ if(_starpu_sched_component_worker_is_sleeping_status(worker_component))
|
|
|
{
|
|
|
starpu_pthread_mutex_t *sched_mutex;
|
|
|
starpu_pthread_cond_t *sched_cond;
|
|
|
starpu_worker_get_sched_condition(w->workerid, &sched_mutex, &sched_cond);
|
|
|
- _starpu_sched_node_unlock_worker(w->workerid);
|
|
|
+ _starpu_sched_component_unlock_worker(w->workerid);
|
|
|
starpu_wakeup_worker(w->workerid, sched_cond, sched_mutex);
|
|
|
}
|
|
|
else
|
|
|
- _starpu_sched_node_unlock_worker(w->workerid);
|
|
|
+ _starpu_sched_component_unlock_worker(w->workerid);
|
|
|
}
|
|
|
|
|
|
-static void combined_worker_available(struct starpu_sched_node * node)
|
|
|
+static void combined_worker_can_pull(struct starpu_sched_component * component)
|
|
|
{
|
|
|
- (void) node;
|
|
|
- STARPU_ASSERT(starpu_sched_node_is_combined_worker(node));
|
|
|
- struct _starpu_worker_node_data * data = node->data;
|
|
|
+ (void) component;
|
|
|
+ STARPU_ASSERT(starpu_sched_component_is_combined_worker(component));
|
|
|
+ struct _starpu_worker_component_data * data = component->data;
|
|
|
int workerid = starpu_worker_get_id();
|
|
|
int i;
|
|
|
for(i = 0; i < data->combined_worker->worker_size; i++)
|
|
@@ -410,31 +410,31 @@ static void combined_worker_available(struct starpu_sched_node * node)
|
|
|
if(i == workerid)
|
|
|
continue;
|
|
|
int worker = data->combined_worker->combined_workerid[i];
|
|
|
- _starpu_sched_node_lock_worker(worker);
|
|
|
- if(_starpu_sched_node_worker_is_sleeping_status(node))
|
|
|
+ _starpu_sched_component_lock_worker(worker);
|
|
|
+ if(_starpu_sched_component_worker_is_sleeping_status(component))
|
|
|
{
|
|
|
starpu_pthread_mutex_t *sched_mutex;
|
|
|
starpu_pthread_cond_t *sched_cond;
|
|
|
starpu_worker_get_sched_condition(worker, &sched_mutex, &sched_cond);
|
|
|
starpu_wakeup_worker(worker, sched_cond, sched_mutex);
|
|
|
}
|
|
|
- if(_starpu_sched_node_worker_is_reset_status(node))
|
|
|
- _starpu_sched_node_worker_set_changed_status(node);
|
|
|
+ if(_starpu_sched_component_worker_is_reset_status(component))
|
|
|
+ _starpu_sched_component_worker_set_changed_status(component);
|
|
|
|
|
|
- _starpu_sched_node_unlock_worker(worker);
|
|
|
+ _starpu_sched_component_unlock_worker(worker);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static int simple_worker_push_task(struct starpu_sched_node * node, struct starpu_task *task)
|
|
|
+static int simple_worker_push_task(struct starpu_sched_component * component, struct starpu_task *task)
|
|
|
{
|
|
|
- STARPU_ASSERT(starpu_sched_node_is_worker(node));
|
|
|
+ STARPU_ASSERT(starpu_sched_component_is_worker(component));
|
|
|
/*this function take the worker's mutex */
|
|
|
- struct _starpu_worker_node_data * data = node->data;
|
|
|
+ struct _starpu_worker_component_data * data = component->data;
|
|
|
struct _starpu_task_grid * t = _starpu_task_grid_create();
|
|
|
t->task = task;
|
|
|
t->ntasks = 1;
|
|
|
|
|
|
- task->workerid = starpu_bitmap_first(node->workers);
|
|
|
+ task->workerid = starpu_bitmap_first(component->workers);
|
|
|
#if 1 /* dead lock problem? */
|
|
|
if (starpu_get_prefetch_flag())
|
|
|
{
|
|
@@ -445,13 +445,13 @@ static int simple_worker_push_task(struct starpu_sched_node * node, struct starp
|
|
|
STARPU_PTHREAD_MUTEX_LOCK(&data->list->mutex);
|
|
|
_starpu_worker_task_list_push(data->list, t);
|
|
|
STARPU_PTHREAD_MUTEX_UNLOCK(&data->list->mutex);
|
|
|
- simple_worker_available(node);
|
|
|
+ simple_worker_can_pull(component);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-struct starpu_task * simple_worker_pop_task(struct starpu_sched_node *node)
|
|
|
+struct starpu_task * simple_worker_pop_task(struct starpu_sched_component *component)
|
|
|
{
|
|
|
- struct _starpu_worker_node_data * data = node->data;
|
|
|
+ struct _starpu_worker_component_data * data = component->data;
|
|
|
struct _starpu_worker_task_list * list = data->list;
|
|
|
STARPU_PTHREAD_MUTEX_LOCK(&list->mutex);
|
|
|
struct starpu_task * task = _starpu_worker_task_list_pop(list);
|
|
@@ -463,34 +463,34 @@ struct starpu_task * simple_worker_pop_task(struct starpu_sched_node *node)
|
|
|
}
|
|
|
STARPU_PTHREAD_MUTEX_LOCK(&data->lock);
|
|
|
int i;
|
|
|
- _starpu_sched_node_worker_reset_status(node);
|
|
|
- for(i=0; i < node->nfathers; i++)
|
|
|
+ _starpu_sched_component_worker_reset_status(component);
|
|
|
+ for(i=0; i < component->nfathers; i++)
|
|
|
{
|
|
|
- if(node->fathers[i] == NULL)
|
|
|
+ if(component->fathers[i] == NULL)
|
|
|
continue;
|
|
|
else
|
|
|
{
|
|
|
- task = node->fathers[i]->pop_task(node->fathers[i]);
|
|
|
+ task = component->fathers[i]->pop_task(component->fathers[i]);
|
|
|
if(task)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if((!task) && _starpu_sched_node_worker_is_changed_status(node))
|
|
|
+ if((!task) && _starpu_sched_component_worker_is_changed_status(component))
|
|
|
{
|
|
|
- for(i=0; i < node->nfathers; i++)
|
|
|
+ for(i=0; i < component->nfathers; i++)
|
|
|
{
|
|
|
- if(node->fathers[i] == NULL)
|
|
|
+ if(component->fathers[i] == NULL)
|
|
|
continue;
|
|
|
else
|
|
|
{
|
|
|
- task = node->fathers[i]->pop_task(node->fathers[i]);
|
|
|
+ task = component->fathers[i]->pop_task(component->fathers[i]);
|
|
|
if(task)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
STARPU_ASSERT(task);
|
|
|
}
|
|
|
- _starpu_sched_node_worker_set_sleep_status(node);
|
|
|
+ _starpu_sched_component_worker_set_sleep_status(component);
|
|
|
STARPU_PTHREAD_MUTEX_UNLOCK(&data->lock);
|
|
|
if(!task)
|
|
|
return NULL;
|
|
@@ -502,40 +502,40 @@ struct starpu_task * simple_worker_pop_task(struct starpu_sched_node *node)
|
|
|
starpu_push_task_end(task);
|
|
|
return task;
|
|
|
}
|
|
|
- struct starpu_sched_node * combined_worker_node = starpu_sched_node_worker_get(workerid);
|
|
|
- (void)combined_worker_node->push_task(combined_worker_node, task);
|
|
|
+ struct starpu_sched_component * combined_worker_component = starpu_sched_component_worker_get(workerid);
|
|
|
+ (void)combined_worker_component->push_task(combined_worker_component, task);
|
|
|
/* we have pushed a task in queue, so can make a recursive call */
|
|
|
- return simple_worker_pop_task(node);
|
|
|
+ return simple_worker_pop_task(component);
|
|
|
|
|
|
}
|
|
|
if(task)
|
|
|
starpu_push_task_end(task);
|
|
|
return task;
|
|
|
}
|
|
|
-void starpu_sched_node_worker_destroy(struct starpu_sched_node *node)
|
|
|
+void starpu_sched_component_worker_destroy(struct starpu_sched_component *component)
|
|
|
{
|
|
|
- struct _starpu_worker * worker = _starpu_sched_node_worker_get_worker(node);
|
|
|
+ struct _starpu_worker * worker = _starpu_sched_component_worker_get_worker(component);
|
|
|
unsigned id = worker->workerid;
|
|
|
- assert(_worker_nodes[id] == node);
|
|
|
+ assert(_worker_components[id] == component);
|
|
|
int i;
|
|
|
for(i = 0; i < STARPU_NMAX_SCHED_CTXS ; i++)
|
|
|
- if(node->fathers[i] != NULL)
|
|
|
- return;//this node is shared between several contexts
|
|
|
- starpu_sched_node_destroy(node);
|
|
|
- _worker_nodes[id] = NULL;
|
|
|
+ if(component->fathers[i] != NULL)
|
|
|
+ return;//this component is shared between several contexts
|
|
|
+ starpu_sched_component_destroy(component);
|
|
|
+ _worker_components[id] = NULL;
|
|
|
}
|
|
|
|
|
|
-void _starpu_sched_node_lock_all_workers(void)
|
|
|
+void _starpu_sched_component_lock_all_workers(void)
|
|
|
{
|
|
|
unsigned i;
|
|
|
for(i = 0; i < starpu_worker_get_count(); i++)
|
|
|
- _starpu_sched_node_lock_worker(i);
|
|
|
+ _starpu_sched_component_lock_worker(i);
|
|
|
}
|
|
|
-void _starpu_sched_node_unlock_all_workers(void)
|
|
|
+void _starpu_sched_component_unlock_all_workers(void)
|
|
|
{
|
|
|
unsigned i;
|
|
|
for(i = 0; i < starpu_worker_get_count(); i++)
|
|
|
- _starpu_sched_node_unlock_worker(i);
|
|
|
+ _starpu_sched_component_unlock_worker(i);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -562,16 +562,16 @@ static double worker_estimated_finish_time(struct _starpu_worker * worker)
|
|
|
return sum + starpu_timing_now();
|
|
|
}
|
|
|
*/
|
|
|
-static double combined_worker_estimated_end(struct starpu_sched_node * node)
|
|
|
+static double combined_worker_estimated_end(struct starpu_sched_component * component)
|
|
|
{
|
|
|
- STARPU_ASSERT(starpu_sched_node_is_combined_worker(node));
|
|
|
- struct _starpu_worker_node_data * data = node->data;
|
|
|
+ STARPU_ASSERT(starpu_sched_component_is_combined_worker(component));
|
|
|
+ struct _starpu_worker_component_data * data = component->data;
|
|
|
struct _starpu_combined_worker * combined_worker = data->combined_worker;
|
|
|
double max = 0.0;
|
|
|
int i;
|
|
|
for(i = 0; i < combined_worker->worker_size; i++)
|
|
|
{
|
|
|
- data = _worker_nodes[combined_worker->combined_workerid[i]]->data;
|
|
|
+ data = _worker_components[combined_worker->combined_workerid[i]]->data;
|
|
|
STARPU_PTHREAD_MUTEX_LOCK(&data->list->mutex);
|
|
|
double tmp = data->list->exp_end;
|
|
|
STARPU_PTHREAD_MUTEX_UNLOCK(&data->list->mutex);
|
|
@@ -579,9 +579,9 @@ static double combined_worker_estimated_end(struct starpu_sched_node * node)
|
|
|
}
|
|
|
return max;
|
|
|
}
|
|
|
-static double simple_worker_estimated_end(struct starpu_sched_node * node)
|
|
|
+static double simple_worker_estimated_end(struct starpu_sched_component * component)
|
|
|
{
|
|
|
- struct _starpu_worker_node_data * data = node->data;
|
|
|
+ struct _starpu_worker_component_data * data = component->data;
|
|
|
STARPU_PTHREAD_MUTEX_LOCK(&data->list->mutex);
|
|
|
data->list->exp_start = STARPU_MAX(starpu_timing_now(), data->list->exp_start);
|
|
|
double tmp = data->list->exp_end = data->list->exp_start + data->list->exp_len;
|
|
@@ -591,9 +591,9 @@ static double simple_worker_estimated_end(struct starpu_sched_node * node)
|
|
|
|
|
|
|
|
|
|
|
|
-static double simple_worker_estimated_load(struct starpu_sched_node * node)
|
|
|
+static double simple_worker_estimated_load(struct starpu_sched_component * component)
|
|
|
{
|
|
|
- struct _starpu_worker * worker = _starpu_sched_node_worker_get_worker(node);
|
|
|
+ struct _starpu_worker * worker = _starpu_sched_component_worker_get_worker(component);
|
|
|
int nb_task = 0;
|
|
|
STARPU_PTHREAD_MUTEX_LOCK(&worker->mutex);
|
|
|
struct starpu_task_list list = worker->local_tasks;
|
|
@@ -603,37 +603,37 @@ static double simple_worker_estimated_load(struct starpu_sched_node * node)
|
|
|
task = starpu_task_list_next(task))
|
|
|
nb_task++;
|
|
|
STARPU_PTHREAD_MUTEX_UNLOCK(&worker->mutex);
|
|
|
- struct _starpu_worker_node_data * d = node->data;
|
|
|
+ struct _starpu_worker_component_data * d = component->data;
|
|
|
struct _starpu_worker_task_list * l = d->list;
|
|
|
int ntasks_in_fifo = l ? l->ntasks : 0;
|
|
|
return (double) (nb_task + ntasks_in_fifo)
|
|
|
/ starpu_worker_get_relative_speedup(
|
|
|
- starpu_worker_get_perf_archtype(starpu_bitmap_first(node->workers)));
|
|
|
+ starpu_worker_get_perf_archtype(starpu_bitmap_first(component->workers)));
|
|
|
}
|
|
|
|
|
|
-static double combined_worker_estimated_load(struct starpu_sched_node * node)
|
|
|
+static double combined_worker_estimated_load(struct starpu_sched_component * component)
|
|
|
{
|
|
|
- struct _starpu_worker_node_data * d = node->data;
|
|
|
+ struct _starpu_worker_component_data * d = component->data;
|
|
|
struct _starpu_combined_worker * c = d->combined_worker;
|
|
|
double load = 0;
|
|
|
int i;
|
|
|
for(i = 0; i < c->worker_size; i++)
|
|
|
{
|
|
|
- struct starpu_sched_node * n = starpu_sched_node_worker_get(c->combined_workerid[i]);
|
|
|
+ struct starpu_sched_component * n = starpu_sched_component_worker_get(c->combined_workerid[i]);
|
|
|
load += n->estimated_load(n);
|
|
|
}
|
|
|
return load;
|
|
|
}
|
|
|
|
|
|
-static int combined_worker_push_task(struct starpu_sched_node * node, struct starpu_task *task)
|
|
|
+static int combined_worker_push_task(struct starpu_sched_component * component, struct starpu_task *task)
|
|
|
{
|
|
|
- STARPU_ASSERT(starpu_sched_node_is_combined_worker(node));
|
|
|
- struct _starpu_worker_node_data * data = node->data;
|
|
|
+ STARPU_ASSERT(starpu_sched_component_is_combined_worker(component));
|
|
|
+ struct _starpu_worker_component_data * data = component->data;
|
|
|
STARPU_ASSERT(data->combined_worker && !data->worker);
|
|
|
struct _starpu_combined_worker * combined_worker = data->combined_worker;
|
|
|
STARPU_ASSERT(combined_worker->worker_size >= 1);
|
|
|
struct _starpu_task_grid * task_alias[combined_worker->worker_size];
|
|
|
- starpu_parallel_task_barrier_init(task, starpu_bitmap_first(node->workers));
|
|
|
+ starpu_parallel_task_barrier_init(task, starpu_bitmap_first(component->workers));
|
|
|
task_alias[0] = _starpu_task_grid_create();
|
|
|
task_alias[0]->task = starpu_task_dup(task);
|
|
|
task_alias[0]->task->workerid = combined_worker->combined_workerid[0];
|
|
@@ -654,8 +654,8 @@ static int combined_worker_push_task(struct starpu_sched_node * node, struct sta
|
|
|
i = 0;
|
|
|
do
|
|
|
{
|
|
|
- struct starpu_sched_node * worker_node = starpu_sched_node_worker_get(combined_worker->combined_workerid[i]);
|
|
|
- struct _starpu_worker_node_data * worker_data = worker_node->data;
|
|
|
+ struct starpu_sched_component * worker_component = starpu_sched_component_worker_get(combined_worker->combined_workerid[i]);
|
|
|
+ struct _starpu_worker_component_data * worker_data = worker_component->data;
|
|
|
struct _starpu_worker_task_list * list = worker_data->list;
|
|
|
STARPU_PTHREAD_MUTEX_LOCK(&list->mutex);
|
|
|
if(mutex_to_unlock)
|
|
@@ -672,7 +672,7 @@ static int combined_worker_push_task(struct starpu_sched_node * node, struct sta
|
|
|
int workerid = starpu_worker_get_id();
|
|
|
if(-1 == workerid)
|
|
|
{
|
|
|
- combined_worker_available(node);
|
|
|
+ combined_worker_can_pull(component);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -684,11 +684,11 @@ static int combined_worker_push_task(struct starpu_sched_node * node, struct sta
|
|
|
/* wake up all other workers of combined worker */
|
|
|
for(i = 0; i < combined_worker->worker_size; i++)
|
|
|
{
|
|
|
- struct starpu_sched_node * worker_node = starpu_sched_node_worker_get(combined_worker->combined_workerid[i]);
|
|
|
- simple_worker_available(worker_node);
|
|
|
+ struct starpu_sched_component * worker_component = starpu_sched_component_worker_get(combined_worker->combined_workerid[i]);
|
|
|
+ simple_worker_can_pull(worker_component);
|
|
|
}
|
|
|
|
|
|
- combined_worker_available(node);
|
|
|
+ combined_worker_can_pull(component);
|
|
|
|
|
|
STARPU_PTHREAD_MUTEX_LOCK(worker_sched_mutex);
|
|
|
}
|
|
@@ -696,146 +696,146 @@ static int combined_worker_push_task(struct starpu_sched_node * node, struct sta
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-void _worker_node_deinit_data(struct starpu_sched_node * node)
|
|
|
+void _worker_component_deinit_data(struct starpu_sched_component * component)
|
|
|
{
|
|
|
- struct _starpu_worker_node_data * d = node->data;
|
|
|
+ struct _starpu_worker_component_data * d = component->data;
|
|
|
_starpu_worker_task_list_destroy(d->list);
|
|
|
- if(starpu_sched_node_is_simple_worker(node))
|
|
|
+ if(starpu_sched_component_is_simple_worker(component))
|
|
|
STARPU_PTHREAD_MUTEX_DESTROY(&d->lock);
|
|
|
int i;
|
|
|
for(i = 0; i < STARPU_NMAXWORKERS; i++)
|
|
|
- if(_worker_nodes[i] == node)
|
|
|
+ if(_worker_components[i] == component)
|
|
|
{
|
|
|
- _worker_nodes[i] = NULL;
|
|
|
+ _worker_components[i] = NULL;
|
|
|
return;
|
|
|
}
|
|
|
free(d);
|
|
|
}
|
|
|
|
|
|
-static struct starpu_sched_node * starpu_sched_node_worker_create(int workerid)
|
|
|
+static struct starpu_sched_component * starpu_sched_component_worker_create(int workerid)
|
|
|
{
|
|
|
STARPU_ASSERT(0 <= workerid && workerid < (int) starpu_worker_get_count());
|
|
|
|
|
|
- if(_worker_nodes[workerid])
|
|
|
- return _worker_nodes[workerid];
|
|
|
+ if(_worker_components[workerid])
|
|
|
+ return _worker_components[workerid];
|
|
|
|
|
|
struct _starpu_worker * worker = _starpu_get_worker_struct(workerid);
|
|
|
if(worker == NULL)
|
|
|
return NULL;
|
|
|
- struct starpu_sched_node * node = starpu_sched_node_create();
|
|
|
- struct _starpu_worker_node_data * data = malloc(sizeof(*data));
|
|
|
+ struct starpu_sched_component * component = starpu_sched_component_create();
|
|
|
+ struct _starpu_worker_component_data * data = malloc(sizeof(*data));
|
|
|
memset(data, 0, sizeof(*data));
|
|
|
|
|
|
data->worker = worker;
|
|
|
STARPU_PTHREAD_MUTEX_INIT(&data->lock,NULL);
|
|
|
- data->status = NODE_STATUS_SLEEPING;
|
|
|
+ data->status = COMPONENT_STATUS_SLEEPING;
|
|
|
data->list = _starpu_worker_task_list_create();
|
|
|
- node->data = data;
|
|
|
-
|
|
|
- node->push_task = simple_worker_push_task;
|
|
|
- node->pop_task = simple_worker_pop_task;
|
|
|
- node->avail = simple_worker_available;
|
|
|
- node->estimated_end = simple_worker_estimated_end;
|
|
|
- node->estimated_load = simple_worker_estimated_load;
|
|
|
- node->deinit_data = _worker_node_deinit_data;
|
|
|
- starpu_bitmap_set(node->workers, workerid);
|
|
|
- starpu_bitmap_or(node->workers_in_ctx, node->workers);
|
|
|
- _worker_nodes[workerid] = node;
|
|
|
+ component->data = data;
|
|
|
+
|
|
|
+ component->push_task = simple_worker_push_task;
|
|
|
+ component->pop_task = simple_worker_pop_task;
|
|
|
+ component->can_pull = simple_worker_can_pull;
|
|
|
+ component->estimated_end = simple_worker_estimated_end;
|
|
|
+ component->estimated_load = simple_worker_estimated_load;
|
|
|
+ component->deinit_data = _worker_component_deinit_data;
|
|
|
+ starpu_bitmap_set(component->workers, workerid);
|
|
|
+ starpu_bitmap_or(component->workers_in_ctx, component->workers);
|
|
|
+ _worker_components[workerid] = component;
|
|
|
|
|
|
#ifdef STARPU_HAVE_HWLOC
|
|
|
struct _starpu_machine_config *config = _starpu_get_machine_config();
|
|
|
struct _starpu_machine_topology *topology = &config->topology;
|
|
|
hwloc_obj_t obj = hwloc_get_obj_by_depth(topology->hwtopology, config->cpu_depth, worker->bindid);
|
|
|
STARPU_ASSERT(obj);
|
|
|
- node->obj = obj;
|
|
|
+ component->obj = obj;
|
|
|
#endif
|
|
|
|
|
|
- return node;
|
|
|
+ return component;
|
|
|
}
|
|
|
|
|
|
|
|
|
-static struct starpu_sched_node * starpu_sched_node_combined_worker_create(int workerid)
|
|
|
+static struct starpu_sched_component * starpu_sched_component_combined_worker_create(int workerid)
|
|
|
{
|
|
|
STARPU_ASSERT(0 <= workerid && workerid < STARPU_NMAXWORKERS);
|
|
|
|
|
|
- if(_worker_nodes[workerid])
|
|
|
- return _worker_nodes[workerid];
|
|
|
+ if(_worker_components[workerid])
|
|
|
+ return _worker_components[workerid];
|
|
|
|
|
|
struct _starpu_combined_worker * combined_worker = _starpu_get_combined_worker_struct(workerid);
|
|
|
if(combined_worker == NULL)
|
|
|
return NULL;
|
|
|
- struct starpu_sched_node * node = starpu_sched_node_create();
|
|
|
- struct _starpu_worker_node_data * data = malloc(sizeof(*data));
|
|
|
+ struct starpu_sched_component * component = starpu_sched_component_create();
|
|
|
+ struct _starpu_worker_component_data * data = malloc(sizeof(*data));
|
|
|
memset(data, 0, sizeof(*data));
|
|
|
data->combined_worker = combined_worker;
|
|
|
- data->status = NODE_STATUS_SLEEPING;
|
|
|
-
|
|
|
- node->data = data;
|
|
|
- node->push_task = combined_worker_push_task;
|
|
|
- node->pop_task = NULL;
|
|
|
- node->estimated_end = combined_worker_estimated_end;
|
|
|
- node->estimated_load = combined_worker_estimated_load;
|
|
|
- node->avail = combined_worker_available;
|
|
|
- node->deinit_data = _worker_node_deinit_data;
|
|
|
- starpu_bitmap_set(node->workers, workerid);
|
|
|
- starpu_bitmap_or(node->workers_in_ctx, node->workers);
|
|
|
- _worker_nodes[workerid] = node;
|
|
|
+ data->status = COMPONENT_STATUS_SLEEPING;
|
|
|
+
|
|
|
+ component->data = data;
|
|
|
+ component->push_task = combined_worker_push_task;
|
|
|
+ component->pop_task = NULL;
|
|
|
+ component->estimated_end = combined_worker_estimated_end;
|
|
|
+ component->estimated_load = combined_worker_estimated_load;
|
|
|
+ component->can_pull = combined_worker_can_pull;
|
|
|
+ component->deinit_data = _worker_component_deinit_data;
|
|
|
+ starpu_bitmap_set(component->workers, workerid);
|
|
|
+ starpu_bitmap_or(component->workers_in_ctx, component->workers);
|
|
|
+ _worker_components[workerid] = component;
|
|
|
|
|
|
#ifdef STARPU_HAVE_HWLOC
|
|
|
struct _starpu_machine_config *config = _starpu_get_machine_config();
|
|
|
struct _starpu_machine_topology *topology = &config->topology;
|
|
|
hwloc_obj_t obj = hwloc_get_obj_by_depth(topology->hwtopology, config->cpu_depth, combined_worker->combined_workerid[0]);
|
|
|
STARPU_ASSERT(obj);
|
|
|
- node->obj = obj;
|
|
|
+ component->obj = obj;
|
|
|
#endif
|
|
|
- return node;
|
|
|
+ return component;
|
|
|
}
|
|
|
|
|
|
-int starpu_sched_node_is_simple_worker(struct starpu_sched_node * node)
|
|
|
+int starpu_sched_component_is_simple_worker(struct starpu_sched_component * component)
|
|
|
{
|
|
|
- return node->push_task == simple_worker_push_task;
|
|
|
+ return component->push_task == simple_worker_push_task;
|
|
|
}
|
|
|
-int starpu_sched_node_is_combined_worker(struct starpu_sched_node * node)
|
|
|
+int starpu_sched_component_is_combined_worker(struct starpu_sched_component * component)
|
|
|
{
|
|
|
- return node->push_task == combined_worker_push_task;
|
|
|
+ return component->push_task == combined_worker_push_task;
|
|
|
}
|
|
|
|
|
|
-int starpu_sched_node_is_worker(struct starpu_sched_node * node)
|
|
|
+int starpu_sched_component_is_worker(struct starpu_sched_component * component)
|
|
|
{
|
|
|
- return starpu_sched_node_is_simple_worker(node)
|
|
|
- || starpu_sched_node_is_combined_worker(node);
|
|
|
+ return starpu_sched_component_is_simple_worker(component)
|
|
|
+ || starpu_sched_component_is_combined_worker(component);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef STARPU_NO_ASSERT
|
|
|
-static int _worker_consistant(struct starpu_sched_node * node)
|
|
|
+static int _worker_consistant(struct starpu_sched_component * component)
|
|
|
{
|
|
|
int is_a_worker = 0;
|
|
|
int i;
|
|
|
for(i = 0; i<STARPU_NMAXWORKERS; i++)
|
|
|
- if(_worker_nodes[i] == node)
|
|
|
+ if(_worker_components[i] == component)
|
|
|
is_a_worker = 1;
|
|
|
if(!is_a_worker)
|
|
|
return 0;
|
|
|
- struct _starpu_worker_node_data * data = node->data;
|
|
|
+ struct _starpu_worker_component_data * data = component->data;
|
|
|
if(data->worker)
|
|
|
{
|
|
|
int id = data->worker->workerid;
|
|
|
- return (_worker_nodes[id] == node)
|
|
|
- && node->nchilds == 0;
|
|
|
+ return (_worker_components[id] == component)
|
|
|
+ && component->nchildren == 0;
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
-int starpu_sched_node_worker_get_workerid(struct starpu_sched_node * worker_node)
|
|
|
+int starpu_sched_component_worker_get_workerid(struct starpu_sched_component * worker_component)
|
|
|
{
|
|
|
#ifndef STARPU_NO_ASSERT
|
|
|
- STARPU_ASSERT(_worker_consistant(worker_node));
|
|
|
+ STARPU_ASSERT(_worker_consistant(worker_component));
|
|
|
#endif
|
|
|
- STARPU_ASSERT(1 == starpu_bitmap_cardinal(worker_node->workers));
|
|
|
- return starpu_bitmap_first(worker_node->workers);
|
|
|
+ STARPU_ASSERT(1 == starpu_bitmap_cardinal(worker_component->workers));
|
|
|
+ return starpu_bitmap_first(worker_component->workers);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -843,12 +843,12 @@ static struct _starpu_worker_task_list * _worker_get_list(void)
|
|
|
{
|
|
|
int workerid = starpu_worker_get_id();
|
|
|
STARPU_ASSERT(0 <= workerid && workerid < (int) starpu_worker_get_count());
|
|
|
- struct _starpu_worker_node_data * d = starpu_sched_node_worker_get(workerid)->data;
|
|
|
+ struct _starpu_worker_component_data * d = starpu_sched_component_worker_get(workerid)->data;
|
|
|
return d->list;
|
|
|
}
|
|
|
|
|
|
|
|
|
-void starpu_sched_node_worker_pre_exec_hook(struct starpu_task * task)
|
|
|
+void starpu_sched_component_worker_pre_exec_hook(struct starpu_task * task)
|
|
|
{
|
|
|
if(!isnan(task->predicted))
|
|
|
{
|
|
@@ -867,7 +867,7 @@ void starpu_sched_node_worker_pre_exec_hook(struct starpu_task * task)
|
|
|
STARPU_PTHREAD_MUTEX_UNLOCK(&list->mutex);
|
|
|
}
|
|
|
}
|
|
|
-void starpu_sched_node_worker_post_exec_hook(struct starpu_task * task)
|
|
|
+void starpu_sched_component_worker_post_exec_hook(struct starpu_task * task)
|
|
|
{
|
|
|
if(task->execute_on_a_specific_worker)
|
|
|
return;
|
|
@@ -880,15 +880,15 @@ void starpu_sched_node_worker_post_exec_hook(struct starpu_task * task)
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
-static void starpu_sched_node_worker_push_task_notify(struct starpu_task * task, int workerid, unsigned sched_ctx_id STARPU_ATTRIBUTE_UNUSED)
|
|
|
+static void starpu_sched_component_worker_push_task_notify(struct starpu_task * task, int workerid, unsigned sched_ctx_id STARPU_ATTRIBUTE_UNUSED)
|
|
|
{
|
|
|
|
|
|
- struct starpu_sched_node * worker_node = starpu_sched_node_worker_get(workerid);
|
|
|
+ struct starpu_sched_component * worker_component = starpu_sched_component_worker_get(workerid);
|
|
|
/* dont work with parallel tasks */
|
|
|
- if(starpu_sched_node_is_combined_worker(worker_node))
|
|
|
+ if(starpu_sched_component_is_combined_worker(worker_component))
|
|
|
return;
|
|
|
|
|
|
- struct _starpu_worker_node_data * d = worker_node->data;
|
|
|
+ struct _starpu_worker_component_data * d = worker_component->data;
|
|
|
struct _starpu_worker_task_list * list = d->list;
|
|
|
/* Compute the expected penality */
|
|
|
enum starpu_perfmodel_archtype perf_arch = starpu_worker_get_perf_archtype(workerid);
|