3
* This is to test GA_Create_irreg (is a collective operation)
4
* GA_Create -- used to create a global array of regular size
5
* GA_Create_IRREG -- used to create G_array of irregular size -- helps user to define the distribution
6
* Here used GA_Inquire to verify that g_A hanle returns the right values of created_array
20
irregular_array1(int rank)
24
int dims[DIM]={5,10}, dims2[DIM], ndim, type, value=5, block[DIM]={2,3}, map[5]={0,2,0,4,6}, val=7;
25
int n_block[DIM], block_dims[DIM], i;
27
g_A = NGA_Create(C_INT, DIM, dims, "array_A", NULL);
28
g_B = NGA_Create_irreg(C_INT, DIM, dims, "array_B", block, map);
37
NGA_Inquire(g_A, &type, &ndim, dims2);
38
//printf(" %d -- %d,,\n", type, ndim);
41
GA_Get_block_info(g_B, n_block, block_dims);
43
printf(" %d: %d ___ %d --- \n", rank, n_block[i], block_dims[i]);
50
irregular_array2(int rank)
54
int dims[DIM]={GSIZE,GSIZE}, dims2[DIM], block[DIM]={3,2}, map[5]={0,2,6,0,4}, val=7;
55
int n_block[DIM], block_dims[DIM], i;
57
g_A = NGA_Create(C_INT, DIM, dims, "array_A", NULL);
58
g_B = NGA_Create_irreg(C_INT, DIM, dims, "array_B", block, map);
65
GA_Get_block_info(g_B, n_block, block_dims);
67
printf(" %d: %d ___ %d --- \n", rank, n_block[i], block_dims[i]);
74
/* In these function the values of blocks and maps are auto-generated number based on number of processes we use */
76
auto_number1(int rank, int nprocs)
80
int dims[DIM]={GSIZE, GSIZE}, dims2[DIM], block[DIM], *map=NULL, val=7;
81
int n_block[DIM], block_dims[DIM], b_temp, i;
88
}while(nprocs/b1>=GSIZE);
93
map=(int*)malloc(nprocs*sizeof(int));
98
for(i=b1; i<(b2+b1); i++)
103
for(i=0; i<(b1+b2); i++)
104
printf("map[%d] - %d\n", i, map[i]);
106
printf("BLOCK[%d] - %d\n", i, block[i]);
109
g_B = NGA_Create_irreg(C_INT, DIM, dims, "array_B", block, map);
117
GA_Get_block_info(g_B, n_block, block_dims);
119
printf(" %d: %d --- %d ... %d\n", rank, n_block[i], block_dims[i], b_temp);
124
auto_number2(int rank, int nprocs)
128
int dims[DIM]={GSIZE, GSIZE}, dims2[DIM], block[DIM], *map=NULL, val=7;
129
int n_block[DIM], block_dims[DIM], b_temp, i;
137
}while(nprocs/b2>=GSIZE);
142
map=(int*)malloc(nprocs*sizeof(int));
147
for(i=b1; i<(b2+b1); i++)
152
for(i=0; i<(b1+b2); i++)
153
printf("map[%d] - %d\n", i, map[i]);
155
printf("BLOCK[%d] - %d\n", i, block[i]);
158
g_B = NGA_Create_irreg(C_INT, DIM, dims, "array_B", block, map);
166
GA_Get_block_info(g_B, n_block, block_dims);
168
printf(" %d: %d --- %d ... %d\n", rank, n_block[i], block_dims[i], b_temp);
173
main(int argc, char **argv)
177
MPI_Init(&argc, &argv);
179
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
180
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
182
MA_init(C_INT, 1000, 1000);
186
//irregular_array1(rank);
187
// irregular_array2(rank);
189
// auto_number1(rank, nprocs);
190
auto_number2(rank, nprocs);
193
printf("Test Completed \n");