|
@@ -3,10 +3,16 @@
|
|
|
#include <starpu_scheduler.h>
|
|
|
|
|
|
|
|
|
+struct _starpu_fifo_data
|
|
|
+{
|
|
|
+ struct _starpu_fifo_taskq * fifo;
|
|
|
+ starpu_pthread_mutex_t mutex;
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
static struct _starpu_task_execute_preds estimated_execute_preds(struct _starpu_sched_node * node,
|
|
|
struct starpu_task * task)
|
|
|
{
|
|
|
-
|
|
|
if(node->nchilds == 0)
|
|
|
{
|
|
|
struct _starpu_task_execute_preds p = { CANNOT_EXECUTE };
|
|
@@ -15,16 +21,18 @@ static struct _starpu_task_execute_preds estimated_execute_preds(struct _starpu_
|
|
|
|
|
|
struct _starpu_task_execute_preds preds = node->childs[0]->estimated_execute_preds(node->childs[0],task);
|
|
|
|
|
|
- struct _starpu_fifo_taskq * fifo = node->data;
|
|
|
-// printf("%p %f %f %f\n",fifo ,fifo->exp_start,fifo->exp_len,fifo->exp_end);
|
|
|
-
|
|
|
- _starpu_spin_lock(&node->lock);
|
|
|
if(preds.state == PERF_MODEL)
|
|
|
- preds.expected_finish_time = _starpu_compute_expected_time(fifo->exp_start = starpu_timing_now(),
|
|
|
+ {
|
|
|
+ struct _starpu_fifo_data * data = node->data;
|
|
|
+ struct _starpu_fifo_taskq * fifo = data->fifo;
|
|
|
+ starpu_pthread_mutex_t * mutex = &data->mutex;
|
|
|
+ STARPU_PTHREAD_MUTEX_LOCK(mutex);
|
|
|
+ preds.expected_finish_time = _starpu_compute_expected_time(fifo->exp_start,
|
|
|
preds.expected_finish_time + fifo->exp_end,
|
|
|
preds.expected_length + fifo->exp_len,
|
|
|
preds.expected_transfer_length);
|
|
|
- _starpu_spin_unlock(&node->lock);
|
|
|
+ STARPU_PTHREAD_MUTEX_UNLOCK(mutex);
|
|
|
+ }
|
|
|
return preds;
|
|
|
}
|
|
|
|
|
@@ -50,9 +58,11 @@ static double estimated_load(struct _starpu_sched_node * node)
|
|
|
|
|
|
static int push_task(struct _starpu_sched_node * node, struct starpu_task * task)
|
|
|
{
|
|
|
- _starpu_spin_lock(&node->lock);
|
|
|
STARPU_ASSERT(node->nworkers > 0);
|
|
|
- struct _starpu_fifo_taskq * fifo = node->data;
|
|
|
+ struct _starpu_fifo_data * data = node->data;
|
|
|
+ struct _starpu_fifo_taskq * fifo = data->fifo;
|
|
|
+ starpu_pthread_mutex_t * mutex = &data->mutex;
|
|
|
+ STARPU_PTHREAD_MUTEX_LOCK(mutex);
|
|
|
STARPU_ASSERT(!isnan(fifo->exp_end));
|
|
|
STARPU_ASSERT(!isnan(fifo->exp_len));
|
|
|
STARPU_ASSERT(!isnan(fifo->exp_start));
|
|
@@ -65,16 +75,18 @@ static int push_task(struct _starpu_sched_node * node, struct starpu_task * task
|
|
|
STARPU_ASSERT(!isnan(fifo->exp_end));
|
|
|
STARPU_ASSERT(!isnan(fifo->exp_len));
|
|
|
STARPU_ASSERT(!isnan(fifo->exp_start));
|
|
|
+ STARPU_PTHREAD_MUTEX_UNLOCK(mutex);
|
|
|
|
|
|
- _starpu_spin_unlock(&node->lock);
|
|
|
node->available(node);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
static struct starpu_task * pop_task(struct _starpu_sched_node * node, unsigned sched_ctx_id)
|
|
|
{
|
|
|
- struct _starpu_fifo_taskq * fifo = node->data;
|
|
|
- _starpu_spin_lock(&node->lock);
|
|
|
+ struct _starpu_fifo_data * data = node->data;
|
|
|
+ struct _starpu_fifo_taskq * fifo = data->fifo;
|
|
|
+ starpu_pthread_mutex_t * mutex = &data->mutex;
|
|
|
+ STARPU_PTHREAD_MUTEX_LOCK(mutex);
|
|
|
STARPU_ASSERT(!isnan(fifo->exp_end));
|
|
|
STARPU_ASSERT(!isnan(fifo->exp_len));
|
|
|
STARPU_ASSERT(!isnan(fifo->exp_start));
|
|
@@ -90,8 +102,7 @@ static struct starpu_task * pop_task(struct _starpu_sched_node * node, unsigned
|
|
|
STARPU_ASSERT(!isnan(fifo->exp_end));
|
|
|
STARPU_ASSERT(!isnan(fifo->exp_len));
|
|
|
STARPU_ASSERT(!isnan(fifo->exp_start));
|
|
|
-
|
|
|
- _starpu_spin_unlock(&node->lock);
|
|
|
+ STARPU_PTHREAD_MUTEX_UNLOCK(mutex);
|
|
|
if(task)
|
|
|
return task;
|
|
|
struct _starpu_sched_node * father = node->fathers[sched_ctx_id];
|
|
@@ -111,17 +122,13 @@ int _starpu_sched_node_is_fifo(struct _starpu_sched_node * node)
|
|
|
struct _starpu_sched_node * _starpu_sched_node_fifo_create(void)
|
|
|
{
|
|
|
struct _starpu_sched_node * node = _starpu_sched_node_create();
|
|
|
- node->data = _starpu_create_fifo();
|
|
|
+ struct _starpu_fifo_data * data = malloc(sizeof(*data));
|
|
|
+ data->fifo = _starpu_create_fifo();
|
|
|
+ STARPU_PTHREAD_MUTEX_INIT(&data->mutex,NULL);
|
|
|
+ node->data = data;
|
|
|
node->estimated_execute_preds = estimated_execute_preds;
|
|
|
node->estimated_load = estimated_load;
|
|
|
node->push_task = push_task;
|
|
|
node->pop_task = pop_task;
|
|
|
return node;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-struct _starpu_fifo_taskq * _starpu_sched_node_fifo_get_fifo(struct _starpu_sched_node * node)
|
|
|
-{
|
|
|
- STARPU_ASSERT(_starpu_sched_node_is_fifo(node));
|
|
|
- return node->data;
|
|
|
-}
|