diff --git a/src/cell.h b/src/cell.h index 6005929f35cb61294247d593f05680e4ce3b3d7b..bfa54e6b547bfe07bafd20b744db5966caf37f0b 100644 --- a/src/cell.h +++ b/src/cell.h @@ -65,7 +65,7 @@ struct cell { /* Pointers for the sorted indices. */ struct entry *sort; - int sorted; + unsigned int sorted; /* Number of pairs associated with this cell. */ // int nr_pairs; diff --git a/src/engine.c b/src/engine.c index 0e78da341eebfa26d74330c3c27e9fb895b8a558..cdb8afc8b379b7ac73633365fef2bf705f9aca0e 100644 --- a/src/engine.c +++ b/src/engine.c @@ -269,6 +269,15 @@ int engine_marktasks ( struct engine *e ) { return 1; } + + /* Sort? */ + else if ( t->type == task_type_sort ) { + + /* If all the sorts have been done, make this task implicit. */ + if ( !( t->flags & (t->flags ^ t->ci->sorted ) ) ) + t->implicit = 1; + + } } @@ -320,10 +329,14 @@ int engine_marktasks ( struct engine *e ) { /* Set the sort flags. */ if ( !t->skip && t->type == task_type_pair ) { - ci->sorts->flags |= (1 << t->flags); - ci->sorts->skip = 0; - cj->sorts->flags |= (1 << t->flags); - cj->sorts->skip = 0; + if ( !( ci->sorted & ( 1 << t->flags ) ) ) { + ci->sorts->flags |= (1 << t->flags); + ci->sorts->skip = 0; + } + if ( !( cj->sorted & ( 1 << t->flags ) ) ) { + cj->sorts->flags |= (1 << t->flags); + cj->sorts->skip = 0; + } } } diff --git a/src/scheduler.c b/src/scheduler.c index 6a132d21ceb2b69d48fd2ef586b8a7fb595a6ae0..fc2a5db633e08af4fddeac43d5fafcac1e3b61ab 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -692,18 +692,19 @@ void scheduler_done ( struct scheduler *s , struct task *t ) { struct task *t2; /* Release whatever locks this task held. */ - switch ( t->type ) { - case task_type_self: - case task_type_sort: - cell_unlocktree( t->ci ); - break; - case task_type_pair: - case task_type_sub: - cell_unlocktree( t->ci ); - if ( t->cj != NULL ) - cell_unlocktree( t->cj ); - break; - } + if ( !t->implicit ) + switch ( t->type ) { + case task_type_self: + case task_type_sort: + cell_unlocktree( t->ci ); + break; + case task_type_pair: + case task_type_sub: + cell_unlocktree( t->ci ); + if ( t->cj != NULL ) + cell_unlocktree( t->cj ); + break; + } /* Loop through the dependencies and add them to a queue if they are ready. */