1 /*
2 * Test Program for GA
3 * This is to test GA_Zero_patch (is a collective operation)
4 * GA_Create -- used to create a global array using handles like 'g_A'
5 * GA_Duplicate --used to duplicate and generate one more global array.., handle 'g_A' to 'g_B'
6 * GA_Zero_patch -- is used to pass zero-value only certain patch of an array
7 */
8
9 #include<stdio.h>
10
11 #include"mpi.h"
12 #include"ga.h"
13 #include"macdecls.h"
14
15 #define DIM 2
16
main(int argc,char ** argv)17 int main(int argc, char **argv)
18 {
19 int rank, nprocs, i, j;
20 int g_A, g_B, local_A[5][5], local_B[5][5];
21 int dims[DIM]={5,5}, alo[DIM]={1,1}, ahi[DIM]={3,2}, blo[DIM]={1,1}, bhi[DIM]={2,3}, ld=5;
22 int value=5, val2=4;
23
24 MPI_Init(&argc, &argv);
25
26 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
27 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
28
29 MA_init(C_INT, 1000, 1000);
30
31 GA_Initialize();
32
33 g_A = NGA_Create(C_INT, DIM, dims, "array_A", NULL);
34 GA_Fill(g_A, &value);
35
36 g_B = GA_Duplicate(g_A, "array_B");
37 GA_Print(g_A);
38 GA_Fill(g_B, &val2);
39 GA_Sync();
40 NGA_Zero_patch(g_B, blo, bhi);
41 GA_Print(g_B);
42
43 NGA_Get(g_A, alo, ahi, local_A, &ld);
44 NGA_Get(g_B, blo, bhi, local_B, &ld);
45
46 if(rank==0)
47 {
48 for(i=0; i<3; i++)
49 {
50 for(j=0; j<2; j++) printf("%d ", local_A[i][j]);
51 printf("\n");
52 }
53 printf("\n");
54
55 for(i=0; i<2; i++)
56 {
57 for(j=0; j<3; j++) printf("%d ", local_B[i][j]);
58 printf("\n");
59 }
60
61 for(i=0; i<2; i++)
62 {
63 for(j=0; j<3; j++)
64 if( local_A[i][j]==local_B[i][j]) printf("ERROR : \n");
65 }
66
67 }
68
69
70 // The process is confirmed and verified by printing the array in OP-scr
71 /*
72 if(rank==0)
73 if(content(g_A) != content(g_B))printf("ERROE : \n");
74 */
75
76 GA_Sync();
77
78 if(rank == 1)
79 printf("Test Completed \n");
80 GA_Terminate();
81 MPI_Finalize();
82
83
84 }
85