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

« back to all changes in this revision

Viewing changes to src/tools/ga-4-3/examples/armci/features/concurrency/simple/comdegree.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
/*$Id: comdegree.c,v 1.1.2.1 2007-06-20 17:41:49 vinod Exp $*/
 
2
/*
 
3
 *                                Copyright (c) 2006
 
4
 *                      Pacific Northwest National Laboratory,
 
5
 *                           Battelle Memorial Institute.
 
6
 *                              All rights reserved.
 
7
 * 
 
8
 * Redistribution and use in source and binary forms, with or without
 
9
 * modification, are permitted provided that the following conditions
 
10
 * are met: - Redistributions of source code must retain the above
 
11
 * copyright notice, this list of conditions and the following disclaimer.
 
12
 * 
 
13
 * - Redistributions in binary form must reproduce the above copyright
 
14
 *   notice, this list of conditions and the following disclaimer in the
 
15
 *   documentation and/or other materials provided with the distribution.
 
16
 * - Neither the name of the Battelle nor the names of its contributors
 
17
 *   may be used to endorse or promote products derived from this software
 
18
 *   without specific prior written permission.
 
19
 * 
 
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
21
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
22
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
23
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
24
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
25
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 
26
 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
27
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 
28
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 
29
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
30
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
31
 * 
 
32
 */
 
33
 
 
34
 
 
35
/*************************
 
36
 * This test checks the networks ability to overlap data transfers.
 
37
 * It does it both for an optimitic case (with no other communication) and
 
38
 * a more realistic case.
 
39
 * --Vinod Tipparaju
 
40
 * --Pacific Northwest National Laboratory
 
41
 * --vinod@pnl.gov
 
42
*************************/
 
43
#include <stdio.h>
 
44
#include <stdlib.h>
 
45
#include <assert.h>
 
46
#include <math.h>
 
47
 
 
48
#define DEBUG__ 
 
49
 
 
50
#if defined(PVM)
 
51
#   include <pvm3.h>
 
52
#   ifdef CRAY
 
53
#     define MPGROUP         (char *)NULL
 
54
#     define MP_INIT(arc,argv)
 
55
#   else
 
56
#     define MPGROUP           "mp_working_group"
 
57
#     define MP_INIT(arc,argv) pvm_init(arc, argv)
 
58
#   endif
 
59
#   define MP_FINALIZE()     pvm_exit()
 
60
#   define MP_BARRIER()      pvm_barrier(MPGROUP,-1)
 
61
#   define MP_MYID(pid)      *(pid)   = pvm_getinst(MPGROUP,pvm_mytid())
 
62
#   define MP_PROCS(pproc)   *(pproc) = (int)pvm_gsize(MPGROUP)
 
63
    void pvm_init(int argc, char *argv[]);
 
64
#elif defined(TCGMSG)
 
65
#   include <sndrcv.h>
 
66
    long tcg_tag =30000;
 
67
#   define MP_BARRIER()      SYNCH_(&tcg_tag)
 
68
#   define MP_INIT(arc,argv) PBEGIN_((argc),(argv))
 
69
#   define MP_FINALIZE()     PEND_()
 
70
#   define MP_MYID(pid)      *(pid)   = (int)NODEID_()
 
71
#   define MP_PROCS(pproc)   *(pproc) = (int)NNODES_()
 
72
#else
 
73
#   include <mpi.h>
 
74
#   define MP_BARRIER()      MPI_Barrier(MPI_COMM_WORLD)
 
75
#   define MP_FINALIZE()     MPI_Finalize()
 
76
#   define MP_INIT(arc,argv) MPI_Init(&(argc),&(argv))
 
77
#   define MP_MYID(pid)      MPI_Comm_rank(MPI_COMM_WORLD, (pid))
 
78
#   define MP_PROCS(pproc)   MPI_Comm_size(MPI_COMM_WORLD, (pproc));
 
79
#   define MP_TIMER()        MPI_Wtime()
 
80
#endif
 
81
 
 
82
#include "armci.h"
 
83
 
 
84
 
 
85
/***************************** macros ************************/
 
86
#define COPY(src, dst, bytes) memcpy((dst),(src),(bytes))
 
87
#define MAX(a,b) (((a) >= (b)) ? (a) : (b))
 
88
#define MIN(a,b) (((a) <= (b)) ? (a) : (b))
 
89
#define ABS(a) (((a) <0) ? -(a) : (a))
 
90
 
 
91
/***************************** global data *******************/
 
92
int me, nproc;
 
93
 
 
94
 
 
95
void create_array(void *a[], int size)
 
96
{
 
97
     armci_size_t bytes=size;
 
98
     int i, rc;
 
99
 
 
100
     rc = ARMCI_Malloc(a, bytes);
 
101
     assert(rc==0);
 
102
     
 
103
#ifdef DEBUG_
 
104
     printf("%d after malloc ndim=%d b=%d ptr=%p\n",me,ndim,(int) bytes,a[me]);
 
105
     fflush(stdout);
 
106
#endif
 
107
 
 
108
     assert(a[me]);
 
109
     bzero(a[me],bytes);
 
110
}
 
111
 
 
112
void destroy_array(void *ptr[])
 
113
{
 
114
    MP_BARRIER();
 
115
 
 
116
    assert(!ARMCI_Free(ptr[me]));
 
117
}
 
118
 
 
119
 
 
120
 
 
121
#define LCC 13
 
122
#define MAXPROC 128
 
123
    
 
124
void test_get_multidma()
 
