1 #if HAVE_CONFIG_H
2 #   include "config.h"
3 #endif
4 
5 #if HAVE_STDIO_H
6 #   include <stdio.h>
7 #endif
8 #if HAVE_MATH_H
9 #   include <math.h>
10 #endif
11 #if HAVE_STDLIB_H
12 #   include <stdlib.h>
13 #endif
14 #if HAVE_STRING_H
15 #   include <string.h>
16 #endif
17 
18 #define FNAME      "/scratch/da.try"
19 #define FNAME_ALT  "/tmp/da.try"
20 #define FNAME1     "/scratch/da1.try"
21 #define FNAME1_ALT "/tmp/da1.try"
22 #define FNAME2     "/scratch/da2.try"
23 #define FNAME2_ALT "/tmp/da2.try"
24 
25 #include "dra.h"
26 #include "ga.h"
27 #include "macdecls.h"
28 #include "mp3.h"
29 
30 #ifndef MAXDIM
31 #   define MAXDIM GA_MAX_DIM
32 #endif
33 #ifndef TRUE
34 #   define TRUE (Logical)1
35 #endif
36 #ifndef FALSE
37 #   define FALSE (Logical)0
38 #endif
39 
40 /* If USER_CONFIG set to:
41  *   0: Use default configuration
42  *   1: Number of files is 1, number of I/O procs equals
43  *      the number of nodes
44  *   2: Number of files and number of I/O procs equals
45  *      the number of nodes
46  *   3: Number of files and number of I/O procs equals 1
47  * These configurations only apply if files are not located
48  * on local scratch disk. For local scratch, system defaults
49  * to 1 I/O proc per node and 1 file per node. Note that
50  * USER_CONFIG=1 will only work if system has parallel I/O.
51  *
52  * Memory and Disk Usage:
53  * The aggregate memory required to run this test is approximately
54  * 2*SIZE**NDIM*sizeof(double) bytes. The amount of disk space
55  * required is approximately 1+2**NDIM times this amount.
56  */
57 #define USER_CONFIG 0
58 #define TEST_TRANSPOSE 0
59 
60 #define NDIM 3
61 #define SIZE 250
62 
63 /*
64 #define NDIM 2
65 #define SIZE 4000
66 
67 #define NDIM 1
68 #define SIZE 16000000
69 */
70 
71 #define SWITCH 0
72 /*#define MAXDIM 7*/
73 /*#define TRUE (logical)1*/
74 /*#define FALSE (logical)0*/
75 
76 #define MULTFILES 0
77 
78 #  define USEMULTFILES 0
79 
80 #define IA 16807
81 #define IM 2147483647
82 #define AM (1.0/IM)
83 #define IQ 127773
84 #define IR 2836
85 #define MASK 123459876
86 
87 
filename_check(char * result,const char * fname,const char * fname_alt)88 void filename_check(char *result, const char *fname, const char *fname_alt)
89 {
90     FILE *fd;
91     strcpy(result, fname);
92     if (! (fd = fopen(result, "w"))) {
93         strcpy(result, fname_alt);
94         if (! (fd = fopen(result, "w"))) {
95             GA_Error("Could not open file", 0);
96         }
97     }
98     fclose(fd);
99 }
100 
101 
ran0(long * idum)102 float ran0(long *idum)
103 {
104     long k;
105     float ans;
106 
107     *idum ^= MASK;
108     k=(*idum)/IQ;
109     *idum = IA*(*idum-k*IQ)-IR*k;
110     if (*idum < 0) *idum += IM;
111     ans=AM*(*idum);
112     *idum ^= MASK;
113     return ans;
114 }
115 
116 
fill_random(double * a,int isize)117 void fill_random(double *a, int isize)
118 {
119     long *idum;
120     long i, j;
121 
122     j = 38282;
123     idum = &j;
124     a[0] = (double)ran0(idum);
125     for (i=0; i<(long)isize; i++) {
126         a[i] = (double)(10000.0*ran0(idum));
127     }
128 }
129 
130 
test_io_dbl()131 void test_io_dbl()
132 {
133     int ndim = NDIM;
134     double err, tt0, tt1, mbytes;
135     int g_a, g_b, d_a, d_b;
136 #if TEST_TRANSPOSE
137     int g_c, g_d, d_c;
138 #endif
139     int i, req, loop;
140     dra_size_t dlo[MAXDIM],dhi[MAXDIM];
141     dra_size_t n, m;
142     dra_size_t ddims[MAXDIM], reqdims[MAXDIM];
143     int glo[MAXDIM],ghi[MAXDIM];
144     int dims[MAXDIM];
145     int me, nproc, isize, numfiles, nioprocs;
146     double plus, minus;
147     double *index;
148     int ld[MAXDIM], chunk[MAXDIM];
149 #if USEMULTFILES
150     int ilen;
151 #endif
152     char filename[80], filename1[80];
153 
154     n = SIZE;
155     m = 2*SIZE;
156 
157     loop  = 30;
158     req = -1;
159     nproc = GA_Nnodes();
160     me    = GA_Nodeid();
161     nioprocs = GA_Cluster_nnodes();
162     numfiles = nioprocs;
163 
164     if (me == 0) {
165         printf("Creating temporary global arrays %ld",(long)n);
166         for (i=1; i<ndim; i++) {
167             printf(" x %ld",(long)n);
168         }
169         printf("\n");
170     }
171     if (me == 0) fflush(stdout);
172     GA_Sync();
173     for (i=0; i<ndim; i++) {
174         dims[i] = n;
175         chunk[i] = 1;
176     }
177 
178     g_a = NGA_Create(MT_DBL, ndim, dims, "a", chunk);
179     if (!g_a) GA_Error("NGA_Create failed: a", 0);
180     g_b = NGA_Create(MT_DBL, ndim, dims, "b", chunk);
181     if (!g_b) GA_Error("NGA_Create failed: b", 0);
182     if (me == 0) printf("done\n");
183     if (me == 0) fflush(stdout);
184 
185     /*     initialize g_a, g_b with random values
186            ... use ga_access to avoid allocating local buffers for ga_put */
187 
188     GA_Sync();
189     NGA_Distribution(g_a, me, glo, ghi);
190     NGA_Access(g_a, glo, ghi, &index, ld);
191     isize = 1;
192     for (i=0; i<ndim; i++) isize *= (ghi[i]-glo[i]+1);
193     fill_random(index, isize);
194     GA_Sync();
195     GA_Zero(g_b);
196 
197     /*.......................................................................*/
198 #if SWITCH
199     if (me == 0) {
200         printf("Creating Disk array %d",m);
201         for (i=1; i<ndim; i++) {
202             printf(" x %d",m);
203         }
204         printf("\n");
205     }
206     if (me == 0) fflush(stdout);
207     for (i=0; i<ndim; i++) {
208         ddims[i] = m;
209         reqdims[i] = n;
210     }
211     GA_Sync();
212     filename_check(filename1, FNAME1, FNAME1_ALT);
213     if (NDRA_Create(MT_DBL, ndim, ddims, "B", filename1, DRA_RW,
214                 reqdims, &d_b) != 0) {
215         GA_Error("NDRA_Create failed(d_b): ",0);
216     }
217 
218     if (me == 0) printf("non alligned blocking write\n");
219     if (me == 0) fflush(stdout);
220 
221     for (i=0; i<ndim; i++) {
222         glo[i] = 0;
223         ghi[i] = n-1;
224         dlo[i] = 1;
225         dhi[i] = n;
226     }
227     GA_Sync();
228     tt0 = MP_TIMER();
229     if (NDRA_Write_section(FALSE, g_a, glo, ghi,
230                 d_b, dlo, dhi, &req) != 0)
231         GA_Error("ndra_write_section failed:",0);
232 
233     if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed(d_b): ",req);
234     tt1 = MP_TIMER() - tt0;
235     GA_Dgop(&tt1,1,"+");
236     tt1 = tt1/((double)nproc);
237     mbytes = 1.e-6*(double)(pow(n,ndim)*sizeof(double));
238     if (me == 0) {
239         printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
240                 mbytes,tt1,mbytes/tt1);
241     }
242 
243     if (DRA_Close(d_b) != 0) GA_Error("DRA_Close failed(d_b): ",d_b);
244     tt1 = MP_TIMER() - tt0;
245     GA_Dgop(&tt1,1,"+");
246     tt1 = tt1/((double)nproc);
247     if (me == 0) {
248         printf("Time including DRA_Close\n");
249         printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
250                 mbytes,tt1,mbytes/tt1);
251     }
252 
253     if (me == 0) printf("\n");
254     if (me == 0) printf("disk array closed\n");
255     if (me == 0) fflush(stdout);
256 
257     GA_Sync();
258     if (me == 0) {
259         printf("Creating Disk array %d",n);
260         for (i=1; i<ndim; i++) {
261             printf(" x %d",n);
262         }
263         printf("\n");
264     }
265     for (i=0; i<ndim; i++) {
266         ddims[i] = n;
267         reqdims[i] = n;
268     }
269     filename_check(filename, FNAME, FNAME_ALT);
270     if (NDRA_Create(MT_DBL, ndim, ddims, "A", filename, DRA_RW,
271                 reqdims, &d_a) != 0)
272     {
273         GA_Error("NDRA_Create failed(d_a): ",0);
274     }
275     if (me == 0) printf("alligned blocking write\n");
276     fflush(stdout);
277     tt0 = MP_TIMER();
278     if (NDRA_Write(g_a, d_a, &req) != 0) GA_Error("NDRA_Write failed(d_a):",0);
279     if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed(d_a): ",req);
280     tt1 = MP_TIMER() - tt0;
281     GA_Dgop(&tt1,1,"+");
282     tt1 = tt1/((double)nproc);
283     mbytes = 1.e-6 * (double)(pow(n,ndim)*sizeof(double));
284     if (me == 0) {
285         printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
286                 mbytes,tt1,mbytes/tt1);
287     }
288 
289     if (DRA_Close(d_a) != 0) GA_Error("DRA_Close failed(d_a): ",d_a);
290     tt1 = MP_TIMER() - tt0;
291     GA_Dgop(&tt1,1,"+");
292     tt1 = tt1/((double)nproc);
293     if (me == 0) {
294         printf("Time including DRA_Close\n");
295         printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
296                 mbytes,tt1,mbytes/tt1);
297     }
298 
299     if (me == 0) printf("\n");
300     if (me == 0) printf("disk array closed\n");
301     if (me == 0) fflush(stdout);
302 #else /* SWITCH */
303     if (me == 0) {
304         printf("Creating Disk array %ld",(long)n);
305         for (i=1; i<ndim; i++) {
306             printf(" x %ld",(long)n);
307         }
308         printf("\n");
309     }
310     if (me == 0) fflush(stdout);
311     for (i=0; i<ndim; i++) {
312         ddims[i] = n;
313         reqdims[i] = n;
314     }
315     GA_Sync();
316     filename_check(filename, FNAME, FNAME_ALT);
317     if (NDRA_Create(MT_DBL, ndim, ddims, "A", filename, DRA_RW,
318                 reqdims, &d_a) != 0) {
319         GA_Error("NDRA_Create failed(d_a): ",0);
320     }
321     if (me == 0) printf("alligned blocking write\n");
322     fflush(stdout);
323     tt0 = MP_TIMER();
324     if (NDRA_Write(g_a, d_a, &req) != 0) GA_Error("NDRA_Write failed(d_a):",0);
325     if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed(d_a): ",req);
326     tt1 = MP_TIMER() - tt0;
327     GA_Dgop(&tt1,1,"+");
328     tt1 = tt1/((double)nproc);
329     mbytes = 1.e-6 * (double)(pow(n,ndim)*sizeof(double));
330     if (me == 0) {
331         printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
332                 mbytes,tt1,mbytes/tt1);
333     }
334 
335     if (DRA_Close(d_a) != 0) GA_Error("DRA_Close failed(d_a): ",d_a);
336     tt1 = MP_TIMER() - tt0;
337     GA_Dgop(&tt1,1,"+");
338     tt1 = tt1/((double)nproc);
339     if (me == 0) {
340         printf("Time including DRA_Close\n");
341         printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
342                 mbytes,tt1,mbytes/tt1);
343     }
344 
345     if (me == 0) printf("\n");
346     if (me == 0) printf("disk array closed\n");
347     if (me == 0) fflush(stdout);
348     /*.......................................................................*/
349 
350     if (me == 0) {
351         printf("Creating Disk array %ld",(long)m);
352         for (i=1; i<ndim; i++) {
353             printf(" x %ld",(long)m);
354         }
355         printf("\n");
356     }
357     for (i=0; i<ndim; i++) {
358         ddims[i] = m;
359         reqdims[i] = n;
360     }
361     filename_check(filename1, FNAME1, FNAME1_ALT);
362     if (NDRA_Create(MT_DBL, ndim, ddims, "B", filename1, DRA_RW,
363                 reqdims, &d_b) != 0) {
364         GA_Error("NDRA_Create failed(d_b): ",0);
365     }
366 
367     if (me == 0) printf("non alligned blocking write\n");
368     if (me == 0) fflush(stdout);
369 
370     for (i=0; i<ndim; i++) {
371         glo[i] = 0;
372         ghi[i] = n-1;
373         dlo[i] = 1;
374         dhi[i] = n;
375     }
376     tt0 = MP_TIMER();
377     if (NDRA_Write_section(FALSE, g_a, glo, ghi,
378                 d_b, dlo, dhi, &req) != 0)
379         GA_Error("ndra_write_section failed:",0);
380 
381     if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed(d_b): ",req);
382     tt1 = MP_TIMER() - tt0;
383     GA_Dgop(&tt1,1,"+");
384     tt1 = tt1/((double)nproc);
385     mbytes = 1.e-6*(double)(pow(n,ndim)*sizeof(double));
386     if (me == 0) {
387         printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
388                 mbytes,tt1,mbytes/tt1);
389     }
390 
391     if (DRA_Close(d_b) != 0) GA_Error("DRA_Close failed(d_b): ",d_b);
392     tt1 = MP_TIMER() - tt0;
393     GA_Dgop(&tt1,1,"+");
394     tt1 = tt1/((double)nproc);
395     if (me == 0) {
396         printf("Time including DRA_Close\n");
397         printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
398                 mbytes,tt1,mbytes/tt1);
399     }
400 
401     if (me == 0) printf("\n");
402     if (me == 0) printf("disk array closed\n");
403     if (me == 0) fflush(stdout);
404 #endif /* SWITCH */
405     /*.......................................................................*/
406 
407 #if SWITCH
408     if (me == 0) printf("\n");
409     if (me == 0) printf("opening disk array\n");
410     if (DRA_Open(filename1, DRA_R, &d_b) != 0) GA_Error("DRA_Open failed",0);
411     if (me == 0) printf("non alligned blocking read\n");
412     if (me == 0) fflush(stdout);
413     tt0 = MP_TIMER();
414     if (NDRA_Read_section(FALSE, g_b, glo, ghi, d_b, dlo, dhi, &req) != 0)
415         GA_Error("NDRA_Read_section failed:",0);
416     if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
417     tt1 = MP_TIMER() - tt0;
418     GA_Dgop(&tt1,1,"+");
419     tt1 = tt1/((double)nproc);
420     if (me == 0) {
421         printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
422                 mbytes,tt1,mbytes/tt1);
423     }
424     plus = 1.0;
425     minus = -1.0;
426     GA_Add(&plus, g_a, &minus, g_b, g_b);
427     err = GA_Ddot(g_b, g_b);
428     if (err != 0) {
429         if (me == 0) printf("BTW, we have error = %f\n",err);
430     } else {
431         if (me == 0) printf("OK\n");
432     }
433     if (DRA_Delete(d_b) != 0) GA_Error("DRA_Delete failed",0);
434     /*.......................................................................*/
435     if (me == 0) printf("\n");
436     if (me == 0) printf("opening disk array\n");
437     if (DRA_Open(filename, DRA_R, &d_a) != 0) GA_Error("DRA_Open failed",0);
438     if (me == 0) printf("alligned blocking read\n");
439     if (me == 0) fflush(stdout);
440     tt0 = MP_TIMER();
441     if (NDRA_Read(g_b, d_a, &req) != 0) GA_Error("NDRA_Read failed:",0);
442     if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
443     tt1 = MP_TIMER() - tt0;
444     GA_Dgop(&tt1,1,"+");
445     tt1 = tt1/((double)nproc);
446     if (me == 0) {
447         printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
448                 mbytes,tt1,mbytes/tt1);
449     }
450     GA_Add(&plus, g_a, &minus, g_b, g_b);
451     err = GA_Ddot(g_b, g_b);
452     if (err != 0) {
453         if (me == 0) printf("BTW, we have error = %f\n",err);
454     } else {
455         if (me == 0) printf("OK\n");
456     }
457     if (DRA_Delete(d_a) != 0) GA_Error("DRA_Delete failed",0);
458 #else /* SWITCH */
459     if (me == 0) printf("\n");
460     if (me == 0) printf("opening disk array\n");
461     if (DRA_Open(filename, DRA_R, &d_a) != 0) GA_Error("DRA_Open failed",0);
462     if (me == 0) printf("alligned blocking read\n");
463     if (me == 0) fflush(stdout);
464     tt0 = MP_TIMER();
465     if (NDRA_Read(g_b, d_a, &req) != 0) GA_Error("NDRA_Read failed:",0);
466     if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
467     tt1 = MP_TIMER() - tt0;
468     GA_Dgop(&tt1,1,"+");
469     tt1 = tt1/((double)nproc);
470     if (me == 0) {
471         printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
472                 mbytes,tt1,mbytes/tt1);
473     }
474     plus = 1.0;
475     minus = -1.0;
476     GA_Add(&plus, g_a, &minus, g_b, g_b);
477     err = GA_Ddot(g_b, g_b);
478     if (err != 0) {
479         if (me == 0) printf("BTW, we have error = %f\n",err);
480     } else {
481         if (me == 0) printf("OK\n");
482     }
483     if (DRA_Delete(d_a) != 0) GA_Error("DRA_Delete failed",0);
484     /*.......................................................................*/
485 
486     if (me == 0) printf("\n");
487     if (me == 0) printf("opening disk array\n");
488     if (DRA_Open(filename1, DRA_R, &d_b) != 0) GA_Error("DRA_Open failed",0);
489     if (me == 0) printf("non alligned blocking read\n");
490     if (me == 0) fflush(stdout);
491     tt0 = MP_TIMER();
492     if (NDRA_Read_section(FALSE, g_b, glo, ghi, d_b, dlo, dhi, &req) != 0)
493         GA_Error("NDRA_Read_section failed:",0);
494     if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
495     tt1 = MP_TIMER() - tt0;
496     GA_Dgop(&tt1,1,"+");
497     tt1 = tt1/((double)nproc);
498     if (me == 0) {
499         printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
500                 mbytes,tt1,mbytes/tt1);
501     }
502     GA_Add(&plus, g_a, &minus, g_b, g_b);
503     err = GA_Ddot(g_b, g_b);
504     if (err != 0) {
505         if (me == 0) printf("BTW, we have error = %f\n",err);
506     } else {
507         if (me == 0) printf("OK\n");
508     }
509     if (DRA_Delete(d_b) != 0) GA_Error("DRA_Delete failed",0);
510 #endif /* SWITCH */
511     /*.......................................................................*/
512     GA_Destroy(g_a);
513     GA_Destroy(g_b);
514     /*.......................................................................*/
515 #if TEST_TRANSPOSE
516     /* Test transpose function for DRAs */
517     dims[0] = n;
518     for (i=1; i<ndim; i++) dims[i] = n/2;
519     for (i=0; i<ndim; i++) chunk[i] = 1;
520     if (me == 0) printf("Creating asymmetric arrays to test transpose\n\n");
521     g_c = NGA_Create(MT_DBL, ndim, dims, "c", chunk);
522     if (!g_c) GA_Error("NGA_Create failed: c", 0);
523     g_d = NGA_Create(MT_DBL, ndim, dims, "d", chunk);
524     if (!g_d) GA_Error("NGA_Create failed: d", 0);
525     if (me == 0) printf("done\n");
526     if (me == 0) fflush(stdout);
527 
528     /*     initialize g_a, g_b with random values
529            ... use ga_access to avoid allocating local buffers for ga_put */
530 
531     GA_Sync();
532     NGA_Distribution(g_c, me, glo, ghi);
533     NGA_Access(g_c, glo, ghi, &index, ld);
534     isize = 1;
535     for (i=0; i<ndim; i++) isize *= (ghi[i]-glo[i]+1);
536     fill_random(index, isize);
537     GA_Sync();
538     GA_Zero(g_c);
539     GA_Copy(g_c,g_d);
540 
541     for (i=0; i<ndim; i++) {
542         ddims[i] = m;
543         reqdims[i] = n;
544     }
545     filename_check(filename2, FNAME2, FNAME2_ALT);
546     if (me == 0) printf("Creating DRA for transpose test\n");
547     if (NDRA_Create(MT_DBL, ndim, ddims, "C", filename2, DRA_RW,
548                 reqdims, &d_c) != 0) {
549         GA_Error("NDRA_Create failed(d_c): ",0);
550     }
551     if (me == 0) printf("done\n");
552     if (me == 0) fflush(stdout);
553     GA_Sync();
554     for (i=0; i<ndim-1; i++) {
555         dlo[i] = 1;
556         dhi[i] = n/2;
557     }
558     dlo[ndim-1] = 1;
559     dhi[ndim-1] = n;
560     glo[0] = 0;
561     ghi[0] = n-1;
562     for (i=1; i<ndim; i++) {
563         glo[i] = 0;
564         ghi[i] = n/2-1;
565     }
566     if (me == 0) printf("non-aligned blocking write with transpose\n");
567     tt0 = MP_TIMER();
568     if (NDRA_Write_section(TRUE,g_c,glo,ghi,d_c,dlo,dhi,&req) != 0)
569         GA_Error("NDRA_Write_section (transpose) failed: ",0);
570     if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
571     isize = 1;
572     for (i=0; i<ndim; i++) isize *= (ghi[i]-glo[i]+1);
573     mbytes = 1.e-6 * (double)(isize*sizeof(double));
574     tt1 = MP_TIMER() - tt0;
575     GA_Dgop(&tt1,1,"+");
576     tt1 = tt1/((double)nproc);
577     if (me == 0) {
578         printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
579                 mbytes,tt1,mbytes/tt1);
580     }
581     if (DRA_Close(d_c) != 0) GA_Error("DRA_Close failed(d_c): ",d_c);
582     if (me == 0) printf("\n");
583     if (me == 0) printf("disk array closed\n");
584     if (me == 0) fflush(stdout);
585 
586     if (me == 0) printf("\n");
587     if (me == 0) printf("opening disk array\n");
588     if (DRA_Open(filename2, DRA_R, &d_c) != 0) GA_Error("DRA_Open failed",0);
589 
590     GA_Zero(g_c);
591     if (me == 0) printf("non-aligned blocking read with transpose\n");
592     tt0 = MP_TIMER();
593     if (NDRA_Read_section(TRUE,g_c,glo,ghi,d_c,dlo,dhi,&req) != 0)
594         GA_Error("NDRA_Read_section (transpose) failed: ",0);
595     if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
596     tt1 = MP_TIMER() - tt0;
597     GA_Dgop(&tt1,1,"+");
598     tt1 = tt1/((double)nproc);
599     if (me == 0) {
600         printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
601                 mbytes,tt1,mbytes/tt1);
602     }
603     GA_Add(&plus, g_c, &minus, g_d, g_d);
604     err = GA_Ddot(g_d, g_d);
605     if (err != 0) {
606         if (me == 0) printf("BTW, we have error = %f\n",err);
607     } else {
608         if (me == 0) printf("OK\n");
609     }
610     if (DRA_Delete(d_c) != 0) GA_Error("DRA_Delete failed",0);
611     /*.......................................................................*/
612     GA_Destroy(g_c);
613     GA_Destroy(g_d);
614 #endif /* TEST_TRANSPOSE */
615 }
616 
617 
main(int argc,char ** argv)618 int main(int argc, char **argv)
619 {
620     int status, me;
621     int max_arrays = 10;
622     double max_sz = 1e8, max_disk = 1e10, max_mem = 1e6;
623     int numfiles, numioprocs;
624 #if defined(IBM)
625     int stack = 9000000, heap = 4000000;
626 #else
627     int stack = 12000000, heap = 8000000;
628 #endif
629 
630     MP_INIT(argc,argv);
631     GA_Initialize();
632     if (!GA_Uses_ma()) {
633         if (GA_Nodeid() == 0) printf("GA not using MA\n");
634         stack = 100000;
635         heap = 2*sizeof(double)*pow(SIZE,NDIM)/GA_Nnodes()+10000000;
636     }
637 
638     me = GA_Nodeid();
639     if (MA_init(MT_F_DBL, stack, heap) ) {
640         if (DRA_Init(max_arrays, max_sz, max_disk, max_mem) != 0)
641             GA_Error("DRA_Init failed: ",0);
642         if (USER_CONFIG == 0) {
643             numfiles = -1;
644             numioprocs = -1;
645         } else if (USER_CONFIG == 1) {
646             numfiles = 1;
647             numioprocs = GA_Cluster_nnodes();
648         } else if (USER_CONFIG == 2) {
649             numfiles = GA_Cluster_nnodes();
650             numioprocs = GA_Cluster_nnodes();
651         } else {
652             numfiles = 1;
653             numioprocs = 1;
654         }
655         if (me==0) {
656             printf("Disk resident arrays configured as:\n");
657             printf("    Number of files: %d\n",numfiles);
658             printf("    Number of I/O processors: %d\n",numioprocs);
659         }
660         DRA_Set_default_config(numfiles,numioprocs);
661         if (me == 0) printf("\n");
662         if (me == 0) printf("TESTING PERFORMANCE OF DISK ARRAYS\n");
663         if (me == 0) printf("\n");
664         test_io_dbl();
665         status = DRA_Terminate();
666         GA_Terminate();
667     } else {
668         printf("MA_init failed\n");
669     }
670     if(me == 0) printf("all done ...\n");
671     MP_FINALIZE();
672     return 0;
673 }
674