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 {
int hold;
/* Spin lock for various uses. */
lock_type lock, mlock;
lock_type lock;
/* ID of the previous owner, e.g. runner. */
int owner;
......
......@@ -187,7 +187,7 @@ struct task *queue_gettask_old ( struct queue *q , int blocking , int keep ) {
continue;
/* 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 )
continue;
}
......@@ -317,7 +317,9 @@ struct task *queue_gettask ( struct queue *q , int rid , int blocking , int keep
continue;
/* 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 )
continue;
}
......@@ -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 ( ind_best >= 0 ) {
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 )
cell_unlocktree( res->ci );
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 )
return;
/* 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 )
free( c->sort );
......@@ -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 )
error( "Failed to allocate sort memory." );
}
if ( lock_unlock( &c->mlock ) != 0 )
error( "Failed to unlock cell." );
/* Does this cell have any progeny? */
if ( c->split ) {
......@@ -205,10 +201,7 @@ void runner_dosort ( struct runner *r , struct cell *c , int flags , int clock )
for ( k = 0 ; k < 8 ; k++ ) {
if ( c->progeny[k] == NULL )
continue;
if ( c->progeny[k]->sorts == NULL )
missing = flags;
else
missing = ( c->progeny[k]->sorts->flags ^ flags ) & flags;
missing = flags & ~c->progeny[k]->sorted;
if ( missing )
runner_dosort( r , c->progeny[k] , missing , 0 );
}
......@@ -735,6 +728,7 @@ void *runner_main ( void *data ) {
break;
case task_type_sort:
runner_dosort( r , ci , t->flags , 1 );
cell_unlocktree( ci );
break;
case task_type_sub:
if ( t->subtype == task_subtype_density )
......
......@@ -1654,9 +1654,8 @@ struct cell *space_getcell ( struct space *s ) {
/* Init some things in the cell. */
bzero( c , sizeof(struct cell) );
if ( lock_init( &c->lock ) != 0 ||
lock_init( &c->mlock ) != 0 )
error( "Failed to initialize cell spinlocks." );
if ( lock_init( &c->lock ) != 0 )
error( "Failed to initialize cell spinlock." );
/* Unlock the space. */
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