125
{
 
126
int dim,elems;
 
127
int i,j, proc=1,Idx=1,idx=0;
 
128
void *b[MAXPROC], *a[MAXPROC];
 
129
int left = (me+nproc-1) % nproc;
 
130
int right = (me+1) % nproc;
 
131
int sendersright=0,sendersleft=0;
 
132
int loopcnt=10, itercount=5,less=2, strl; /*less>1 takes a partial plane */
 
133
double tt, t0[LCC],t1[LCC],t2[LCC],t3[LCC],t4=0,t5=0,t6=0;
 
134
armci_hdl_t hdl1,hdl2;
 
135
 
 
136
    for(i=0;i<LCC;i++){
 
137
       t0[i]=0;
 
138
       t1[i]=0;
 
139
       t2[i]=0;
 
140
       t3[i]=0;
 
141
    }
 
142
 
 
143
    /* create shared and local arrays */
 
144
    create_array(b, 1024*1024*10);
 
145
    create_array(a, 1024*1024*10);
 
146
    /* warmup */
 
147
    ARMCI_INIT_HANDLE(&hdl1);
 
148
    ARMCI_INIT_HANDLE(&hdl2);
 
149
    ARMCI_NbGet((double*)b[left],(double*)a[me],1024,left,&hdl1);
 
150
    ARMCI_NbGet((double*)b[right]+1024,(double*)a[me]+1024,1024,
 
151
                         right,&hdl2);
 
152
    ARMCI_Wait(&hdl1);
 
153
    ARMCI_Wait(&hdl2);
 
154
 
 
155
    ARMCI_Barrier();
 
156
 
 
157
    /*start test*/
 
158
    for(j=0;j<itercount;j++){
 
159
       for(i=0;i<loopcnt;i++){
 
160
         int lc, rc,wc,lc1,rc1,wc1,bytes;
 
161
        
 
162
         sendersright = (j+1)%nproc;
 
163
         sendersleft = (j+nproc-1)%nproc;
 
164
 
 
165
         bytes = 1024*pow(2,i);
 
166
 
 
167
         ARMCI_INIT_HANDLE(&hdl1);
 
168
 
 
169
         armci_msg_barrier();
 
170
         /*first time a regular call*/
 
171
         tt = MP_TIMER();
 
172
         ARMCI_NbGet((double*)b[left],(double*)a[me],bytes, left,&hdl1);
 
173
         ARMCI_Wait(&hdl1);
 
174
         t1[i] += (MP_TIMER()-tt);
 
175
 
 
176
         
 
177
         armci_msg_barrier();
 
178
         /*now time 1 left + 1 right but realize there is one xtra issue*/
 
179
         ARMCI_INIT_HANDLE(&hdl1);
 
180
         ARMCI_INIT_HANDLE(&hdl2);
 
181
         tt = MP_TIMER();
 
182
         ARMCI_NbGet((double*)b[left],(double*)a[me],bytes/2,left,&hdl1);
 
183
         ARMCI_NbGet((double*)b[right]+bytes/16,(double*)a[me]+bytes/16,bytes/2,
 
184
                         right,&hdl2);
 
185
         ARMCI_Wait(&hdl1);
 
186
         ARMCI_Wait(&hdl2);
 
187
         t2[i] += (MP_TIMER()-tt);
 
188
 
 
189
         ARMCI_Barrier();
 
190
         armci_msg_barrier();
 
191
         /*now time both to the left*/
 
192
         ARMCI_INIT_HANDLE(&hdl1);
 
193
         ARMCI_INIT_HANDLE(&hdl2);
 
194
         tt = MP_TIMER();
 
195
         ARMCI_NbGet((double*)b[left],(double*)a[me],bytes/2,left,&hdl1);
 
196
         ARMCI_NbGet((double*)b[left]+bytes/16,(double*)a[me]+bytes/16,bytes/2,
 
197
                         left,&hdl2);
 
198
         ARMCI_Wait(&hdl1);
 
199
         ARMCI_Wait(&hdl2);
 
200
         t3[i] += ( MP_TIMER()-tt);
 
201
 
 
202
         ARMCI_Barrier();
 
203
       }
 
204
    }
 
205
    MP_BARRIER();
 
206
    if(0==me){
 
207
       for(i=0;i<loopcnt;i++){
 
208
         fprintf(stderr,"\n%.0f\t%.2e\t%.2e\t%.2e",
 
209
                         1024.0*pow(2,i),t1[i]/loopcnt,t3[i]/loopcnt,
 
210
                         t2[i]/loopcnt);
 
211
       }
 
212
    }
 
213
    fflush(stdout);
 
214
    MP_BARRIER();
 
215
    MP_BARRIER();
 
216
    if((nproc-3)==me){
 
217
       for(i=0;i<loopcnt;i++){
 
218
         fprintf(stderr,"\n%.0f\t%.2e\t%.2e\t%.2e",
 
219
                         1024.0*pow(2,i),t1[i]/loopcnt,t3[i]/loopcnt,
 
220
                         t2[i]/loopcnt);
 
221
       }
 
222
    }
 
223
    fflush(stdout);
 
224
    MP_BARRIER();
 
225
#if 0
 
226
    for(j=0;j<nproc;j++) {
 
227
       if(j==me){
 
228
         for(i=0;i<loopcnt;i++){
 
229
           printf("\n%d:size=%f onesnd=%.2e twosnd=%.2e twosnddiffdir=%.2e\n",
 
230
                           me,1024.0*pow(2,i),t1[i]/loopcnt,t3[i]/loopcnt,
 
231
                           t2[i]/loopcnt);
 
232
         }
 
233
         MP_BARRIER();
 
234
       }
 
235
       else
 
236
         MP_BARRIER();
 
237
    }
 
238
#endif
 
239
 
 
240
 
 
241
    ARMCI_Barrier();
 
242
 
 
243
    destroy_array(b);
 
244
    destroy_array(a);
 
245
}
 
246
 
 
247
 
 
248
void test_put_multidma()
 
249
{
 
250
int dim,elems;
 
251
int i,j, proc=1,Idx=1,idx=0;
 
252
void *b[MAXPROC], *a[MAXPROC];
 
253
int left = (me+nproc-1) % nproc;
 
254
int right = (me+1) % nproc;
 
255
int sendersright=0,sendersleft=0;
 
256
int loopcnt=LCC, itercount=1000,less=2, strl; /*less>1 takes a partial plane */
 
257
double tt, t0[LCC],t1[LCC],t2[LCC],t3[LCC],t4=0,t5=0,t6=0;
 
258
armci_hdl_t hdl1,hdl2;
 
259
 
 
260
 
 
261
    /* create shared and local arrays */
 
262
    create_array(b, 1024*1024*10);
 
263
    create_array(a, 1024*1024*10);
 
264
    for(i=0;i<LCC;i++){
 
265
       t0[i]=0;
 
266
       t1[i]=0;
 
267
       t2[i]=0;
 
268
       t3[i]=0;
 
269
    }
 
270
 
 
271
    ARMCI_Barrier();
 
272
    for(j=0;j<itercount;j++){
 
273
       for(i=0;i<loopcnt;i++){
 
274
         int lc, rc,wc,lc1,rc1,wc1,bytes;
 
275
        
 
276
         sendersright = (j+1)%nproc;
 
277
         sendersleft = (j+nproc-1)%nproc;
 
278
 
 
279
         bytes = 1024*pow(2,i)/8;
 
280
 
 
281
         ARMCI_INIT_HANDLE(&hdl1);
 
282
         ARMCI_NbPut((double*)a[me]+1024,(double*)b[left]+1024,bytes,left,&hdl1);
 
283
         ARMCI_Wait(&hdl1);
 
284
         ARMCI_INIT_HANDLE(&hdl1);
 
285
         ARMCI_NbPut((double*)a[me]+1024,(double*)b[right]+1024,bytes,right,&hdl1);
 
286
         ARMCI_Wait(&hdl1);
 
287
 
 
288
         ARMCI_INIT_HANDLE(&hdl1);
 
289
         armci_msg_barrier();
 
290
 
 
291
         tt = MP_TIMER();
 
292
         ARMCI_NbPut((double*)a[me],(double*)b[left],bytes, left,&hdl1);
 
293
         ARMCI_Wait(&hdl1);
 
294
         t1[i] += (MP_TIMER()-tt);
 
295
         //lc=armci_notify(left);
 
296
         //tt = MP_TIMER();
 
297
         //rc = armci_notify_wait(right,&wc); 
 
298
         //t1[i] += (MP_TIMER()-tt);
 
299
 
 
300
         ARMCI_INIT_HANDLE(&hdl1);
 
301
         ARMCI_INIT_HANDLE(&hdl2);
 
302
         armci_msg_barrier();
 
303
 
 
304
         tt = MP_TIMER();
 
305
         ARMCI_NbPut((double*)a[me],(double*)b[left],bytes,left,&hdl1);
 
306
         ARMCI_NbPut((double*)a[me],(double*)b[right],bytes,
 
307
                         right,&hdl2);
 
308
         ARMCI_Wait(&hdl1);
 
309
         t2[i] += (MP_TIMER()-tt);
 
310
         //lc=armci_notify(left);
 
311
         //lc1=armci_notify(right);
 
312
         //tt = MP_TIMER();
 
313
         //rc1 = armci_notify_wait(left,&wc1); 
 
314
         //rc = armci_notify_wait(right,&wc); 
 
315
         //t2[i] += (MP_TIMER()-tt);
 
316
         //ARMCI_Wait(&hdl1);
 
317
         ARMCI_Wait(&hdl2);
 
318
 
 
319
         ARMCI_INIT_HANDLE(&hdl1);
 
320
         ARMCI_INIT_HANDLE(&hdl2);
 
321
         armci_msg_barrier();
 
322
 
 
323
         tt = MP_TIMER();
 
324
         ARMCI_NbPut((double*)a[me],(double*)b[left],bytes/2,left,&hdl1);
 
325
         ARMCI_NbPut((double*)a[me]+bytes/16,(double*)b[left]+bytes/16,bytes/2,
 
326
                         left,&hdl2);
 
327
         //ARMCI_Wait(&hdl1);
 
328
         //ARMCI_Wait(&hdl2);
 
329
         t3[i] += ( MP_TIMER()-tt);
 
330
         lc=armci_notify(left);
 
331
         tt = MP_TIMER();
 
332
         rc = armci_notify_wait(right,&wc); 
 
333
         t3[i] += ( MP_TIMER()-tt);
 
334
         ARMCI_Wait(&hdl1);
 
335
         ARMCI_Wait(&hdl2);
 
336
 
 
337
         ARMCI_Barrier();
 
338
       }
 
339
    }
 
340
    MP_BARRIER();
 
341
    if(0==me){
 
342
       for(i=0;i<loopcnt;i++){
 
343
         fprintf(stderr,"\n%.0f\t%.2e\t%.2e\t%.2e",
 
344
                         128.0*pow(2,i),t1[i]/itercount,t3[i]/itercount,
 
345
                         t2[i]/itercount);
 
346
       }
 
347
    }
 
348
    fflush(stdout);
 
349
    fflush(stdout);
 
350
    MP_BARRIER();
 
351
    MP_BARRIER();
 
352
    if((nproc-1)==me){
 
353
       for(i=0;i<loopcnt;i++){
 
354
         fprintf(stderr,"\n%.0f\t%.2e\t%.2e\t%.2e",
 
355
                         128.0*pow(2,i),t1[i]/itercount,t3[i]/itercount,
 
356
                         t2[i]/itercount);
 
357
       }
 
358
    }
 
359
    fflush(stdout);
 
360
    MP_BARRIER();
 
361
#if 0
 
362
    for(j=0;j<nproc;j++) {
 
363
       if(j==me){
 
364
         for(i=0;i<loopcnt;i++){
 
365
           printf("\n%d:size=%f onesnd=%.2e twosnd=%.2e twosnddiffdir=%.2e\n",
 
366
                           me,1024.0*pow(2,i),t1[i]/loopcnt,t3[i]/loopcnt,
 
367
                           t2[i]/loopcnt);
 
368
         }
 
369
         MP_BARRIER();
 
370
       }
 
371
       else
 
372
         MP_BARRIER();
 
373
    }
 
374
#endif
 
375
 
 
376
 
 
377
    ARMCI_Barrier();
 
378
 
 
379
    destroy_array(b);
 
380
    destroy_array(a);
 
381
}
 
