Skip to content
Snippets Groups Projects
Commit 6d8c3195 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

On nodes with a number of cores that isn't a power of 2 an overrun

of the cpuid array was happening (COSMA4 has 24 cores per node).

There may be better solutions, one just refuses to accept invalid
ids using the existing calculation that runs cleanly to the next power of 2.


Former-commit-id: e698ada22eb1240257feb31505a55dfde386e105
parent 0e181ea7
No related branches found
No related tags found
No related merge requests found
......@@ -2011,11 +2011,17 @@ void engine_init ( struct engine *e , struct space *s , float dt , int nr_thread
cpuid[k] = k;
}
else {
/* Get next highest power of 2. */
int maxint = 1;
while ( maxint < nr_cores )
maxint *= 2;
cpuid[0] = 0;
k = 1;
for ( i = 1 ; i < nr_cores ; i *= 2 )
for ( j = nr_cores / i / 2 ; j < nr_cores ; j += nr_cores / i )
cpuid[k++] = j;
for ( i = 1 ; i < maxint ; i *= 2 )
for ( j = maxint / i / 2 ; j < maxint ; j += maxint / i )
if ( j < nr_cores && j != 0 )
cpuid[k++] = j;
#ifdef WITHMPI
printf( "engine_init: cpu map is [ " );
#else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment