|
@@ -57,17 +57,23 @@ void _starpu_sched_node_set_father(struct _starpu_sched_node *node,
|
|
|
|
|
|
struct starpu_task * pop_task(unsigned sched_ctx_id)
|
|
|
{
|
|
|
- //struct _starpu_sched_tree * t = starpu_sched_ctx_get_policy_data(sched_ctx_id);
|
|
|
+ struct _starpu_sched_tree * t = starpu_sched_ctx_get_policy_data(sched_ctx_id);
|
|
|
int workerid = starpu_worker_get_id();
|
|
|
struct _starpu_sched_node * wn = _starpu_sched_node_worker_get(workerid);
|
|
|
- return wn->pop_task(wn, sched_ctx_id);
|
|
|
+ _starpu_spin_lock(&t->lock);
|
|
|
+ struct starpu_task * task = wn->pop_task(wn, sched_ctx_id);
|
|
|
+ _starpu_spin_unlock(&t->lock);
|
|
|
+ return task;
|
|
|
}
|
|
|
|
|
|
int push_task(struct starpu_task * task)
|
|
|
{
|
|
|
unsigned sched_ctx_id = task->sched_ctx;
|
|
|
struct _starpu_sched_tree * t = starpu_sched_ctx_get_policy_data(sched_ctx_id);
|
|
|
- return t->root->push_task(t->root, task);
|
|
|
+ _starpu_spin_lock(&t->lock);
|
|
|
+ int ret = t->root->push_task(t->root, task);
|
|
|
+ _starpu_spin_unlock(&t->lock);
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
void _starpu_node_destroy_rec(struct _starpu_sched_node * node, unsigned sched_ctx_id)
|
|
@@ -118,7 +124,7 @@ void _starpu_node_destroy_rec(struct _starpu_sched_node * node, unsigned sched_c
|
|
|
void _starpu_tree_destroy(struct _starpu_sched_tree * tree, unsigned sched_ctx_id)
|
|
|
{
|
|
|
_starpu_node_destroy_rec(tree->root, sched_ctx_id);
|
|
|
- STARPU_PTHREAD_RWLOCK_DESTROY(&tree->mutex);
|
|
|
+ _starpu_spin_destroy(&tree->lock);
|
|
|
free(tree);
|
|
|
}
|
|
|
void _starpu_sched_node_add_child(struct _starpu_sched_node* node, struct _starpu_sched_node * child,unsigned sched_ctx_id STARPU_ATTRIBUTE_UNUSED)
|
|
@@ -151,10 +157,10 @@ int _starpu_tree_push_task(struct starpu_task * task)
|
|
|
{
|
|
|
unsigned sched_ctx_id = task->sched_ctx;
|
|
|
struct _starpu_sched_tree *tree = starpu_sched_ctx_get_policy_data(sched_ctx_id);
|
|
|
- STARPU_PTHREAD_RWLOCK_RDLOCK(&tree->mutex);
|
|
|
+// _starpu_spin_lock(&tree->lock);
|
|
|
int ret_val = tree->root->push_task(tree->root,task);
|
|
|
// starpu_push_task_end(task);
|
|
|
- STARPU_PTHREAD_RWLOCK_UNLOCK(&tree->mutex);
|
|
|
+// _starpu_spin_unlock(&tree->lock);
|
|
|
return ret_val;
|
|
|
}
|
|
|
struct starpu_task * _starpu_tree_pop_task(unsigned sched_ctx_id)
|
|
@@ -162,9 +168,9 @@ struct starpu_task * _starpu_tree_pop_task(unsigned sched_ctx_id)
|
|
|
struct _starpu_sched_tree *tree = starpu_sched_ctx_get_policy_data(sched_ctx_id);
|
|
|
int workerid = starpu_worker_get_id();
|
|
|
struct _starpu_sched_node * node = _starpu_sched_node_worker_get(workerid);
|
|
|
- STARPU_PTHREAD_RWLOCK_RDLOCK(&tree->mutex);
|
|
|
+// _starpu_spin_lock(&tree->lock);
|
|
|
struct starpu_task * task = node->pop_task(node, sched_ctx_id);
|
|
|
- STARPU_PTHREAD_RWLOCK_UNLOCK(&tree->mutex);
|
|
|
+// _starpu_spin_unlock(&tree->lock);
|
|
|
return task;
|
|
|
}
|
|
|
/*
|
|
@@ -288,7 +294,7 @@ struct _starpu_sched_node * _starpu_sched_node_create(void)
|
|
|
{
|
|
|
struct _starpu_sched_node * node = malloc(sizeof(*node));
|
|
|
memset(node,0,sizeof(*node));
|
|
|
- STARPU_PTHREAD_RWLOCK_INIT(&node->mutex,NULL);
|
|
|
+ _starpu_spin_init(&node->lock);
|
|
|
node->available = available;
|
|
|
node->pop_task = pop_task_node;
|
|
|
node->estimated_load = estimated_load;
|