3
* This is to test GA_Gather (is a one-sided operation)
4
* GA_Create -- used to create a global array using handles like 'g_A'
6
* GA_gather -- used to get data from different location
20
main(int argc, char **argv)
23
int g_A, dims[D]={5,10}, local_A[N], local_G[N], sub_array[N][D], **s_array=NULL;
26
MPI_Init(&argc, &argv);
28
MA_init(C_INT, 1000, 1000);
30
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
31
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
33
s_array=(int**)malloc(N*sizeof(int*));
36
s_array[i]=(int*)malloc(D*sizeof(int));
37
for(j=0; j<D; j++) s_array[i][j]=rand()%5;
41
for(j=0; j<D; j++)sub_array[i][j]=rand()%5;
43
* depends on the value of array ..we can generate the location values in randon
44
* we can also use the if-condition
49
for(j=0; j<D; j++)printf("%d ",s_array[i][j]);
56
for(j=0; j<D; j++)printf("%d ",sub_array[i][j]);
61
for(i=0; i<N; i++)printf("%d \n",local_A[i]=rand()%5+1);
63
g_A=NGA_Create(C_INT, D, dims, "array_A", NULL);
67
NGA_Scatter(g_A, local_A, s_array, N);
68
NGA_Gather(g_A, local_G, s_array, N);
72
for(i=0; i<N; i++)printf("%d \n",local_G[i]);
78
if(local_G[i]!=local_A[i]) printf("Error : \n");