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

Cleaned out all but 3 omp statements. Might also have corrected a race...

Cleaned out all but 3 omp statements. Might also have corrected a race condition in the space construction.


Former-commit-id: e0b9e6872f5388f09b94489c65869acc28e3eb7c
parent a8b4503a
......@@ -32,7 +32,6 @@
#include <float.h>
#include <limits.h>
#include <fenv.h>
#include <omp.h>
/* Conditional headers. */
#ifdef HAVE_LIBZ
......@@ -271,7 +270,6 @@ void pairs_n2 ( double *dim , struct part *__restrict__ parts , int N , int peri
double rho_max = 0.0, rho_min = 100;
/* Loop over all particle pairs. */
#pragma omp parallel for schedule(dynamic), default(none), private(k,i,dx,r2), shared(periodic,parts,dim,N,stdout)
for ( j = 0 ; j < N ; j++ ) {
if ( j % 1000 == 0 ) {
printf( "pairs_n2: j=%i.\n" , j );
......@@ -291,13 +289,11 @@ void pairs_n2 ( double *dim , struct part *__restrict__ parts , int N , int peri
if ( r2 < parts[j].h*parts[j].h || r2 < parts[k].h*parts[k].h ) {
runner_iact_density( r2 , NULL , parts[j].h , parts[k].h , &parts[j] , &parts[k] );
/* if ( parts[j].h / parts[k].h > maxratio )
#pragma omp critical
{
maxratio = parts[j].h / parts[k].h;
mj = j; mk = k;
}
else if ( parts[k].h / parts[j].h > maxratio )
#pragma omp critical
{
maxratio = parts[k].h / parts[j].h;
mj = j; mk = k;
......@@ -658,7 +654,6 @@ int main ( int argc , char *argv[] ) {
case 't':
if ( sscanf( optarg , "%d" , &nr_threads ) != 1 )
error( "Error parsing number of threads." );
omp_set_num_threads( nr_threads );
break;
case 'w':
if ( sscanf( optarg , "%d" , &space_subsize ) != 1 )
......
......@@ -29,7 +29,6 @@
#include <math.h>
#include <float.h>
#include <limits.h>
#include <omp.h>
#include <sched.h>
/* MPI headers. */
......@@ -1041,7 +1040,6 @@ void engine_maketasks ( struct engine *e ) {
/* Count the number of tasks associated with each cell and
store the density tasks in each cell, and make each sort
depend on the sorts of its progeny. */
// #pragma omp parallel for private(t,j)
for ( k = 0 ; k < sched->nr_tasks ; k++ ) {
/* Get the current task. */
......@@ -1112,7 +1110,6 @@ void engine_maketasks ( struct engine *e ) {
Each force task depends on the cell ghosts and unlocks the kick2 task
of its super-cell. */
kk = sched->nr_tasks;
// #pragma omp parallel for private(t,t2)
for ( k = 0 ; k < kk ; k++ ) {
/* Get a pointer to the task. */
......
......@@ -29,7 +29,6 @@
#include <math.h>
#include <float.h>
#include <limits.h>
#include <omp.h>
#include <sched.h>
/* MPI headers. */
......
......@@ -28,7 +28,6 @@
#include <math.h>
#include <float.h>
#include <limits.h>
#include <omp.h>
/* MPI headers. */
#ifdef WITH_MPI
......
......@@ -27,7 +27,6 @@
#include <math.h>
#include <pthread.h>
#include <limits.h>
#include <omp.h>
/* MPI headers. */
#ifdef WITH_MPI
......@@ -725,7 +724,6 @@ void scheduler_reweight ( struct scheduler *s ) {
/* Run throught the tasks backwards and set their waits and
weights. */
// tic = getticks();
// #pragma omp parallel for schedule(static) private(t,j)
for ( k = nr_tasks-1 ; k >= 0 ; k-- ) {
t = &tasks[ tid[k] ];
t->weight = 0;
......@@ -810,7 +808,6 @@ void scheduler_start ( struct scheduler *s , unsigned int mask ) {
/* Run throught the tasks and set their waits. */
// tic = getticks();
// #pragma omp parallel for schedule(static) private(t,j)
for ( k = nr_tasks - 1 ; k >= 0 ; k-- ) {
t = &tasks[ tid[k] ];
t->wait = 0;
......
......@@ -28,7 +28,7 @@
#include <float.h>
#include <limits.h>
#include <math.h>
#include <omp.h>
/* MPI headers. */
#ifdef WITH_MPI
......@@ -327,7 +327,6 @@ void space_rebuild ( struct space *s , double cell_max ) {
ih[0] = s->ih[0]; ih[1] = s->ih[1]; ih[2] = s->ih[2];
dim[0] = s->dim[0]; dim[1] = s->dim[1]; dim[2] = s->dim[2];
cdim[0] = s->cdim[0]; cdim[1] = s->cdim[1]; cdim[2] = s->cdim[2];
#pragma omp parallel for private(p,j)
for ( k = 0 ; k < nr_parts ; k++ ) {
p = &parts[k];
for ( j = 0 ; j < 3 ; j++ )
......@@ -414,7 +413,6 @@ void space_rebuild ( struct space *s , double cell_max ) {
// tic = getticks();
if ( ( ind = (int *)malloc( sizeof(int) * s->size_gparts ) ) == NULL )
error( "Failed to allocate temporary particle indices." );
#pragma omp parallel for private(gp,j)
for ( k = 0 ; k < nr_gparts ; k++ ) {
gp = &gparts[k];
for ( j = 0 ; j < 3 ; j++ )
......@@ -464,17 +462,15 @@ void space_rebuild ( struct space *s , double cell_max ) {
sure that the parts in each cell are ok. */
// tic = getticks();
k = 0;
#pragma omp parallel shared(s,k)
{
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;
}
}
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;
}
// message( "space_split took %.3f ms." , (double)(getticks() - tic) / CPU_TPS * 1000 );
}
......@@ -855,19 +851,9 @@ void space_map_parts ( struct space *s , void (*fun)( struct part *p , struct ce
}
/* Call the recursive function on all higher-level cells. */
#pragma omp parallel shared(cid)
{
int mycid;
while ( 1 ) {
#pragma omp critical
mycid = cid++;
if ( mycid < s->nr_cells )
rec_map( &s->cells[mycid] );
else
break;
}
}
for( cid = 0; cid < s->nr_cells; cid++ )
rec_map( &s->cells[cid] );
}
......@@ -901,18 +887,8 @@ void space_map_cells_post ( struct space *s , int full , void (*fun)( struct cel
}
/* Call the recursive function on all higher-level cells. */
// #pragma omp parallel shared(s,cid)
{
int mycid;
while ( 1 ) {
// #pragma omp critical
mycid = cid++;
if ( mycid < s->nr_cells )
rec_map( &s->cells[mycid] );
else
break;
}
}
for ( cid = 0; cid < s->nr_cells; cid++ )
rec_map( &s->cells[cid] );
}
......@@ -938,18 +914,9 @@ void space_map_cells_pre ( struct space *s , int full , void (*fun)( struct cell
}
/* Call the recursive function on all higher-level cells. */
// #pragma omp parallel shared(s,cid)
{
int mycid;
while ( 1 ) {
// #pragma omp critical
mycid = cid++;
if ( mycid < s->nr_cells )
rec_map( &s->cells[mycid] );
else
break;
}
}
for (cid = 0; cid < s->nr_cells; cid++ )
rec_map( &s->cells[cid] );
}
......
......@@ -28,7 +28,6 @@
#include <math.h>
#include <float.h>
#include <limits.h>
#include <omp.h>
#include <sched.h>
/* MPI headers. */
......
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