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

prioritize tasks according to the maximum depth of their dependent tasks.

Former-commit-id: 7ce8137a6362d80727fd3d06ca52e9afb25767c1
parent 61e7f193
No related branches found
No related tags found
No related merge requests found
......@@ -854,7 +854,7 @@ void engine_step ( struct engine *e ) {
void engine_init ( struct engine *e , struct space *s , float dt , int nr_threads , int nr_queues , int policy ) {
#if defined(HAVE_SETAFFINITY)
#if defined(NO_HAVE_SETAFFINITY)
cpu_set_t cpuset;
#endif
int k;
......@@ -900,7 +900,7 @@ void engine_init ( struct engine *e , struct space *s , float dt , int nr_thread
e->runners[k].e = e;
if ( pthread_create( &e->runners[k].thread , NULL , &runner_main , &e->runners[k] ) != 0 )
error( "Failed to create runner thread." );
#if defined(HAVE_SETAFFINITY)
#if defined(NO_HAVE_SETAFFINITY)
/* Set the cpu mask to zero | e->id. */
CPU_ZERO( &cpuset );
CPU_SET( e->runners[k].id , &cpuset );
......
......@@ -104,7 +104,7 @@ void queue_insert ( struct queue *q , struct task *t ) {
/* Shuffle up. */
for ( int k = q->count - 1 ; k > 0 ; k /= 2 )
if ( q->tasks[ q->tid[k] ].rank < q->tasks[ q->tid[k/2] ].rank ) {
if ( q->tasks[ q->tid[k] ].maxdepth > q->tasks[ q->tid[k/2] ].maxdepth ) {
int temp = q->tid[k];
q->tid[k] = q->tid[k/2];
q->tid[k/2] = temp;
......@@ -234,9 +234,9 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) {
int i = 2*k;
if ( i >= q->count )
break;
if ( i+1 < q->count && qtasks[ qtid[i+1] ].rank < qtasks[ qtid[i] ].rank )
if ( i+1 < q->count && qtasks[ qtid[i+1] ].maxdepth > qtasks[ qtid[i] ].maxdepth )
i += 1;
if ( qtasks[ qtid[i] ].rank < qtasks[ qtid[k] ].rank ) {
if ( qtasks[ qtid[i] ].maxdepth > qtasks[ qtid[k] ].maxdepth ) {
int temp = qtid[i];
qtid[i] = qtid[k];
qtid[k] = temp;
......
......@@ -473,6 +473,15 @@ void scheduler_ranktasks ( struct scheduler *s ) {
}
/* Run throught the tasks backwards and set their maxdepth. */
for ( k = nr_tasks-1 ; k >= 0 ; k-- ) {
t = &tasks[ tid[k] ];
t->maxdepth = 0;
for ( j = 0 ; j < t->nr_unlock_tasks ; j++ )
if ( t->unlock_tasks[j]->maxdepth > t->maxdepth )
t->maxdepth = t->unlock_tasks[j]->maxdepth;
}
}
......
......@@ -51,7 +51,7 @@ extern const char *taskID_names[];
struct task {
char type, subtype, skip, tight;
int flags, wait, rank;
int flags, wait, rank, maxdepth;
lock_type lock;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment