Commit 043a43f8 authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

Merge branch 'mpi_fixes' into 'master'

Mpi fixes

Batch jobs on the COSMA4 queue (using intel compiler and MPI) do not
run. The main reason is an overrun of the cpuid array because of the
number of cores (not a power of 2). This patch attempts to fix that.

Also includes an additional fix for a incorrect size memcpy I discovered.

See merge request !12


Former-commit-id: 19f3277120365d6722cfbddc94c97cb04bda1326
parents 3b09f3ec 6d8c3195
...@@ -2011,11 +2011,17 @@ void engine_init ( struct engine *e , struct space *s , float dt , int nr_thread ...@@ -2011,11 +2011,17 @@ void engine_init ( struct engine *e , struct space *s , float dt , int nr_thread
cpuid[k] = k; cpuid[k] = k;
} }
else { else {
/* Get next highest power of 2. */
int maxint = 1;
while ( maxint < nr_cores )
maxint *= 2;
cpuid[0] = 0; cpuid[0] = 0;
k = 1; k = 1;
for ( i = 1 ; i < nr_cores ; i *= 2 ) for ( i = 1 ; i < maxint ; i *= 2 )
for ( j = nr_cores / i / 2 ; j < nr_cores ; j += nr_cores / i ) for ( j = maxint / i / 2 ; j < maxint ; j += maxint / i )
cpuid[k++] = j; if ( j < nr_cores && j != 0 )
cpuid[k++] = j;
#ifdef WITHMPI #ifdef WITHMPI
printf( "engine_init: cpu map is [ " ); printf( "engine_init: cpu map is [ " );
#else #else
......
...@@ -285,7 +285,7 @@ void proxy_parts_load ( struct proxy *p , struct part *parts , struct xpart *xpa ...@@ -285,7 +285,7 @@ void proxy_parts_load ( struct proxy *p , struct part *parts , struct xpart *xpa
( txp = (struct xpart *)malloc( sizeof(struct xpart) * p->size_parts_out ) ) == NULL ) ( txp = (struct xpart *)malloc( sizeof(struct xpart) * p->size_parts_out ) ) == NULL )
error( "Failed to re-allocate parts_out buffers." ); error( "Failed to re-allocate parts_out buffers." );
memcpy( tp , p->parts_out , sizeof(struct part) * p->nr_parts_out ); memcpy( tp , p->parts_out , sizeof(struct part) * p->nr_parts_out );
memcpy( txp , p->xparts_out , sizeof(struct part) * p->nr_parts_out ); memcpy( txp , p->xparts_out , sizeof(struct xpart) * p->nr_parts_out );
free( p->parts_out ); free( p->xparts_out ); free( p->parts_out ); free( p->xparts_out );
p->parts_out = tp; p->xparts_out = txp; p->parts_out = tp; p->xparts_out = txp;
} }
......
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