~ubuntu-branches/ubuntu/saucy/nwchem/saucy

« back to all changes in this revision

Viewing changes to src/tools/ga-4-3/pario/dra/rate.c

  • Committer: Package Import Robot
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2012-02-09 20:02:41 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120209200241-jgk03qfsphal4ug2
Tags: 6.1-1
* New upstream release.

[ Michael Banck ]
* debian/patches/02_makefile_flags.patch: Updated.
* debian/patches/02_makefile_flags.patch: Use internal blas and lapack code.
* debian/patches/02_makefile_flags.patch: Define GCC4 for LINUX and LINUX64
  (Closes: #632611 and LP: #791308).
* debian/control (Build-Depends): Added openssh-client.
* debian/rules (USE_SCALAPACK, SCALAPACK): Removed variables (Closes:
  #654658).
* debian/rules (LIBDIR, USE_MPIF4, ARMCI_NETWORK): New variables.
* debian/TODO: New file.
* debian/control (Build-Depends): Removed libblas-dev, liblapack-dev and
  libscalapack-mpi-dev.
* debian/patches/04_show_testsuite_diff_output.patch: New patch, shows the
  diff output for failed tests.
* debian/patches/series: Adjusted.
* debian/testsuite: Optionally run all tests if "all" is passed as option.
* debian/rules: Run debian/testsuite with "all" if DEB_BUILD_OPTIONS
  contains "checkall".

[ Daniel Leidert ]
* debian/control: Used wrap-and-sort. Added Vcs-Svn and Vcs-Browser fields.
  (Priority): Moved to extra according to policy section 2.5.
  (Standards-Version): Bumped to 3.9.2.
  (Description): Fixed a typo.
* debian/watch: Added.
* debian/patches/03_hurd-i386_define_path_max.patch: Added.
  - Define MAX_PATH if not defines to fix FTBFS on hurd.
* debian/patches/series: Adjusted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#define BASE_NAME  "/scratch/da.try"
 
2
#  define FNAME   BASE_NAME
 
3
 
 
4
#include <stdio.h>
 
5
#include <math.h>
 
6
#include <stdlib.h>
 
7
#include "macdecls.h"
 
8
#include "ga.h"
 
9
#include "dra.h"
 
10
#include "eaf.h"
 
11
#include "sndrcv.h"
 
12
#include "srftoc.h"
 
13
 
 
14
/* If USER_CONFIG set to:
 
15
     0: Use default configuration
 
16
     1: Number of files is 1, number of I/O procs equals
 
17
        the number of nodes
 
18
     2: Number of files and number of I/O procs equals
 
19
        the number of nodes
 
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.
 
25
 
 
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.
 
30
*/
 
31
#define USER_CONFIG 0
 
32
 
 
33
#define NDIM 3
 
34
#define SIZE 250
 
35
#define NFACTOR 7
 
36
 
 
37
/*
 
38
#define NDIM 2
 
39
#define SIZE 4000
 
40
#define NFACTOR 3
 
41
 
 
42
#define NDIM 1
 
43
#define SIZE 12500000
 
44
#define NFACTOR 640
 
45
*/
 
46
 
 
47
#define MAXDIM 7
 
48
#define TRUE (logical)1
 
49
#define FALSE (logical)0
 
50
 
 
51
#define MULTFILES 0
 
52
 
 
53
#ifdef SOLARIS
 
54
#  if MULTFILES
 
55
#    define USEMULTFILES 1
 
56
#  endif
 
57
#else
 
58
#  define USEMULTFILES 0
 
59
#endif
 
60
 
 
61
#define IA 16807
 
62
#define IM 2147483647
 
63
#define AM (1.0/IM)
 
64
#define IQ 127773
 
65
#define IR 2836
 
66
#define MASK 123459876
 
67
float ran0(long *idum)
 
68
{
 
69
  long k;
 
70
  float ans;
 
71
 
 
72
  *idum ^= MASK;
 
73
  k=(*idum)/IQ;
 
74
  *idum = IA*(*idum-k*IQ)-IR*k;
 
75
  if (*idum < 0) *idum += IM;
 
76
  ans=AM*(*idum);
 
77
  *idum ^= MASK;
 
78
  return ans;
 
79
}
 
80
 
 
81
 
 
82
void fill_random(double *a, int isize)
 
83
{
 
84
  long *idum;
 
85
  long i, j;
 
86
 
 
87
  j = 38282;
 
88
  idum = &j;
 
89
  a[0] = (double)ran0(idum);
 
90
  for (i=0; i<(long)isize; i++) {
 
91
    a[i] = (double)(10000.0*ran0(idum));
 
92
  }
 
93
}
 
94
 
 
95
 
 
96
void test_io_dbl()
 
97
{
 
98
  int n, ndim = NDIM;
 
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;
 
102
  int fd;
 
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];
 
107
  dra_size_t m;
 
108
  int index[MAXDIM], dims[MAXDIM];
 
109
  int me, nproc, isize;
 
110
  double *ptr;
 
111
  double plus, minus;
 
112
  int ld[MAXDIM], chunk[MAXDIM];
 
113
  char filename[80];
 
114
  logical status;
 
115
 
 
116
  n = SIZE;
 
117
  m = ((dra_size_t)NFACTOR)*((dra_size_t)SIZE);
 
118
 
 
119
  loop  = 1;
 
120
  for (i=0; i<ndim; i++) loop *= NFACTOR;
 
121
  req = -1;
 
122
  nproc = GA_Nnodes();
 
123
  me    = GA_Nodeid();
 
124
 
 
125
  if (me == 0) {
 
126
    printf("Creating temporary global arrays %d",n);
 
127
    for (i=1; i<ndim; i++) {
 
128
      printf(" x %d",n);
 
129
    }
 
130
    printf("\n");
 
131
  }
 
132
  if (me == 0) fflush(stdout);
 
133
  GA_Sync();
 
134
  for (i=0; i<ndim; i++) {
 
135
    dims[i] = n;
 
136
    chunk[i] = 1;
 
137
  }
 
138
 
 
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);
 
145
 
 
146
/*     initialize g_a, g_b with random values
 
147
      ... use ga_access to avoid allocating local buffers for ga_put */
 
148
 
 
149
  GA_Sync();
 
150
  NGA_Distribution(g_a, me, glo, ghi);
 
151
  NGA_Access(g_a, glo, ghi, &ptr, ld);
 
152
  isize = 1;
 
153
  for (i=0; i<ndim; i++) isize *= (ghi[i]-glo[i]+1);
 
154
  fill_random(ptr, isize);
 
155
  GA_Sync();
 
156
  GA_Zero(g_b);
 
157
 
 
158
 
 
159
/*.......................................................................*/
 
160
  if (me == 0) {
 
161
    printf("Creating Disk array %ld",m);
 
162
    for (i=1; i<ndim; i++) {
 
163
      printf(" x %ld",m);
 
164
    }
 
165
    printf("\n");
 
166
  }
 
167
  if (me == 0) fflush(stdout);
 
168
  for (i=0; i<ndim; i++) {
 
169
    ddims[i] = m;
 
170
    reqdims[i] = (dra_size_t)n;
 
171
  }
 
172
  strcpy(filename,FNAME);
 
173
  GA_Sync();
 
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");
 
177
  fflush(stdout);
 
178
  tt1 = 0.0;
 
179
  for (i=0; i<loop; i++) {
 
180
    itmp=i;
 
181
    for (j=0; j<ndim; j++) {
 
182
      index[j] = itmp%NFACTOR;
 
183
      itmp = (itmp - index[j])/NFACTOR;
 
184
    }
 
185
    for (j=0; j<ndim; j++) {
 
186
      glo[j] = 0;
 
187
      ghi[j] = SIZE - 1;
 
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)
 
190
             - (dra_size_t)1;
 
191
    }
 
192
    tt0 = tcgtime_();
 
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);
 
