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"
31
# define MAXDIM GA_MAX_DIM
34
# define TRUE (Logical)1
37
# define FALSE (Logical)0
40
/* If USER_CONFIG set to:
41
* 0: Use default configuration
42
* 1: Number of files is 1, number of I/O procs equals
44
* 2: Number of files and number of I/O procs equals
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.
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.
58
#define TEST_TRANSPOSE 0
73
/*#define TRUE (logical)1*/
74
/*#define FALSE (logical)0*/
80
# define USEMULTFILES 1
83
# define USEMULTFILES 0
91
#define MASK 123459876
94
void filename_check(char *result, const char *fname, const char *fname_alt)
97
strcpy(result, fname);
98
if (! (fd = fopen(result, "w"))) {
99
strcpy(result, fname_alt);
100
if (! (fd = fopen(result, "w"))) {
101
GA_Error("Could not open file", 0);
108
float ran0(long *idum)
115
*idum = IA*(*idum-k*IQ)-IR*k;
116
if (*idum < 0) *idum += IM;
123
void fill_random(double *a, int isize)
130
a[0] = (double)ran0(idum);
131
for (i=0; i<(long)isize; i++) {
132
a[i] = (double)(10000.0*ran0(idum));
140
double err, tt0, tt1, mbytes;
141
int g_a, g_b, d_a, d_b;
146
dra_size_t dlo[MAXDIM],dhi[MAXDIM];
148
dra_size_t ddims[MAXDIM], reqdims[MAXDIM];
149
int glo[MAXDIM],ghi[MAXDIM];
151
int me, nproc, isize, numfiles, nioprocs;
154
int ld[MAXDIM], chunk[MAXDIM];
158
char filename[80], filename1[80];
167
nioprocs = GA_Cluster_nnodes();
171
printf("Creating temporary global arrays %ld",(long)n);
172
for (i=1; i<ndim; i++) {
173
printf(" x %ld",(long)n);
177
if (me == 0) fflush(stdout);
179
for (i=0; i<ndim; i++) {
184
g_a = NGA_Create(MT_DBL, ndim, dims, "a", chunk);
185
if (!g_a) GA_Error("NGA_Create failed: a", 0);
186
g_b = NGA_Create(MT_DBL, ndim, dims, "b", chunk);
187
if (!g_b) GA_Error("NGA_Create failed: b", 0);
188
if (me == 0) printf("done\n");
189
if (me == 0) fflush(stdout);
191
/* initialize g_a, g_b with random values
192
... use ga_access to avoid allocating local buffers for ga_put */
195
NGA_Distribution(g_a, me, glo, ghi);
196
NGA_Access(g_a, glo, ghi, &index, ld);
198
for (i=0; i<ndim; i++) isize *= (ghi[i]-glo[i]+1);
199
fill_random(index, isize);
203
/*.......................................................................*/
206
printf("Creating Disk array %d",m);
207
for (i=1; i<ndim; i++) {
212
if (me == 0) fflush(stdout);
213
for (i=0; i<ndim; i++) {
218
filename_check(filename1, FNAME1, FNAME1_ALT);
219
if (NDRA_Create(MT_DBL, ndim, ddims, "B", filename1, DRA_RW,
220
reqdims, &d_b) != 0) {
221
GA_Error("NDRA_Create failed(d_b): ",0);
224
if (me == 0) printf("non alligned blocking write\n");
225
if (me == 0) fflush(stdout);
227
for (i=0; i<ndim; i++) {
235
if (NDRA_Write_section(FALSE, g_a, glo, ghi,
236
d_b, dlo, dhi, &req) != 0)
237
GA_Error("ndra_write_section failed:",0);
239
if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed(d_b): ",req);
240
tt1 = MP_TIMER() - tt0;
242
tt1 = tt1/((double)nproc);
243
mbytes = 1.e-6*(double)(pow(n,ndim)*sizeof(double));
245
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
246
mbytes,tt1,mbytes/tt1);
249
if (DRA_Close(d_b) != 0) GA_Error("DRA_Close failed(d_b): ",d_b);
250
tt1 = MP_TIMER() - tt0;
252
tt1 = tt1/((double)nproc);
254
printf("Time including DRA_Close\n");
255
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
256
mbytes,tt1,mbytes/tt1);
259
if (me == 0) printf("\n");
260
if (me == 0) printf("disk array closed\n");
261
if (me == 0) fflush(stdout);
265
printf("Creating Disk array %d",n);
266
for (i=1; i<ndim; i++) {
271
for (i=0; i<ndim; i++) {
275
filename_check(filename, FNAME, FNAME_ALT);
276
if (NDRA_Create(MT_DBL, ndim, ddims, "A", filename, DRA_RW,
279
GA_Error("NDRA_Create failed(d_a): ",0);
281
if (me == 0) printf("alligned blocking write\n");
284
if (NDRA_Write(g_a, d_a, &req) != 0) GA_Error("NDRA_Write failed(d_a):",0);
285
if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed(d_a): ",req);
286
tt1 = MP_TIMER() - tt0;
288
tt1 = tt1/((double)nproc);
289
mbytes = 1.e-6 * (double)(pow(n,ndim)*sizeof(double));
291
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
292
mbytes,tt1,mbytes/tt1);
295
if (DRA_Close(d_a) != 0) GA_Error("DRA_Close failed(d_a): ",d_a);
296
tt1 = MP_TIMER() - tt0;
298
tt1 = tt1/((double)nproc);
300
printf("Time including DRA_Close\n");
301
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
302
mbytes,tt1,mbytes/tt1);
305
if (me == 0) printf("\n");
306
if (me == 0) printf("disk array closed\n");
307
if (me == 0) fflush(stdout);
310
printf("Creating Disk array %ld",(long)n);
311
for (i=1; i<ndim; i++) {
312
printf(" x %ld",(long)n);
316
if (me == 0) fflush(stdout);
317
for (i=0; i<ndim; i++) {
322
filename_check(filename, FNAME, FNAME_ALT);
323
if (NDRA_Create(MT_DBL, ndim, ddims, "A", filename, DRA_RW,
324
reqdims, &d_a) != 0) {
325
GA_Error("NDRA_Create failed(d_a): ",0);
327
if (me == 0) printf("alligned blocking write\n");
330
if (NDRA_Write(g_a, d_a, &req) != 0) GA_Error("NDRA_Write failed(d_a):",0);
331
if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed(d_a): ",req);
332
tt1 = MP_TIMER() - tt0;
334
tt1 = tt1/((double)nproc);
335
mbytes = 1.e-6 * (double)(pow(n,ndim)*sizeof(double));
337
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
338
mbytes,tt1,mbytes/tt1);
341
if (DRA_Close(d_a) != 0) GA_Error("DRA_Close failed(d_a): ",d_a);
342
tt1 = MP_TIMER() - tt0;
344
tt1 = tt1/((double)nproc);
346
printf("Time including DRA_Close\n");
347
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
348
mbytes,tt1,mbytes/tt1);
351
if (me == 0) printf("\n");
352
if (me == 0) printf("disk array closed\n");
353
if (me == 0) fflush(stdout);
354
/*.......................................................................*/
357
printf("Creating Disk array %ld",(long)m);
358
for (i=1; i<ndim; i++) {
359
printf(" x %ld",(long)m);
363
for (i=0; i<ndim; i++) {
367
filename_check(filename1, FNAME1, FNAME1_ALT);
368
if (NDRA_Create(MT_DBL, ndim, ddims, "B", filename1, DRA_RW,
369
reqdims, &d_b) != 0) {
370
GA_Error("NDRA_Create failed(d_b): ",0);
373
if (me == 0) printf("non alligned blocking write\n");
374
if (me == 0) fflush(stdout);
376
for (i=0; i<ndim; i++) {
383
if (NDRA_Write_section(FALSE, g_a, glo, ghi,
384
d_b, dlo, dhi, &req) != 0)
385
GA_Error("ndra_write_section failed:",0);
387
if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed(d_b): ",req);
388
tt1 = MP_TIMER() - tt0;
390
tt1 = tt1/((double)nproc);
391
mbytes = 1.e-6*(double)(pow(n,ndim)*sizeof(double));
393
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
394
mbytes,tt1,mbytes/tt1);
397
if (DRA_Close(d_b) != 0) GA_Error("DRA_Close failed(d_b): ",d_b);
398
tt1 = MP_TIMER() - tt0;
400
tt1 = tt1/((double)nproc);
402
printf("Time including DRA_Close\n");
403
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
404
mbytes,tt1,mbytes/tt1);
407
if (me == 0) printf("\n");
408
if (me == 0) printf("disk array closed\n");
409
if (me == 0) fflush(stdout);
411
/*.......................................................................*/
414
if (me == 0) printf("\n");
415
if (me == 0) printf("opening disk array\n");
416
if (DRA_Open(filename1, DRA_R, &d_b) != 0) GA_Error("DRA_Open failed",0);
417
if (me == 0) printf("non alligned blocking read\n");
418
if (me == 0) fflush(stdout);
420
if (NDRA_Read_section(FALSE, g_b, glo, ghi, d_b, dlo, dhi, &req) != 0)
421
GA_Error("NDRA_Read_section failed:",0);
422
if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
423
tt1 = MP_TIMER() - tt0;
425
tt1 = tt1/((double)nproc);
427
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
428
mbytes,tt1,mbytes/tt1);
432
GA_Add(&plus, g_a, &minus, g_b, g_b);
433
err = GA_Ddot(g_b, g_b);
435
if (me == 0) printf("BTW, we have error = %f\n",err);
437
if (me == 0) printf("OK\n");
439
if (DRA_Delete(d_b) != 0) GA_Error("DRA_Delete failed",0);
440
/*.......................................................................*/
441
if (me == 0) printf("\n");
442
if (me == 0) printf("opening disk array\n");
443
if (DRA_Open(filename, DRA_R, &d_a) != 0) GA_Error("DRA_Open failed",0);
444
if (me == 0) printf("alligned blocking read\n");
445
if (me == 0) fflush(stdout);
447
if (NDRA_Read(g_b, d_a, &req) != 0) GA_Error("NDRA_Read failed:",0);
448
if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
449
tt1 = MP_TIMER() - tt0;
451
tt1 = tt1/((double)nproc);
453
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
454
mbytes,tt1,mbytes/tt1);
456
GA_Add(&plus, g_a, &minus, g_b, g_b);
457
err = GA_Ddot(g_b, g_b);
459
if (me == 0) printf("BTW, we have error = %f\n",err);
461
if (me == 0) printf("OK\n");
463
if (DRA_Delete(d_a) != 0) GA_Error("DRA_Delete failed",0);
465
if (me == 0) printf("\n");
466
if (me == 0) printf("opening disk array\n");
467
if (DRA_Open(filename, DRA_R, &d_a) != 0) GA_Error("DRA_Open failed",0);
468
if (me == 0) printf("alligned blocking read\n");
469
if (me == 0) fflush(stdout);
471
if (NDRA_Read(g_b, d_a, &req) != 0) GA_Error("NDRA_Read failed:",0);
472
if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
473
tt1 = MP_TIMER() - tt0;
475
tt1 = tt1/((double)nproc);
477
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
478
mbytes,tt1,mbytes/tt1);
482
GA_Add(&plus, g_a, &minus, g_b, g_b);
483
err = GA_Ddot(g_b, g_b);
485
if (me == 0) printf("BTW, we have error = %f\n",err);
487
if (me == 0) printf("OK\n");
489
if (DRA_Delete(d_a) != 0) GA_Error("DRA_Delete failed",0);
490
/*.......................................................................*/
492
if (me == 0) printf("\n");
493
if (me == 0) printf("opening disk array\n");
494
if (DRA_Open(filename1, DRA_R, &d_b) != 0) GA_Error("DRA_Open failed",0);
495
if (me == 0) printf("non alligned blocking read\n");
496
if (me == 0) fflush(stdout);
498
if (NDRA_Read_section(FALSE, g_b, glo, ghi, d_b, dlo, dhi, &req) != 0)
499
GA_Error("NDRA_Read_section failed:",0);
500
if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
501
tt1 = MP_TIMER() - tt0;
503
tt1 = tt1/((double)nproc);
505
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
506
mbytes,tt1,mbytes/tt1);
508
GA_Add(&plus, g_a, &minus, g_b, g_b);
509
err = GA_Ddot(g_b, g_b);
511
if (me == 0) printf("BTW, we have error = %f\n",err);
513
if (me == 0) printf("OK\n");
515
if (DRA_Delete(d_b) != 0) GA_Error("DRA_Delete failed",0);
517
/*.......................................................................*/
520
/*.......................................................................*/
522
/* Test transpose function for DRAs */
524
for (i=1; i<ndim; i++) dims[i] = n/2;
525
for (i=0; i<ndim; i++) chunk[i] = 1;
526
if (me == 0) printf("Creating asymmetric arrays to test transpose\n\n");
527
g_c = NGA_Create(MT_DBL, ndim, dims, "c", chunk);
528
if (!g_c) GA_Error("NGA_Create failed: c", 0);
529
g_d = NGA_Create(MT_DBL, ndim, dims, "d", chunk);
530
if (!g_d) GA_Error("NGA_Create failed: d", 0);
531
if (me == 0) printf("done\n");
532
if (me == 0) fflush(stdout);
534
/* initialize g_a, g_b with random values
535
... use ga_access to avoid allocating local buffers for ga_put */
538
NGA_Distribution(g_c, me, glo, ghi);
539
NGA_Access(g_c, glo, ghi, &index, ld);
541
for (i=0; i<ndim; i++) isize *= (ghi[i]-glo[i]+1);
542
fill_random(index, isize);
547
for (i=0; i<ndim; i++) {
551
filename_check(filename2, FNAME2, FNAME2_ALT);
552
if (me == 0) printf("Creating DRA for transpose test\n");
553
if (NDRA_Create(MT_DBL, ndim, ddims, "C", filename2, DRA_RW,
554
reqdims, &d_c) != 0) {
555
GA_Error("NDRA_Create failed(d_c): ",0);
557
if (me == 0) printf("done\n");
558
if (me == 0) fflush(stdout);
560
for (i=0; i<ndim-1; i++) {
568
for (i=1; i<ndim; i++) {
572
if (me == 0) printf("non-aligned blocking write with transpose\n");
574
if (NDRA_Write_section(TRUE,g_c,glo,ghi,d_c,dlo,dhi,&req) != 0)
575
GA_Error("NDRA_Write_section (transpose) failed: ",0);
576
if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
578
for (i=0; i<ndim; i++) isize *= (ghi[i]-glo[i]+1);
579
mbytes = 1.e-6 * (double)(isize*sizeof(double));
580
tt1 = MP_TIMER() - tt0;
582
tt1 = tt1/((double)nproc);
584
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
585
mbytes,tt1,mbytes/tt1);
587
if (DRA_Close(d_c) != 0) GA_Error("DRA_Close failed(d_c): ",d_c);
588
if (me == 0) printf("\n");
589
if (me == 0) printf("disk array closed\n");
590
if (me == 0) fflush(stdout);
592
if (me == 0) printf("\n");
593
if (me == 0) printf("opening disk array\n");
594
if (DRA_Open(filename2, DRA_R, &d_c) != 0) GA_Error("DRA_Open failed",0);
597
if (me == 0) printf("non-aligned blocking read with transpose\n");
599
if (NDRA_Read_section(TRUE,g_c,glo,ghi,d_c,dlo,dhi,&req) != 0)
600
GA_Error("NDRA_Read_section (transpose) failed: ",0);
601
if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed: ",req);
602
tt1 = MP_TIMER() - tt0;
604
tt1 = tt1/((double)nproc);
606
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
607
mbytes,tt1,mbytes/tt1);
609
GA_Add(&plus, g_c, &minus, g_d, g_d);
610
err = GA_Ddot(g_d, g_d);
612
if (me == 0) printf("BTW, we have error = %f\n",err);
614
if (me == 0) printf("OK\n");
616
if (DRA_Delete(d_c) != 0) GA_Error("DRA_Delete failed",0);
617
/*.......................................................................*/
620
#endif /* TEST_TRANSPOSE */
624
int main(int argc, char **argv)
628
double max_sz = 1e8, max_disk = 1e10, max_mem = 1e6;
629
int numfiles, numioprocs;
631
int stack = 9000000, heap = 4000000;
633
int stack = 12000000, heap = 8000000;
639
if (GA_Nodeid() == 0) printf("GA not using MA\n");
641
heap = 2*sizeof(double)*pow(SIZE,NDIM)/GA_Nnodes()+10000000;
645
if (MA_init(MT_F_DBL, stack, heap) ) {
646
if (DRA_Init(max_arrays, max_sz, max_disk, max_mem) != 0)
647
GA_Error("DRA_Init failed: ",0);
648
if (USER_CONFIG == 0) {
651
} else if (USER_CONFIG == 1) {
653
numioprocs = GA_Cluster_nnodes();
654
} else if (USER_CONFIG == 2) {
655
numfiles = GA_Cluster_nnodes();
656
numioprocs = GA_Cluster_nnodes();
662
printf("Disk resident arrays configured as:\n");
663
printf(" Number of files: %d\n",numfiles);
664
printf(" Number of I/O processors: %d\n",numioprocs);
666
DRA_Set_default_config(numfiles,numioprocs);
667
if (me == 0) printf("\n");
668
if (me == 0) printf("TESTING PERFORMANCE OF DISK ARRAYS\n");
669
if (me == 0) printf("\n");
671
status = DRA_Terminate();
674
printf("MA_init failed\n");
676
if(me == 0) printf("all done ...\n");