1 /*
2  * Test Program for GA
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  *
7  * GA_Get_Block_info -- used to obtain info (like number of blocks and block dimension) about the global array
8  */
9 
10 #include<stdio.h>
11 
12 #include"mpi.h"
13 #include"ga.h"
14 #include"macdecls.h"
15 
16 #define DIM 2
17 
main(int argc,char ** argv)18 int main(int argc, char **argv)
19 {
20   int rank, nprocs, i;
21   int g_A, g_B;
22   int dims[DIM]={5,10}, dims2[DIM], ndim, type, value=5, block[DIM]={2,3}, map[5]={0,2,0,4,6}, val=7;
23   int n_block[DIM], block_dims[DIM];
24 
25   MPI_Init(&argc, &argv);
26 
27   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
28   MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
29 
30   MA_init(C_INT, 1000, 1000);
31 
32   GA_Initialize();
33 
34   g_A = NGA_Create(C_INT, DIM, dims, "array_A", NULL);
35   g_B = NGA_Create_irreg(C_INT, DIM, dims, "array_B", block, map);
36 
37   GA_Fill(g_A, &value);
38   GA_Print(g_A);
39 
40   GA_Fill(g_B, &val);
41   GA_Print(g_B);
42   GA_Sync();
43 
44   GA_Get_block_info(g_B, n_block, block_dims);
45   for(i=0; i<DIM; i++)
46     printf(" %d:  %d ___ %d --- \n", rank, n_block[i], block_dims[i]);
47 
48   if(rank == 0)
49     printf("Test Completed \n");
50   GA_Terminate();
51   MPI_Finalize();
52 }
53