Skip to content
Snippets Groups Projects
Commit 692bb903 authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

revert to fast queues.

Former-commit-id: e5b9ea23660c4e597bf7513e865d642560987e8b
parent 4e9b5b63
No related branches found
No related tags found
No related merge requests found
...@@ -103,19 +103,19 @@ void queue_insert ( struct queue *q , struct task *t ) { ...@@ -103,19 +103,19 @@ void queue_insert ( struct queue *q , struct task *t ) {
q->count += 1; q->count += 1;
/* Shuffle up. */ /* Shuffle up. */
/* for ( int k = q->count - 1 ; k > 0 ; k = (k-1)/2 ) for ( int k = q->count - 1 ; k > 0 ; k = (k-1)/2 )
if ( q->tasks[ q->tid[k] ].weight > q->tasks[ q->tid[(k-1)/2] ].weight ) { if ( q->tasks[ q->tid[k] ].weight > q->tasks[ q->tid[(k-1)/2] ].weight ) {
int temp = q->tid[k]; int temp = q->tid[k];
q->tid[k] = q->tid[(k-1)/2]; q->tid[k] = q->tid[(k-1)/2];
q->tid[(k-1)/2] = temp; q->tid[(k-1)/2] = temp;
} }
else else
break; */ break;
for ( int k = q->count - 1 ; k > 0 && q->tasks[ q->tid[k-1] ].weight < q->tasks[ q->tid[k] ].weight ; k-- ) { /* for ( int k = q->count - 1 ; k > 0 && q->tasks[ q->tid[k-1] ].weight < q->tasks[ q->tid[k] ].weight ; k-- ) {
int temp = q->tid[k]; int temp = q->tid[k];
q->tid[k] = q->tid[k-1]; q->tid[k] = q->tid[k-1];
q->tid[k-1] = temp; q->tid[k-1] = temp;
} } */
/* Verify queue consistency. */ /* Verify queue consistency. */
/* for ( int k = 1 ; k < q->count ; k++ ) /* for ( int k = 1 ; k < q->count ; k++ )
...@@ -238,7 +238,7 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) { ...@@ -238,7 +238,7 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) {
cj->super->owner = qid; cj->super->owner = qid;
/* Swap this task with the last task and re-heap. */ /* Swap this task with the last task and re-heap. */
/* if ( k < qcount ) { if ( k < qcount ) {
qtid[ k ] = qtid[ qcount ]; qtid[ k ] = qtid[ qcount ];
while ( qtasks[ qtid[k] ].weight > qtasks[ qtid[(k-1)/2] ].weight ) { while ( qtasks[ qtid[k] ].weight > qtasks[ qtid[(k-1)/2] ].weight ) {
int temp = q->tid[k]; int temp = q->tid[k];
...@@ -246,6 +246,7 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) { ...@@ -246,6 +246,7 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) {
q->tid[(k-1)/2] = temp; q->tid[(k-1)/2] = temp;
k = (k-1)/2; k = (k-1)/2;
} }
int i;
while ( ( i = 2*k+1 ) < qcount ) { while ( ( i = 2*k+1 ) < qcount ) {
if ( i+1 < qcount && qtasks[ qtid[i+1] ].weight > qtasks[ qtid[i] ].weight ) if ( i+1 < qcount && qtasks[ qtid[i+1] ].weight > qtasks[ qtid[i] ].weight )
i += 1; i += 1;
...@@ -258,14 +259,14 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) { ...@@ -258,14 +259,14 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) {
else else
break; break;
} }
} */ }
qtid[ k ] = qtid[ qcount ]; /* qtid[ k ] = qtid[ qcount ];
while ( k < qcount-1 && qtasks[ qtid[k+1] ].weight > qtasks[ qtid[k] ].weight ) { while ( k < qcount-1 && qtasks[ qtid[k+1] ].weight > qtasks[ qtid[k] ].weight ) {
temp = qtid[k]; temp = qtid[k];
qtid[k] = qtid[k+1]; qtid[k] = qtid[k+1];
qtid[k+1] = temp; qtid[k+1] = temp;
k += 1; k += 1;
} } */
/* Verify queue consistency. */ /* Verify queue consistency. */
/* for ( k = 1 ; k < q->count ; k++ ) /* for ( k = 1 ; k < q->count ; k++ )
......
...@@ -563,47 +563,47 @@ void scheduler_start ( struct scheduler *s , unsigned int mask ) { ...@@ -563,47 +563,47 @@ void scheduler_start ( struct scheduler *s , unsigned int mask ) {
// #pragma omp parallel for schedule(static) private(t,j) // #pragma omp parallel for schedule(static) private(t,j)
for ( k = s->nr_tasks-1 ; k >= 0 ; k-- ) { for ( k = s->nr_tasks-1 ; k >= 0 ; k-- ) {
t = &tasks[ tid[k] ]; t = &tasks[ tid[k] ];
if ( ( (1 << t->type) & mask ) && !t->skip ) { if ( !( (1 << t->type) & mask ) || !t->skip )
for ( j = 0 ; j < t->nr_unlock_tasks ; j++ ) continue;
atomic_inc( &t->unlock_tasks[j]->wait ); for ( j = 0 ; j < t->nr_unlock_tasks ; j++ )
t->maxdepth = 0; atomic_inc( &t->unlock_tasks[j]->wait );
t->weight = 0; t->maxdepth = 0;
for ( j = 0 ; j < t->nr_unlock_tasks ; j++ ) { t->weight = 0;
if ( t->unlock_tasks[j]->weight > t->weight ) for ( j = 0 ; j < t->nr_unlock_tasks ; j++ ) {
t->weight = t->unlock_tasks[j]->weight; if ( t->unlock_tasks[j]->weight > t->weight )
if ( t->unlock_tasks[j]->maxdepth > t->maxdepth ) t->weight = t->unlock_tasks[j]->weight;
t->maxdepth = t->unlock_tasks[j]->maxdepth; if ( t->unlock_tasks[j]->maxdepth > t->maxdepth )
} t->maxdepth = t->unlock_tasks[j]->maxdepth;
t->maxdepth += 1; }
if ( t->tic > 0 ) t->maxdepth += 1;
t->weight += t->toc - t->tic; if ( t->tic > 0 )
else t->weight += t->toc - t->tic;
switch ( t->type ) { else
case task_type_sort: switch ( t->type ) {
t->weight += t->ci->count * ( sizeof(int)*8 - __builtin_clz( t->ci->count ) ); case task_type_sort:
break; t->weight += t->ci->count * ( sizeof(int)*8 - __builtin_clz( t->ci->count ) );
case task_type_self: break;
t->weight += t->ci->count * t->ci->count; case task_type_self:
break; t->weight += t->ci->count * t->ci->count;
case task_type_pair: break;
case task_type_pair:
t->weight += t->ci->count * t->cj->count;
break;
case task_type_sub:
if ( t->cj != NULL )
t->weight += t->ci->count * t->cj->count; t->weight += t->ci->count * t->cj->count;
break; else
case task_type_sub: t->weight += t->ci->count * t->ci->count;
if ( t->cj != NULL ) break;
t->weight += t->ci->count * t->cj->count; case task_type_ghost:
else if ( t->ci == t->ci->super )
t->weight += t->ci->count * t->ci->count;
break;
case task_type_ghost:
if ( t->ci == t->ci->super )
t->weight += t->ci->count;
break;
case task_type_kick1:
case task_type_kick2:
t->weight += t->ci->count; t->weight += t->ci->count;
break; break;
} case task_type_kick1:
} case task_type_kick2:
t->weight += t->ci->count;
break;
}
} }
/* Loop over the tasks and enqueue whoever is ready. */ /* Loop over the tasks and enqueue whoever is ready. */
...@@ -636,7 +636,6 @@ void scheduler_enqueue ( struct scheduler *s , struct task *t ) { ...@@ -636,7 +636,6 @@ void scheduler_enqueue ( struct scheduler *s , struct task *t ) {
case task_type_self: case task_type_self:
case task_type_sort: case task_type_sort:
case task_type_ghost: case task_type_ghost:
case task_type_kick1:
case task_type_kick2: case task_type_kick2:
qid = t->ci->super->owner; qid = t->ci->super->owner;
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment