15
#define armci_msg_brdcst__ armci_msg_bcast_lapi
21
void time_gop(double *test, int len)
27
for (i = 0; i < LOOP; i++) {
28
armci_msg_dgop(test, len, "+");
30
t = armci_timer() - t;
35
printf("Time per gop %f len=%d doubles\n", t, len);
41
void time_reduce(double *test, int len)
47
for (i = 0; i < LOOP; i++) {
48
armci_msg_reduce(test, len, "+", ARMCI_DOUBLE);
50
t = armci_timer() - t;
55
printf("Time per reduce %f len=%d doubles\n", t, len);
64
#define MAXLENG 256*1024
69
int ifrom = nproc - 1, lfrom = 1, dfrom = 1;
72
printf("Global test ... broadcast and reduction for int, long, double\n----------\n");
76
if (!(dtest = (double *) malloc((unsigned)(MAXLENG * sizeof(double))))) {
77
ARMCI_Error("TestGlobals: failed to allocated dtest", MAXLENG);
79
if (!(ltest = (long *) malloc((unsigned)(MAXLENG * sizeof(long))))) {
80
ARMCI_Error("TestGlobals: failed to allocated ltest", MAXLENG);
82
if (!(itest = (int *) malloc((unsigned)(MAXLENG * sizeof(int))))) {
83
ARMCI_Error("TestGlobals: failed to allocated itest", MAXLENG);
86
for (len = 1; len < MAXLENG; len *= 2) {
87
int ilen = len * sizeof(int);
88
int dlen = len * sizeof(double);
89
int llen = len * sizeof(long);
92
ifrom = (ifrom + 1) % nproc;
93
lfrom = (lfrom + 1) % nproc;
94
dfrom = (lfrom + 1) % nproc;
97
printf("%d:ifrom=%d lfrom=%d dfrom=%d\n", me, ifrom, lfrom, dfrom);
102
printf("Test length = %d ... ", len);
106
if (me == ifrom)for (i = 0; i < len; i++) {
109
else for (i = 0; i < len; i++) {
112
if (me == lfrom)for (i = 0; i < len; i++) {
115
else for (i = 0; i < len; i++) {
118
if (me == dfrom)for (i = 0; i < len; i++) {
119
dtest[i] = (double)i;
121
else for (i = 0; i < len; i++) {
126
armci_msg_brdcst(itest, ilen, ifrom);
127
armci_msg_brdcst(ltest, llen, lfrom);
128
armci_msg_brdcst(dtest, dlen, dfrom);
130
for (i = 0; i < len; i++) {
132
printf("int broadcast failed %d", itest[i]);
133
ARMCI_Error("int broadcast failed %d", itest[i]);
135
if (ltest[i] != (long)i) {
136
printf("long broadcast failed %ld", ltest[i]);
137
ARMCI_Error("long broadcast failed %ld", ltest[i]);
139
if (dtest[i] != (double)i) {
140
printf("double broadcast failed %f", dtest[i]);
141
ARMCI_Error("double broadcast failed %f", dtest[i]);
146
printf("broadcast OK ...");
150
/* Test global sum */
151
for (i = 0; i < len; i++) {
153
ltest[i] = (long) itest[i];
154
dtest[i] = (double) itest[i];
158
armci_msg_igop(itest, len, "+");
159
armci_msg_lgop(ltest, len, "+");
160
armci_msg_dgop(dtest, len, "+");
163
for (i = 0; i < len; i++) {
164
int iresult = i * nproc * (nproc - 1) / 2;
165
if (itest[i] != iresult || ltest[i] != (long)iresult ||
166
dtest[i] != (double) iresult) {
167
ARMCI_Error("TestGlobals: global sum failed", (int) i);
173
printf("global sums OK\n");
179
/* now we get timing data */
180
time_gop(dtest, MAXLENG);
181
time_reduce(dtest, MAXLENG);
183
free((char *) itest);
184
free((char *) ltest);
185
free((char *) dtest);
189
int main(int argc, char **argv)
192
armci_msg_init(&argc, &argv);
193
/* initialize ARMCI */
194
ARMCI_Init_args(&argc, &argv);
196
nproc = armci_msg_nproc();
201
"USAGE: 2 <= processes < %d\n", nproc);
203
armci_msg_finalize();
208
printf("Test of ARMCI Wrappers to Basic Message Passing Operations\n");
219
armci_msg_finalize();