Commit 1030f513 authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

fix another error in recursive sort generation.


Former-commit-id: 535ec97a8a8958dcebef6d10998ae873e6bec49c
parent f2bf78f2
...@@ -100,7 +100,7 @@ struct cell { ...@@ -100,7 +100,7 @@ struct cell {
int hold; int hold;
/* Spin lock for various uses. */ /* Spin lock for various uses. */
lock_type lock, mlock; lock_type lock;
/* ID of the previous owner, e.g. runner. */ /* ID of the previous owner, e.g. runner. */
int owner; int owner;
......
...@@ -187,7 +187,7 @@ struct task *queue_gettask_old ( struct queue *q , int blocking , int keep ) { ...@@ -187,7 +187,7 @@ struct task *queue_gettask_old ( struct queue *q , int blocking , int keep ) {
continue; continue;
/* Different criteria for different types. */ /* Different criteria for different types. */
if ( res->type == task_type_self || (res->type == task_type_sub && res->cj == NULL) ) { if ( res->type == task_type_self || res->type == task_type_sort || (res->type == task_type_sub && res->cj == NULL) ) {
if ( res->ci->hold || cell_locktree( res->ci ) != 0 ) if ( res->ci->hold || cell_locktree( res->ci ) != 0 )
continue; continue;
} }
...@@ -317,7 +317,9 @@ struct task *queue_gettask ( struct queue *q , int rid , int blocking , int keep ...@@ -317,7 +317,9 @@ struct task *queue_gettask ( struct queue *q , int rid , int blocking , int keep
continue; continue;
/* Try to lock ci. */ /* Try to lock ci. */
if ( res->type == task_type_self || (res->type == task_type_sub && res->cj == NULL) ) { if ( res->type == task_type_self ||
res->type == task_type_sort ||
(res->type == task_type_sub && res->cj == NULL) ) {
if ( res->ci != ci_best && res->ci != cj_best && cell_locktree( res->ci ) != 0 ) if ( res->ci != ci_best && res->ci != cj_best && cell_locktree( res->ci ) != 0 )
continue; continue;
} }
...@@ -336,7 +338,7 @@ struct task *queue_gettask ( struct queue *q , int rid , int blocking , int keep ...@@ -336,7 +338,7 @@ struct task *queue_gettask ( struct queue *q , int rid , int blocking , int keep
/* If we owned a previous task, unlock it. */ /* If we owned a previous task, unlock it. */
if ( ind_best >= 0 ) { if ( ind_best >= 0 ) {
res = &qtasks[ qtid[ ind_best ] ]; res = &qtasks[ qtid[ ind_best ] ];
if ( res->type == task_type_self || res->type == task_type_pair || res->type == task_type_sub ) if ( res->type == task_type_self || res->type == task_type_sort || res->type == task_type_pair || res->type == task_type_sub )
if ( res->ci != ci_best && res->ci != cj_best ) if ( res->ci != ci_best && res->ci != cj_best )
cell_unlocktree( res->ci ); cell_unlocktree( res->ci );
if ( res->type == task_type_pair || (res->type == task_type_sub && res->cj != NULL) ) if ( res->type == task_type_pair || (res->type == task_type_sub && res->cj != NULL) )
......
...@@ -186,8 +186,6 @@ void runner_dosort ( struct runner *r , struct cell *c , int flags , int clock ) ...@@ -186,8 +186,6 @@ void runner_dosort ( struct runner *r , struct cell *c , int flags , int clock )
return; return;
/* start by allocating the entry arrays. */ /* start by allocating the entry arrays. */
if ( lock_lock( &c->mlock ) != 0 )
error( "Failed to lock cell." );
if ( c->sort == NULL || c->sortsize < c->count ) { if ( c->sort == NULL || c->sortsize < c->count ) {
if ( c->sort != NULL ) if ( c->sort != NULL )
free( c->sort ); free( c->sort );
...@@ -195,8 +193,6 @@ void runner_dosort ( struct runner *r , struct cell *c , int flags , int clock ) ...@@ -195,8 +193,6 @@ void runner_dosort ( struct runner *r , struct cell *c , int flags , int clock )
if ( ( c->sort = (struct entry *)malloc( sizeof(struct entry) * (c->sortsize + 1) * 13 ) ) == NULL ) if ( ( c->sort = (struct entry *)malloc( sizeof(struct entry) * (c->sortsize + 1) * 13 ) ) == NULL )
error( "Failed to allocate sort memory." ); error( "Failed to allocate sort memory." );
} }
if ( lock_unlock( &c->mlock ) != 0 )
error( "Failed to unlock cell." );
/* Does this cell have any progeny? */ /* Does this cell have any progeny? */
if ( c->split ) { if ( c->split ) {
...@@ -205,10 +201,7 @@ void runner_dosort ( struct runner *r , struct cell *c , int flags , int clock ) ...@@ -205,10 +201,7 @@ void runner_dosort ( struct runner *r , struct cell *c , int flags , int clock )
for ( k = 0 ; k < 8 ; k++ ) { for ( k = 0 ; k < 8 ; k++ ) {
if ( c->progeny[k] == NULL ) if ( c->progeny[k] == NULL )
continue; continue;
if ( c->progeny[k]->sorts == NULL ) missing = flags & ~c->progeny[k]->sorted;
missing = flags;
else
missing = ( c->progeny[k]->sorts->flags ^ flags ) & flags;
if ( missing ) if ( missing )
runner_dosort( r , c->progeny[k] , missing , 0 ); runner_dosort( r , c->progeny[k] , missing , 0 );
} }
...@@ -735,6 +728,7 @@ void *runner_main ( void *data ) { ...@@ -735,6 +728,7 @@ void *runner_main ( void *data ) {
break; break;
case task_type_sort: case task_type_sort:
runner_dosort( r , ci , t->flags , 1 ); runner_dosort( r , ci , t->flags , 1 );
cell_unlocktree( ci );
break; break;
case task_type_sub: case task_type_sub:
if ( t->subtype == task_subtype_density ) if ( t->subtype == task_subtype_density )
......
...@@ -1654,9 +1654,8 @@ struct cell *space_getcell ( struct space *s ) { ...@@ -1654,9 +1654,8 @@ struct cell *space_getcell ( struct space *s ) {
/* Init some things in the cell. */ /* Init some things in the cell. */
bzero( c , sizeof(struct cell) ); bzero( c , sizeof(struct cell) );
if ( lock_init( &c->lock ) != 0 || if ( lock_init( &c->lock ) != 0 )
lock_init( &c->mlock ) != 0 ) error( "Failed to initialize cell spinlock." );
error( "Failed to initialize cell spinlocks." );
/* Unlock the space. */ /* Unlock the space. */
lock_unlock_blind( &s->lock ); lock_unlock_blind( &s->lock );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment