1
#define BASE_NAME "/scratch/da.try"
2
# define FNAME BASE_NAME
14
/* If USER_CONFIG set to:
15
0: Use default configuration
16
1: Number of files is 1, number of I/O procs equals
18
2: Number of files and number of I/O procs equals
20
3: Number of files and number of I/O procs equals 1
21
These configurations only apply if files are not located
22
on local scratch disk. For local scratch, system defaults
23
to 1 I/O proc per node and 1 file per node. Note that
24
USER_CONFIG=1 will only work if system has parallel I/O.
26
Memory and Disk Usage:
27
The aggregate memory required to run this test is approximately
28
2*SIZE**NDIM*sizeof(double) bytes. The amount of disk space
29
required is approximately NFACTOR**NDIM times this amount.
48
#define TRUE (logical)1
49
#define FALSE (logical)0
55
# define USEMULTFILES 1
58
# define USEMULTFILES 0
66
#define MASK 123459876
67
float ran0(long *idum)
74
*idum = IA*(*idum-k*IQ)-IR*k;
75
if (*idum < 0) *idum += IM;
82
void fill_random(double *a, int isize)
89
a[0] = (double)ran0(idum);
90
for (i=0; i<(long)isize; i++) {
91
a[i] = (double)(10000.0*ran0(idum));
99
double err, tt0, tt1, mbytes;
100
int g_a, g_b, g_c, g_d, d_a, d_b, d_c;
101
int i, itmp, j, req, loop;
103
eaf_off_t filelength;
104
int glo[MAXDIM],ghi[MAXDIM];
105
dra_size_t dlo[MAXDIM],dhi[MAXDIM];
106
dra_size_t ddims[MAXDIM],reqdims[MAXDIM];
108
int index[MAXDIM], dims[MAXDIM];
109
int me, nproc, isize;
112
int ld[MAXDIM], chunk[MAXDIM];
117
m = ((dra_size_t)NFACTOR)*((dra_size_t)SIZE);
120
for (i=0; i<ndim; i++) loop *= NFACTOR;
126
printf("Creating temporary global arrays %d",n);
127
for (i=1; i<ndim; i++) {
132
if (me == 0) fflush(stdout);
134
for (i=0; i<ndim; i++) {
139
g_a = NGA_Create(MT_DBL, ndim, dims, "a", chunk);
140
if (!g_a) GA_Error("NGA_Create failed: a", 0);
141
g_b = NGA_Create(MT_DBL, ndim, dims, "b", chunk);
142
if (!g_b) GA_Error("NGA_Create failed: b", 0);
143
if (me == 0) printf("done\n");
144
if (me == 0) fflush(stdout);
146
/* initialize g_a, g_b with random values
147
... use ga_access to avoid allocating local buffers for ga_put */
150
NGA_Distribution(g_a, me, glo, ghi);
151
NGA_Access(g_a, glo, ghi, &ptr, ld);
153
for (i=0; i<ndim; i++) isize *= (ghi[i]-glo[i]+1);
154
fill_random(ptr, isize);
159
/*.......................................................................*/
161
printf("Creating Disk array %ld",m);
162
for (i=1; i<ndim; i++) {
167
if (me == 0) fflush(stdout);
168
for (i=0; i<ndim; i++) {
170
reqdims[i] = (dra_size_t)n;
172
strcpy(filename,FNAME);
174
if (NDRA_Create(MT_DBL, ndim, ddims, "A", filename, DRA_RW,
175
reqdims, &d_a) != 0) GA_Error("NDRA_Create failed(d_a): ",0);
176
if (me == 0) printf("testing write\n");
179
for (i=0; i<loop; i++) {
181
for (j=0; j<ndim; j++) {
182
index[j] = itmp%NFACTOR;
183
itmp = (itmp - index[j])/NFACTOR;
185
for (j=0; j<ndim; j++) {
188
dlo[j] = ((dra_size_t)index[j])*((dra_size_t)SIZE);
189
dhi[j] = (((dra_size_t)index[j])+(dra_size_t)1)*((dra_size_t)SIZE)
193
if (NDRA_Write_section(FALSE, g_a, glo, ghi,
194
d_a, dlo, dhi, &req) != 0)
195
GA_Error("ndra_write_section failed:",0);
196
if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed(d_a): ",req);
197
tt1 += (tcgtime_() - tt0);
200
tt1 = tt1/((double)nproc);
201
mbytes = 1.e-6 * (double)(pow(m,ndim)*sizeof(double));
203
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
204
mbytes,tt1,mbytes/tt1);
207
if (DRA_Close(d_a) != 0) GA_Error("DRA_Close failed(d_a): ",d_a);
209
if (me == 0) printf("\n");
210
if (me == 0) printf("disk array closed\n");
211
if (me == 0) fflush(stdout);
213
/*.......................................................................*/
215
if (me == 0) printf("\n");
216
if (me == 0) printf("opening disk array\n");
217
if (DRA_Open(filename, DRA_R, &d_a) != 0) GA_Error("DRA_Open failed",0);
218
if (me == 0) printf("testing read\n");
219
/* printf("testing read on proc %d\n",me); */
220
if (me == 0) fflush(stdout);
222
for (i=0; i<loop; i++) {
224
for (j=0; j<ndim; j++) {
225
index[j] = itmp%NFACTOR;
226
itmp = (itmp - index[j])/NFACTOR;
228
for (j=0; j<ndim; j++) {
231
dlo[j] = ((dra_size_t)index[j])*((dra_size_t)SIZE);
232
dhi[j] = (((dra_size_t)index[j])+(dra_size_t)1)*((dra_size_t)SIZE)
236
if (NDRA_Read_section(FALSE, g_b, glo, ghi,
237
d_a, dlo, dhi, &req) != 0)
238
GA_Error("ndra_read_section failed:",0);
239
if (DRA_Wait(req) != 0) GA_Error("DRA_Wait failed(d_a): ",req);
240
tt1 += (tcgtime_() - tt0);
243
GA_Add(&plus, g_a, &minus, g_b, g_b);
244
err = GA_Ddot(g_b, g_b);
246
if (me == 0) printf("BTW, we have error = %f on loop value %d\n",err,i);
251
tt1 = tt1/((double)nproc);
253
printf("%11.2f MB time = %11.2f rate = %11.3f MB/s\n",
254
mbytes,tt1,mbytes/tt1);
256
if (DRA_Delete(d_a) != 0) GA_Error("DRA_Delete failed",0);
257
/*.......................................................................*/
262
void main(argc, argv)
268
double max_sz = 1e8, max_disk = 1e10, max_mem = 1e6;
269
int stack = 120000, heap = 3200000;
270
int numfiles, numioprocs;
276
total = pow(SIZE,NDIM)*sizeof(double);
278
if (GA_Nodeid() == 0) {
279
printf("GA is not using MA\n");
282
heap = (int)(2.2*(float)(total));
285
if (MA_init(MT_F_DBL, stack, heap) ) {
287
if (DRA_Init(max_arrays, max_sz, max_disk, max_mem) != 0)
288
GA_Error("DRA_Init failed: ",0);
289
if (USER_CONFIG == 0) {
292
} else if (USER_CONFIG == 1) {
294
numioprocs = GA_Cluster_nnodes();
295
} else if (USER_CONFIG == 2) {
296
numfiles = GA_Cluster_nnodes();
297
numioprocs = GA_Cluster_nnodes();
303
printf("Disk resident arrays configured as:\n");
304
printf(" Number of files: %d\n",numfiles);
305
printf(" Number of I/O processors: %d\n",numioprocs);
307
DRA_Set_default_config(numfiles,numioprocs);
308
if (me == 0) printf("\n");
309
if (me == 0) printf("TESTING PERFORMANCE OF DISK ARRAYS\n");
310
if (me == 0) printf("\n");
312
status = DRA_Terminate();
315
printf("MA_init failed\n");
317
if(me == 0) printf("all done ...\n");