Commit da35b5df authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Removed the last traces of OpenMP in the code.


Former-commit-id: dbf79c6373aaf253e7e1898aee5afad68ee30c01
parent b48473af
......@@ -38,7 +38,6 @@
/* Local headers. */
#include "const.h"
#include "cycle.h"
#include "atomic.h"
#include "lock.h"
#include "task.h"
#include "kernel.h"
......@@ -335,7 +334,7 @@ void space_rebuild ( struct space *s , double cell_max ) {
else if ( p->x[j] >= dim[j] )
p->x[j] -= dim[j];
ind[k] = cell_getid( cdim , p->x[0]*ih[0] , p->x[1]*ih[1] , p->x[2]*ih[2] );
atomic_inc( &cells[ ind[k] ].count );
cells[ ind[k] ].count++;
}
// message( "getting particle indices took %.3f ms." , (double)(getticks() - tic) / CPU_TPS * 1000 );
......@@ -421,7 +420,7 @@ void space_rebuild ( struct space *s , double cell_max ) {
else if ( gp->x[j] >= dim[j] )
gp->x[j] -= dim[j];
ind[k] = cell_getid( cdim , gp->x[0]*ih[0] , gp->x[1]*ih[1] , gp->x[2]*ih[2] );
atomic_inc( &cells[ ind[k] ].gcount );
cells[ ind[k] ].gcount++;
}
// message( "getting particle indices took %.3f ms." , (double)(getticks() - tic) / CPU_TPS * 1000 );
......@@ -461,15 +460,8 @@ void space_rebuild ( struct space *s , double cell_max ) {
/* At this point, we have the upper-level cells, old or new. Now make
sure that the parts in each cell are ok. */
// tic = getticks();
k = 0;
if ( omp_get_thread_num() < 8 )
while ( 1 ) {
int myk = atomic_inc( &k );
if ( myk < s->nr_cells )
space_split( s , &cells[myk] );
else
break;
}
for ( k = 0; k < s->nr_cells; k++ )
space_split( s , &cells[k] );
// message( "space_split took %.3f ms." , (double)(getticks() - tic) / CPU_TPS * 1000 );
......@@ -520,23 +512,12 @@ void parts_sort ( struct part *parts , struct xpart *xparts , int *ind , int N ,
qstack[i].ready = 0;
first = 0; last = 1; waiting = 1;
/* Parallel bit. */
#pragma omp parallel default(shared) shared(N,first,last,waiting,qstack,parts,xparts,ind,qstack_size,stderr,engine_rank) private(pivot,i,ii,j,jj,min,max,temp_i,qid,temp_xp,temp_p)
{
/* Main loop. */
if ( omp_get_thread_num() < 8 )
while ( waiting > 0 ) {
/* Grab an interval off the queue. */
qid = atomic_inc( &first ) % qstack_size;
qid = ( first++ ) % qstack_size;
/* Wait for the interval to be ready. */
while ( waiting > 0 && atomic_cas( &qstack[qid].ready , 1 , 1 ) != 1 );
/* Broke loop for all the wrong reasons? */
if ( waiting == 0 )
break;
/* Get the stack entry. */
i = qstack[qid].i;
......@@ -544,7 +525,7 @@ void parts_sort ( struct part *parts , struct xpart *xparts , int *ind , int N ,
min = qstack[qid].min;
max = qstack[qid].max;
qstack[qid].ready = 0;
// message( "thread %i got interval [%i,%i] with values in [%i,%i]." , omp_get_thread_num() , i , j , min , max );
/* Loop over sub-intervals. */
while ( 1 ) {
......@@ -583,14 +564,13 @@ void parts_sort ( struct part *parts , struct xpart *xparts , int *ind , int N ,
/* Recurse on the left? */
if ( jj > i && pivot > min ) {
qid = atomic_inc( &last ) % qstack_size;
while ( atomic_cas( &qstack[qid].ready , 0 , 0 ) != 0 );
qid = ( last++ ) % qstack_size;
qstack[qid].i = i;
qstack[qid].j = jj;
qstack[qid].min = min;
qstack[qid].max = pivot;
qstack[qid].ready = 1;
if ( atomic_inc( &waiting ) >= qstack_size )
if ( waiting++ >= qstack_size )
error( "Qstack overflow." );
}
......@@ -608,14 +588,13 @@ void parts_sort ( struct part *parts , struct xpart *xparts , int *ind , int N ,
/* Recurse on the right? */
if ( jj+1 < j && pivot+1 < max ) {
qid = atomic_inc( &last ) % qstack_size;
while ( atomic_cas( &qstack[qid].ready , 0 , 0 ) != 0 );
qid = ( last++ ) % qstack_size;
qstack[qid].i = jj+1;
qstack[qid].j = j;
qstack[qid].min = pivot+1;
qstack[qid].max = max;
qstack[qid].ready = 1;
if ( atomic_inc( &waiting ) >= qstack_size )
if ( ( waiting++ ) >= qstack_size )
error( "Qstack overflow." );
}
......@@ -631,11 +610,10 @@ void parts_sort ( struct part *parts , struct xpart *xparts , int *ind , int N ,
} /* loop over sub-intervals. */
atomic_dec( &waiting );
waiting--;
} /* main loop. */
} /* parallel bit. */
/* Verify sort. */
/* for ( i = 1 ; i < N ; i++ )
......@@ -680,23 +658,12 @@ void gparts_sort ( struct gpart *gparts , int *ind , int N , int min , int max )
qstack[i].ready = 0;
first = 0; last = 1; waiting = 1;
/* Parallel bit. */
#pragma omp parallel default(shared) shared(N,first,last,waiting,qstack,gparts,ind,qstack_size,stderr,engine_rank) private(pivot,i,ii,j,jj,min,max,temp_i,qid,temp_p)
{
/* Main loop. */
if ( omp_get_thread_num() < 8 )
while ( waiting > 0 ) {
/* Grab an interval off the queue. */
qid = atomic_inc( &first ) % qstack_size;
qid = ( first++ ) % qstack_size;
/* Wait for the interval to be ready. */
while ( waiting > 0 && atomic_cas( &qstack[qid].ready , 1 , 1 ) != 1 );
/* Broke loop for all the wrong reasons? */
if ( waiting == 0 )
break;
/* Get the stack entry. */
i = qstack[qid].i;
......@@ -704,7 +671,7 @@ void gparts_sort ( struct gpart *gparts , int *ind , int N , int min , int max )
min = qstack[qid].min;
max = qstack[qid].max;
qstack[qid].ready = 0;
// message( "thread %i got interval [%i,%i] with values in [%i,%i]." , omp_get_thread_num() , i , j , min , max );
/* Loop over sub-intervals. */
while ( 1 ) {
......@@ -742,14 +709,13 @@ void gparts_sort ( struct gpart *gparts , int *ind , int N , int min , int max )
/* Recurse on the left? */
if ( jj > i && pivot > min ) {
qid = atomic_inc( &last ) % qstack_size;
while ( atomic_cas( &qstack[qid].ready , 0 , 0 ) != 0 );
qid = ( last++ ) % qstack_size;
qstack[qid].i = i;
qstack[qid].j = jj;
qstack[qid].min = min;
qstack[qid].max = pivot;
qstack[qid].ready = 1;
if ( atomic_inc( &waiting ) >= qstack_size )
if ( ( waiting++ ) >= qstack_size )
error( "Qstack overflow." );
}
......@@ -767,14 +733,13 @@ void gparts_sort ( struct gpart *gparts , int *ind , int N , int min , int max )
/* Recurse on the right? */
if ( jj+1 < j && pivot+1 < max ) {
qid = atomic_inc( &last ) % qstack_size;
while ( atomic_cas( &qstack[qid].ready , 0 , 0 ) != 0 );
qid = ( last++ ) % qstack_size;
qstack[qid].i = jj+1;
qstack[qid].j = j;
qstack[qid].min = pivot+1;
qstack[qid].max = max;
qstack[qid].ready = 1;
if ( atomic_inc( &waiting ) >= qstack_size )
if ( ( waiting++ ) >= qstack_size )
error( "Qstack overflow." );
}
......@@ -790,11 +755,11 @@ void gparts_sort ( struct gpart *gparts , int *ind , int N , int min , int max )
} /* loop over sub-intervals. */
atomic_dec( &waiting );
waiting--;
} /* main loop. */
} /* parallel bit. */
/* Verify sort. */
/* for ( i = 1 ; i < N ; i++ )
......
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