31 static inline int index(
int ndim,
const int *dims,
const int *
x)
34 for (
int i = 1; i < ndim; i++) {
35 idx = dims[i]*idx + x[i];
41 static inline bool advance_coords(
int ndim,
const int *dims,
int *
x)
44 for (
int i = ndim-1; i >= 0; i--) {
45 if (x[i] < dims[i]-1) {
59 static bool cached =
false;
60 static char hostname[128];
63 gethostname(hostname, 128);
72 static unsigned long int rand_seed = 137;
83 const double twoneg48 = 0.35527136788005009e-14;
84 const unsigned long int m = 25214903917, a = 11, mask = 281474976710655;
85 rand_seed = (m * rand_seed + a) & mask;
86 return (twoneg48 * rand_seed);
104 for (
int i=0; i<ndim; i++) {
105 topo->
dims[i] = dims[i];
113 for (
int i = 0; i < ndim; i++) {
118 int rank = rank_from_coords(x, map_data);
119 topo->
ranks[index(ndim, dims, x)] = rank;
120 for (
int i=0; i<ndim; i++) {
121 topo->
coords[rank][i] = x[i];
123 }
while (advance_coords(ndim, dims, x));
127 for (
int i = 0; i < ndim; i++) {
132 rand_seed = 17*my_rank + 137;
166 return topo->
coords[rank];
176 static inline int mod(
int a,
int b)
178 return ((a % b) + b) % b;
185 for (
int i = 0; i < topo->
ndim; i++) {
206 errorQuda(
"Default topology has not been declared");
262 manual_set_partition[dim] = 1;
268 return (manual_set_partition[dim] || (
comm_dim(dim) > 1));