382
 
 
383
 
 
384
int main(int argc, char* argv[])
 
385
{
 
386
    int ndim;
 
387
 
 
388
    MP_INIT(argc, argv);
 
389
    MP_PROCS(&nproc);
 
390
    MP_MYID(&me);
 
391
 
 
392
    
 
393
    ARMCI_Init();
 
394
 
 
395
    MP_BARRIER();
 
396
    if(me==0){
 
397
       printf("\nTesting transfer overlap with ARMCI put calls\n");
 
398
       printf("\nsize\tone-send\ttwo-sends\ttwo-sends-diff-dir\n");
 
399
       fflush(stdout);
 
400
       sleep(1);
 
401
    }
 
402
    MP_BARRIER();
 
403
    test_put_multidma();
 
404
    MP_BARRIER();
 
405
    if(me==0){
 
406
       printf("\nTesting transfer overlap with ARMCI get calls\n");
 
407
       printf("\nsize\tone-send\ttwo-sends\ttwo-sends-diff-dir\n");
 
408
       fflush(stdout);
 
409
       sleep(1);
 
410
    }
 
411
    MP_BARRIER();
 
412
    test_get_multidma();
 
413
    if(me==0)printf("\n");
 
414
 
 
415
    ARMCI_Finalize();
 
416
    MP_FINALIZE();
 
417
    return(0);
 
418
}