Commit 4e82363e authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

re-introduce subs.


Former-commit-id: fa5c3671177171e34f5f908f67b3a62df2f3ee75
parent 26655155
......@@ -100,7 +100,7 @@ struct cell {
int hold;
/* Spin lock for various uses. */
lock_type lock;
lock_type lock, mlock;
/* ID of the previous owner, e.g. runner. */
int owner;
......
......@@ -186,7 +186,7 @@ void runner_dosort ( struct runner *r , struct cell *c , int flags , int clock )
return;
/* start by allocating the entry arrays. */
if ( lock_lock( &c->lock ) != 0 )
if ( lock_lock( &c->mlock ) != 0 )
error( "Failed to lock cell." );
if ( c->sort == NULL || c->sortsize < c->count ) {
if ( c->sort != NULL )
......@@ -195,7 +195,7 @@ 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->lock ) != 0 )
if ( lock_unlock( &c->mlock ) != 0 )
error( "Failed to unlock cell." );
/* Does this cell have any progeny? */
......
......@@ -113,8 +113,8 @@ int space_marktasks ( struct space *s ) {
t->skip = ( t->ci->dt_min > dt_step );
/* Set the sort flags. */
if ( !t->skip && t->type == task_type_sub )
space_addsorts( s , t , t->ci , t->cj , t->flags );
// if ( !t->skip && t->type == task_type_sub )
// space_addsorts( s , t , t->ci , t->cj , t->flags );
}
......@@ -941,10 +941,10 @@ void space_splittasks ( struct space *s ) {
{ -1 , -1 , -1 , -1 , -1 , -1 , -1 , 12 } };
/* Loop through the tasks... */
#pragma omp parallel shared(s,tid,pts) private(ind,j,k,t,t_old,redo,ci,cj,hi,hj,sid,shift)
#pragma omp parallel default(none) shared(s,tid,pts,space_subsize) private(ind,j,k,t,t_old,redo,ci,cj,hi,hj,sid,shift)
{
redo = 0; t_old = t = NULL;
while ( redo || tid < s->nr_tasks ) {
while ( 1 ) {
/* Get a pointer on the task. */
if ( redo ) {
......@@ -952,9 +952,10 @@ void space_splittasks ( struct space *s ) {
t = t_old;
}
else {
if ( ( ind = atomic_inc( &tid ) ) >= s->nr_tasks )
if ( ( ind = atomic_inc( &tid ) ) < s->nr_tasks )
t_old = t = &s->tasks[ s->tasks_ind[ ind ] ];
else
break;
t_old = t = &s->tasks[ s->tasks_ind[ ind ] ];
}
/* Empty task? */
......@@ -988,7 +989,7 @@ void space_splittasks ( struct space *s ) {
/* Wait for this tasks sorts, as we will now have pairwise
components in this sub. */
space_addsorts( s , t , ci , NULL , -1 );
// space_addsorts( s , t , ci , NULL , -1 );
}
......@@ -1934,8 +1935,9 @@ struct cell *space_getcell ( struct space *s ) {
/* Init some things in the cell. */
bzero( c , sizeof(struct cell) );
if ( lock_init( &c->lock ) != 0 )
error( "Failed to initialize cell spinlock." );
if ( lock_init( &c->lock ) != 0 ||
lock_init( &c->mlock ) != 0 )
error( "Failed to initialize cell spinlocks." );
/* Unlock the space. */
lock_unlock_blind( &s->lock );
......
......@@ -26,7 +26,7 @@
#define space_splitratio 0.875
#define space_splitsize_default 400
#define space_subsize_default 1000
#define space_dosub 0
#define space_dosub 1
#define space_stretch 1.05
#define space_maxtaskspercell 31
......
......@@ -33,6 +33,7 @@
/* Local headers. */
#include "cycle.h"
#include "atomic.h"
#include "lock.h"
#include "task.h"
#include "error.h"
......@@ -125,10 +126,10 @@ void task_rmunlock_blind ( struct task *ta , struct task *tb ) {
* @param tb The #task that will be unlocked.
*/
void task_addunlock ( struct task *ta , struct task *tb ) {
void task_addunlock_new ( struct task *ta , struct task *tb ) {
/* Add the lock atomically. */
ta->unlock_tasks[ __sync_fetch_and_add( &ta->nr_unlock_tasks, 1 ) ] = tb;
ta->unlock_tasks[ atomic_inc( &ta->nr_unlock_tasks ) ] = tb;
/* Check a posteriori if we did not overshoot. */
if ( ta->nr_unlock_tasks > task_maxunlock )
......@@ -137,7 +138,7 @@ void task_addunlock ( struct task *ta , struct task *tb ) {
}
void task_addunlock_old ( struct task *ta , struct task *tb ) {
void task_addunlock ( struct task *ta , struct task *tb ) {
int k;
......
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