1 /*
2 * Test Program for GA
3 * This is to test GA_Transpose (is a collective operation)
4 * GA_Create -- used to create a global array using handles like 'g_A'
5 * _Transpose -- used to transpose the whole array
6 *
7 * not completed ---
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 #define SIZE 5
18
main(int argc,char ** argv)19 int main(int argc, char **argv)
20 {
21 int rank, nprocs, i, j;
22 int g_A, g_B, value=5, local_GA[SIZE][SIZE], local_A[SIZE][SIZE], local_B[SIZE][SIZE];
23 int dims[DIM]={SIZE,SIZE}, dims2[DIM], lo[DIM]={0,0}, hi[DIM]={4,4}, ld=5;
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(C_INT, DIM, dims, "array_B", NULL);
36
37 for(i=0; i<SIZE; i++)
38 for(j=0; j<SIZE; j++) local_GA[i][j]=rand()%10;
39
40 NGA_Put(g_A, lo, hi, local_GA, &ld);
41 GA_Transpose(g_A, g_B);
42 GA_Print(g_A);
43 GA_Print(g_B);
44
45 if(rank==0)
46 {
47 NGA_Get(g_A, lo, hi, local_A, &ld);
48 NGA_Get(g_B, lo, hi, local_B, &ld);
49
50 for(i=1; i<3; i++)
51 {
52 for(j=1; j<3; j++)
53 printf("%d ", local_B[i][j]);
54 printf("\n");
55 }
56
57 printf("\n");
58 for(i=1; i<3; i++)
59 {
60 for(j=1; j<3; j++)
61 printf("%d ", local_A[i][j]);
62 printf("\n");
63 }
64
65 printf("\n");
66 for(i=1; i<3; i++)
67 {
68 for(j=1; j<3; j++)
69 {
70 if(local_B[j][i]!=local_A[i][j])
71 printf("ERROR : in passing values \n");
72 }
73 }
74 }
75 GA_Sync();
76 if(rank == 1)
77 printf("Test Completed \n");
78
79 GA_Terminate();
80 MPI_Finalize();
81 }
82