198
  }
 
199
  GA_Dgop(&tt1,1,"+");
 
200
  tt1 = tt1/((double)nproc);
 
201
  mbytes = 1.e-6 * (double)(pow(m,ndim)*sizeof(double));
 
202
  if (me == 0) {
 
203
    printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
 
204
        mbytes,tt1,mbytes/tt1);
 
205
  }
 
206
 
 
207
  if (DRA_Close(d_a) != 0) GA_Error("DRA_Close failed(d_a): ",d_a);
 
208
 
 
209
  if (me == 0) printf("\n");
 
210
  if (me == 0) printf("disk array closed\n");
 
211
  if (me == 0) fflush(stdout);
 
212
 
 
213
/*.......................................................................*/
 
214
 
 
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);
 
221
  tt1 = 0.0;
 
222
  for (i=0; i<loop; i++) {
 
223
    itmp=i;
 
224
    for (j=0; j<ndim; j++) {
 
225
      index[j] = itmp%NFACTOR;
 
226
      itmp = (itmp - index[j])/NFACTOR;
 
227
    }
 
228
    for (j=0; j<ndim; j++) {
 
229
      glo[j] = 0;
 
230
      ghi[j] = SIZE - 1;
 
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)
 
233
             - (dra_size_t)1;
 
234
    }
 
