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
armci_die2("int broadcast failed", i, itest[i]);
134
if (ltest[i] != (long)i) {
135
armci_die2("long broadcast failed", i, (int)ltest[i]);
137
if (dtest[i] != (double)i) {
138
armci_die2("double broadcast failed", i, (int)dtest[i]);
143
printf("broadcast OK ...");
147
/* Test global sum */
148
for (i = 0; i < len; i++) {
150
ltest[i] = (long) itest[i];
151
dtest[i] = (double) itest[i];
155
armci_msg_igop(itest, len, "+");
156
armci_msg_lgop(ltest, len, "+");
157
armci_msg_dgop(dtest, len, "+");
160
for (i = 0; i < len; i++) {
161
int iresult = i * nproc * (nproc - 1) / 2;
162
if (itest[i] != iresult || ltest[i] != (long)iresult ||
163
dtest[i] != (double) iresult) {
164
ARMCI_Error("TestGlobals: global sum failed", (int) i);
170
printf("global sums OK\n");
176
/* now we get timing data */
177
time_gop(dtest, MAXLENG);
178
time_reduce(dtest, MAXLENG);
180
free((char *) itest);
181
free((char *) ltest);
182
free((char *) dtest);
186
int main(int argc, char **argv)
189
/* initialize ARMCI */
190
ARMCI_Init_args(&argc, &argv);
192
nproc = armci_msg_nproc();
197
"USAGE: 2 <= processes < %d\n", nproc);
199
armci_msg_finalize();
204
printf("Test of ARMCI Wrappers to Basic Message Passing Operations\n");
215
armci_msg_finalize();