root / synthbench / euroben-ports / base / C-MPI / mod2f / sizoff.c @ 0:839f52ef7657
History | View | Annotate | Download (1.2 kB)
1 |
#include "mpiargs.h" |
---|---|
2 |
|
3 |
void sizoff( int n1, int n2 ) |
4 |
// ---------------------------------------------------------------------
|
5 |
// --- Routine 'sizoff' determines the sizes and offsets of a 2-D
|
6 |
// array with dimensions 'n1' and 'n2' with respect to a
|
7 |
// distribution that is as even as possible on 'nodes' processors
|
8 |
// Then the offsets for each local array with respect to the global
|
9 |
// array are determined.
|
10 |
// Entry 'sizes[i][0]' giving the size for the i-th slice and 1-st
|
11 |
// dimension, etc.
|
12 |
// ---------------------------------------------------------------------
|
13 |
{ |
14 |
int i, k, non, nrest, rest;
|
15 |
// ---------------------------------------------------------------------
|
16 |
non = n1/nodes; |
17 |
rest = n1%nodes; |
18 |
nrest = nodes - rest - 1;
|
19 |
for( i = 0; i < nodes; i++ ) { |
20 |
sizes[i][0] = non;
|
21 |
if ( i > nrest ) sizes[i][0] = non + 1; |
22 |
} |
23 |
non = n2/nodes; |
24 |
rest = n2%nodes; |
25 |
nrest = nodes - rest - 1;
|
26 |
for( i = 0; i < nodes; i++ ) { |
27 |
sizes[i][1] = non;
|
28 |
if ( i > nrest ) sizes[i][1] = non + 1; |
29 |
} |
30 |
for( k = 0; k < 2; k++ ) { |
31 |
offset[0][k] = 0; |
32 |
for( i = 1; i < nodes; i++ ) { |
33 |
offset[i][k] = offset[i-1][k] + sizes[i-1][k]; |
34 |
} |
35 |
} |
36 |
} |