235
    tt0 = tcgtime_();
 
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);
 
241
    plus = 1.0;
 
242
    minus = -1.0;
 
243
    GA_Add(&plus, g_a, &minus, g_b, g_b);
 
244
    err = GA_Ddot(g_b, g_b);
 
245
    if (err != 0) {
 
246
      if (me == 0) printf("BTW, we have error = %f on loop value %d\n",err,i);
 
247
      GA_Error(" bye",0);
 
248
    }
 
249
  }
 
250
  GA_Dgop(&tt1,1,"+");
 
251
  tt1 = tt1/((double)nproc);
 
252
  if (me == 0) {
 
253
    printf("%11.2f MB  time = %11.2f rate = %11.3f MB/s\n",
 
254
        mbytes,tt1,mbytes/tt1);
 
255
  }
 
256
  if (DRA_Delete(d_a) != 0) GA_Error("DRA_Delete failed",0);
 
257
/*.......................................................................*/
 
258
  GA_Destroy(g_a);
 
259
  GA_Destroy(g_b);
 
260
}
 
261
 
 
262
void main(argc, argv)
 
263
int argc;
 
264
char **argv;
 
265
{
 
266
  int status, me;
 
267
  int max_arrays = 10;
 
268
  double max_sz = 1e8, max_disk = 1e10, max_mem = 1e6;
 
269
  int stack = 120000, heap = 3200000;
 
270
  int numfiles, numioprocs;
 
271
  int total, nproc;
 
272
 
 
273
  PBEGIN_(argc, argv); 
 
274
  GA_Initialize();
 
275
  nproc = GA_Nnodes();
 
276
  total = pow(SIZE,NDIM)*sizeof(double);
 
277
  if (!GA_Uses_ma()) {
 
278
    if (GA_Nodeid() == 0) {
 
279
      printf("GA is not using MA\n");
 
280
    }
 
281
    stack = 100000;
 
282
    heap  = (int)(2.2*(float)(total));
 
283
  }
 
284
 
 
285
  if (MA_init(MT_F_DBL, stack, heap) ) {
 
286
    me    = GA_Nodeid();
 
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) {
 
290
      numfiles = -1;
 
291
      numioprocs = -1;
 
292
    } else if (USER_CONFIG == 1) {
 
293
      numfiles = 1;
 
294
      numioprocs = GA_Cluster_nnodes();
 
295
    } else if (USER_CONFIG == 2) {
 
296
      numfiles = GA_Cluster_nnodes();
 
297
      numioprocs = GA_Cluster_nnodes();
 
298
    } else {
 
299
      numfiles = 1;
 
300
      numioprocs = 1;
 
301
    }
 
302
    if (me==0) {
 
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);
 
306
    }
 
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");
 
311
    test_io_dbl();
 
312
    status = DRA_Terminate();
 
313
    GA_Terminate();
 
314
  } else {
 
315
    printf("MA_init failed\n");
 
316
  }
 
317
  if(me == 0) printf("all done ...\n");
 
318
  PEND_();
 
319
}