forked from Nek5000-deprecated/Nek5000-deprecated
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcomm_mpi.f
1254 lines (1038 loc) · 33.3 KB
/
comm_mpi.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
c---------------------------------------------------------------------
subroutine iniproc(intracomm)
include 'SIZE'
include 'PARALLEL'
include 'mpif.h'
common /nekmpi/ nid_,np_,nekcomm,nekgroup,nekreal
logical flag
c call mpi_initialized(mpi_is_initialized, ierr) ! Initialize MPI
c if ( mpi_is_initialized .eq. 0 ) then
c call mpi_init (ierr)
c endif
! set nek communicator
call init_nek_comm(intracomm)
nid = nid_
np = np_
if(nid.eq.0) call printHeader
! check upper tag size limit
call mpi_attr_get(MPI_COMM_WORLD,MPI_TAG_UB,nval,flag,ierr)
if (nval.lt.(10000+max(lp,lelg))) then
if(nid.eq.0) write(6,*) 'ABORT: MPI_TAG_UB too small!'
call exitt
endif
IF (NP.GT.LP) THEN
WRITE(6,*)
$ 'ERROR: Code compiled for a max of',LP,' processors.'
WRITE(6,*)
$ 'Recompile with LP =',NP,' or run with fewer processors.'
WRITE(6,*)
$ 'Aborting in routine INIPROC.'
call exitt
endif
! set word size for REAL
wdsize=4
eps=1.0e-12
oneeps = 1.0+eps
if (oneeps.ne.1.0) then
wdsize=8
else
if(nid.eq.0)
& write(6,*) 'ABORT: single precision mode not supported!'
call exitt
endif
nekreal = mpi_real
if (wdsize.eq.8) nekreal = mpi_double_precision
ifdblas = .false.
if (wdsize.eq.8) ifdblas = .true.
! set word size for INTEGER
! HARDCODED since there is no secure way to detect an int overflow
isize = 4
! set word size for LOGICAL
lsize = 4
! set word size for CHARACTER
csize = 1
c
PID = 0
NULLPID=0
NODE0=0
NODE= NID+1
if (nid.eq.0) then
write(6,*) 'Number of processors:',np
WRITE(6,*) 'REAL wdsize :',WDSIZE
WRITE(6,*) 'INTEGER wdsize :',ISIZE
endif
call crystal_setup(cr_h,nekcomm,np) ! set cr handle to new instance
return
end
c-----------------------------------------------------------------------
subroutine init_nek_comm(intracomm)
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
C
nekcomm = intracomm
nid = mynode()
np = numnodes()
c
return
end
c-----------------------------------------------------------------------
subroutine gop( x, w, op, n)
c Global vector commutative operation
include 'CTIMER'
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
real x(n), w(n)
character*3 op
if (ifsync) call nekgsync()
#ifndef NOTIMER
if (icalld.eq.0) then
tgop =0.0d0
ngop =0
icalld=1
endif
ngop = ngop + 1
etime1=dnekclock()
#endif
c
if (op.eq.'+ ') then
call mpi_allreduce (x,w,n,nekreal,mpi_sum ,nekcomm,ierr)
elseif (op.EQ.'M ') then
call mpi_allreduce (x,w,n,nekreal,mpi_max ,nekcomm,ierr)
elseif (op.EQ.'m ') then
call mpi_allreduce (x,w,n,nekreal,mpi_min ,nekcomm,ierr)
elseif (op.EQ.'* ') then
call mpi_allreduce (x,w,n,nekreal,mpi_prod,nekcomm,ierr)
else
write(6,*) nid,' OP ',op,' not supported. ABORT in GOP.'
call exitt
endif
call copy(x,w,n)
#ifndef NOTIMER
tgop =tgop +(dnekclock()-etime1)
#endif
return
end
c-----------------------------------------------------------------------
subroutine igop( x, w, op, n)
c
c Global vector commutative operation
c
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
integer x(n), w(n)
character*3 op
if (op.eq.'+ ') then
call mpi_allreduce (x,w,n,mpi_integer,mpi_sum ,nekcomm,ierr)
elseif (op.EQ.'M ') then
call mpi_allreduce (x,w,n,mpi_integer,mpi_max ,nekcomm,ierr)
elseif (op.EQ.'m ') then
call mpi_allreduce (x,w,n,mpi_integer,mpi_min ,nekcomm,ierr)
elseif (op.EQ.'* ') then
call mpi_allreduce (x,w,n,mpi_integer,mpi_prod,nekcomm,ierr)
else
write(6,*) nid,' OP ',op,' not supported. ABORT in igop.'
call exitt
endif
call icopy(x,w,n)
return
end
c-----------------------------------------------------------------------
subroutine i8gop( x, w, op, n)
c
c Global vector commutative operation
c
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
integer*8 x(n), w(n)
character*3 op
if (op.eq.'+ ') then
call mpi_allreduce (x,w,n,mpi_integer8,mpi_sum ,nekcomm,ierr)
elseif (op.EQ.'M ') then
call mpi_allreduce (x,w,n,mpi_integer8,mpi_max ,nekcomm,ierr)
elseif (op.EQ.'m ') then
call mpi_allreduce (x,w,n,mpi_integer8,mpi_min ,nekcomm,ierr)
elseif (op.EQ.'* ') then
call mpi_allreduce (x,w,n,mpi_integer8,mpi_prod,nekcomm,ierr)
else
write(6,*) nid,' OP ',op,' not supported. ABORT in igop.'
call exitt
endif
call i8copy(x,w,n)
return
end
c-----------------------------------------------------------------------
subroutine csend(mtype,buf,len,jnid,jpid)
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
real*4 buf(1)
call mpi_send (buf,len,mpi_byte,jnid,mtype,nekcomm,ierr)
return
end
c-----------------------------------------------------------------------
subroutine crecv(mtype,buf,lenm)
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
integer status(mpi_status_size)
C
real*4 buf(1)
len = lenm
jnid = mpi_any_source
call mpi_recv (buf,len,mpi_byte
$ ,jnid,mtype,nekcomm,status,ierr)
c
if (len.gt.lenm) then
write(6,*) nid,'long message in mpi_crecv:',len,lenm
call exitt
endif
c
return
end
c-----------------------------------------------------------------------
subroutine crecv3(mtype,buf,len,lenm)
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
integer status(mpi_status_size)
C
real*4 buf(1)
len = lenm
jnid = mpi_any_source
call mpi_recv (buf,len,mpi_byte
$ ,jnid,mtype,nekcomm,status,ierr)
call mpi_get_count (status,mpi_byte,len,ierr)
c
if (len.gt.lenm) then
write(6,*) nid,'long message in mpi_crecv:',len,lenm
call exitt
endif
c
return
end
c-----------------------------------------------------------------------
integer function numnodes()
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
call mpi_comm_size (nekcomm, numnodes , ierr)
return
end
c-----------------------------------------------------------------------
integer function mynode()
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
integer myid
call mpi_comm_rank (nekcomm, myid, ierr)
mynode = myid
return
end
c-----------------------------------------------------------------------
real*8 function dnekclock()
include 'mpif.h'
c
dnekclock=mpi_wtime()
c
return
end
c-----------------------------------------------------------------------
real*8 function dnekclock_sync()
include 'mpif.h'
c
call nekgsync()
dnekclock_sync=mpi_wtime()
c
return
end
c-----------------------------------------------------------------------
subroutine lbcast(ifif)
C
C Broadcast logical variable to all processors.
C
include 'SIZE'
include 'PARALLEL'
include 'mpif.h'
logical ifif
if (np.eq.1) return
item=0
if (ifif) item=1
call bcast(item,isize)
ifif=.false.
if (item.eq.1) ifif=.true.
return
end
c-----------------------------------------------------------------------
subroutine bcast(buf,len)
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
real*4 buf(1)
call mpi_bcast (buf,len,mpi_byte,0,nekcomm,ierr)
return
end
c-----------------------------------------------------------------------
subroutine create_comm(inewcomm)
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
c call mpi_comm_group (mpi_comm_world,itmp,ierr)
c call mpi_comm_create (mpi_comm_world,itmp,icomm,ierr)
c call mpi_group_free (itmp,ierr)
call mpi_comm_dup(nekcomm,inewcomm,ierr)
return
end
c-----------------------------------------------------------------------
function isend(msgtag,x,len,jnid,jpid)
c
c Note: len in bytes
c
integer x(1)
C
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
C
call mpi_isend (x,len,mpi_byte,jnid,msgtag
$ ,nekcomm,imsg,ierr)
isend = imsg
c write(6,*) nid,' isend:',imsg,msgtag,len,jnid,(x(k),k=1,len/4)
c
return
end
c-----------------------------------------------------------------------
function irecv(msgtag,x,len)
c
c Note: len in bytes
c
integer x(1)
C
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
C
call mpi_irecv (x,len,mpi_byte,mpi_any_source,msgtag
$ ,nekcomm,imsg,ierr)
irecv = imsg
c write(6,*) nid,' irecv:',imsg,msgtag,len
c
c
return
end
c-----------------------------------------------------------------------
subroutine msgwait(imsg)
c
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
integer status(mpi_status_size)
c
c write(6,*) nid,' msgwait:',imsg
c
call mpi_wait (imsg,status,ierr)
c
return
end
c-----------------------------------------------------------------------
subroutine nekgsync()
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
call mpi_barrier(nekcomm,ierr)
return
end
c-----------------------------------------------------------------------
subroutine exittr(stringi,rdata,idata)
character*1 stringi(132)
character*1 stringo(132)
character*25 s25
include 'SIZE'
include 'TOTAL'
include 'CTIMER'
call blank(stringo,132)
call chcopy(stringo,stringi,132)
len = indx1(stringo,'$',1)
write(s25,25) rdata,idata
25 format(1x,1p1e14.6,i10)
call chcopy(stringo(len),s25,25)
if (nid.eq.0) write(6,1) (stringo(k),k=1,len+24)
1 format('EXIT: ',132a1)
call exitt
return
end
c-----------------------------------------------------------------------
subroutine exitti(stringi,idata)
character*1 stringi(132)
character*1 stringo(132)
character*11 s11
include 'SIZE'
include 'TOTAL'
include 'CTIMER'
call blank(stringo,132)
call chcopy(stringo,stringi,132)
len = indx1(stringo,'$',1)
write(s11,11) idata
11 format(1x,i10)
call chcopy(stringo(len),s11,11)
if (nid.eq.0) write(6,1) (stringo(k),k=1,len+10)
1 format('EXIT: ',132a1)
call exitt
return
end
c-----------------------------------------------------------------------
subroutine err_chk(ierr,string)
character*1 string(132)
character*1 ostring(132)
character*10 s10
include 'SIZE'
c include 'TOTAL'
c include 'CTIMER'
ierr = iglsum(ierr,1)
if(ierr.eq.0) return
len = indx1(string,'$',1)
call blank(ostring,132)
write(s10,11) ierr
11 format(1x,' ierr=',i3)
call chcopy(ostring,string,len-1)
call chcopy(ostring(len),s10,10)
if (nid.eq.0) write(6,1) (ostring(k),k=1,len+10)
1 format('ERROR: ',132a1)
call exitt
return
end
c
c-----------------------------------------------------------------------
subroutine exitt0
include 'SIZE'
include 'TOTAL'
include 'CTIMER'
include 'mpif.h'
real*4 papi_mflops
integer*8 papi_flops
write(6,*) 'Emergency exit'
call print_stack()
call flush_io
call mpi_finalize (ierr)
#ifdef EXTBAR
call exit_(0)
#else
call exit(0)
#endif
return
end
c-----------------------------------------------------------------------
subroutine exitt
include 'SIZE'
include 'TOTAL'
include 'CTIMER'
include 'mpif.h'
common /happycallflag/ icall
real*4 papi_mflops
integer*8 papi_flops
logical ifopen !check for opened files
c
c Communicate unhappiness to the other session
if (ifneknek.and.icall.eq.0) call happy_check(0)
call nekgsync()
#ifdef PAPI
call nek_flops(papi_flops,papi_mflops)
#endif
tstop = dnekclock()
ttotal = tstop-etimes
nxyz = nx1*ny1*nz1
if (nid.eq.0) then
call close_files(ifopen)
dtmp1 = 0
dtmp2 = 0
dtmp3 = 0
if(istep.gt.0) then
dgp = nvtot
dgp = max(dgp,1.)
dtmp1 = np*ttime/(dgp*max(istep,1))
dtmp2 = ttime/max(istep,1)
dtmp3 = 1.*papi_flops/1e6
endif
write(6,*) ' '
write(6,'(A)') 'call exitt: dying ...'
write(6,*) ' '
call print_stack()
write(6,*) ' '
write(6,'(4(A,1p1e13.5,A,/))')
& 'total elapsed time : ',ttotal, ' sec'
& ,'total solver time incl. I/O : ',ttime , ' sec'
& ,'time/timestep : ',dtmp2 , ' sec'
& ,'CPU seconds/timestep/gridpt : ',dtmp1 , ' sec'
#ifdef PAPI
write(6,'(2(A,1g13.5,/))')
& 'Gflops : ',dtmp3/1000.
& ,'Gflops/s : ',papi_mflops/1000.
#endif
endif
call flush_io
call mpi_finalize (ierr)
#ifdef EXTBAR
call exit_(0)
#else
call exit(0)
#endif
return
end
c-----------------------------------------------------------------------
subroutine printHeader
INCLUDE 'HEADER'
return
end
c-----------------------------------------------------------------------
function igl_running_sum(in)
c
include 'mpif.h'
common /nekmpi/ nid,np,nekcomm,nekgroup,nekreal
integer status(mpi_status_size)
integer x,w,r
x = in ! running sum
w = in ! working buff
r = 0 ! recv buff
call mpi_scan(x,r,1,mpi_integer,mpi_sum,nekcomm,ierr)
igl_running_sum = r
return
end
c-----------------------------------------------------------------------
subroutine platform_timer(ivb) ! mxm, ping-pong, and all_reduce timer
include 'SIZE'
include 'TOTAL'
call mxm_test_all(nid,ivb) ! measure mxm times
c call exitti('done mxm_test_all$',ivb)
call comm_test(ivb) ! measure message-passing and all-reduce times
return
end
c-----------------------------------------------------------------------
subroutine comm_test(ivb) ! measure message-passing and all-reduce times
! ivb = 0 --> minimal verbosity
! ivb = 1 --> fully verbose
! ivb = 2 --> smaller sample set(shorter)
include 'SIZE'
include 'PARALLEL'
call gop_test(ivb) ! added, Jan. 8, 2008
log_np=log2(np)
np2 = 2**log_np
if (np2.eq.np) call gp2_test(ivb) ! added, Jan. 8, 2008
io = 6
n512 = min(512,np-1)
do nodeb=1,n512
call pingpongo(alphas,betas,0,nodeb,.0005,io,ivb)
if (nid.eq.0) write(6,2) nodeb,np,alphas,betas
2 format(2i10,1p2e15.7,' alpha betao')
enddo
do kk=0,2
do nodeb=1,n512
call pingpong (alphas,betas,0,nodeb,.0005,io,ivb,kk)
if (nid.eq.0) write(6,1) nodeb,np,alphas,betas,kk
1 format(2i10,1p2e15.7,' alpha beta',i1)
enddo
enddo
return
end
c-----------------------------------------------------------------------
subroutine pingpong(alphas,betas,nodea,nodeb,dt,io,ivb,kk)
include 'SIZE'
common /nekmpi/ mid,np,nekcomm,nekgroup,nekreal
parameter (lt=lx1*ly1*lz1*lelt)
parameter (mwd = 3*lt)
common /scrns/ x(mwd),y(mwd)
include 'mpif.h'
integer status(mpi_status_size)
character*10 fname
if (nid.eq.nodea) then
write(fname,3) np,nodeb
3 format('t',i4.4,'.',i4.4)
if (io.ne.6) open (unit=io,file=fname)
endif
call nekgsync
call get_msg_vol(msg_vol,dt,nodea,nodeb) ! Est. msg vol for dt s
nwds = 0
if (nid.eq.nodea.and.ivb.gt.0) write(io,*)
betas = 0 ! Reported inverse bandwidth
count = 0
do itest = 1,500
nloop = msg_vol/(nwds+2)
nloop = min(nloop,1000)
nloop = max(nloop,1)
len = 8*nwds
if (kk.eq.0)
$ call ping_loop (t1,t0,len,nloop,nodea,nodeb,nid,x,y,x,y)
if (kk.eq.1)
$ call ping_loop1(t1,t0,len,nloop,nodea,nodeb,nid,x,y,x,y)
if (kk.eq.2)
$ call ping_loop2(t1,t0,len,nloop,nodea,nodeb,nid,x,y,x,y)
if (nid.eq.nodea) then
tmsg = (t1-t0)/(2*nloop) ! 2*nloop--> Double Buffer
tmsg = tmsg / 2. ! one-way cost = 1/2 round-trip
tpwd = tmsg ! time-per-word
if (nwds.gt.0) tpwd = tmsg/nwds
if (ivb.gt.0) write(io,1) nodeb,np,nloop,nwds,tmsg,tpwd,kk
1 format(3i6,i12,1p2e16.8,' pgn',i1)
if (nwds.eq.1) then
alphas = tmsg
elseif (nwds.gt.10000) then ! "average" beta
betas = (betas*count + tpwd)/(count+1)
count = count + 1
endif
endif
if (ivb.eq.2) then
nwds = (nwds+1)*1.25
else
nwds = (nwds+1)*1.016
endif
if (nwds.gt.mwd) then
c if (nwds.gt.1024) then
if (nid.eq.nodea.and.io.ne.6) close(unit=io)
call nekgsync
return
endif
enddo
if (nid.eq.nodea.and.io.ne.6) close(unit=io)
call nekgsync
return
end
c-----------------------------------------------------------------------
subroutine pingpongo(alphas,betas,nodea,nodeb,dt,io,ivb)
include 'SIZE'
common /nekmpi/ mid,np,nekcomm,nekgroup,nekreal
parameter (lt=lx1*ly1*lz1*lelt)
parameter (mwd = 3*lt)
common /scrns/ x(mwd),y(mwd)
include 'mpif.h'
integer status(mpi_status_size)
character*10 fname
if (nid.eq.nodea) then
write(fname,3) np,nodeb
3 format('t',i4.4,'.',i4.4)
if (io.ne.6) open (unit=io,file=fname)
endif
call nekgsync
call get_msg_vol(msg_vol,dt,nodea,nodeb) ! Est. msg vol for dt s
nwds = 0
if (nid.eq.nodea.and.ivb.gt.0) write(io,*)
betas = 0 ! Reported inverse bandwidth
count = 0
do itest = 1,500
call nekgsync
nloop = msg_vol/(nwds+2)
nloop = min(nloop,1000)
nloop = max(nloop,1)
len = 8*nwds
jnid = mpi_any_source
if (nid.eq.nodea) then
msg = irecv(itest,y,1)
call csend(itest,x,1,nodeb,0) ! Initiate send, to synch.
call msgwait(msg)
t0 = mpi_wtime ()
do i=1,nloop
call mpi_irecv(y,len,mpi_byte,mpi_any_source,i
$ ,nekcomm,msg,ierr)
call mpi_send (x,len,mpi_byte,nodeb,i,nekcomm,ierr)
call mpi_wait (msg,status,ierr)
enddo
t1 = mpi_wtime ()
tmsg = (t1-t0)/nloop
tmsg = tmsg / 2. ! Round-trip message time = twice one-way
tpwd = tmsg
if (nwds.gt.0) tpwd = tmsg/nwds
if (ivb.gt.0) write(io,1) nodeb,np,nloop,nwds,tmsg,tpwd
1 format(3i6,i12,1p2e16.8,' pgo')
if (nwds.eq.1) then
alphas = tmsg
elseif (nwds.gt.10000) then
betas = (betas*count + tpwd)/(count+1)
count = count + 1
endif
elseif (nid.eq.nodeb) then
call crecv(itest,y,1) ! Initiate send, to synch.
call csend(itest,x,1,nodea,0)
t0 = dnekclock()
do i=1,nloop
call mpi_recv (y,len,mpi_byte
$ ,jnid,i,nekcomm,status,ierr)
call mpi_send (x,len,mpi_byte,nodea,i,nekcomm,ierr)
enddo
t1 = dnekclock()
tmsg = (t1-t0)/nloop
endif
nwds = (nwds+1)*1.016
if (nwds.gt.mwd) then
if (nid.eq.nodea.and.io.ne.6) close(unit=io)
call nekgsync
return
endif
enddo
if (nid.eq.nodea.and.io.ne.6) close(unit=io)
call nekgsync
return
end
c-----------------------------------------------------------------------
subroutine get_msg_vol(msg_vol,dt,nodea,nodeb)
include 'SIZE'
common /nekmpi/ mid,np,nekcomm,nekgroup,nekreal
parameter (lt=lx1*ly1*lz1*lelt)
common /scrns/ x(3*lt),y(3*lt)
!
! Est. msg vol for dt s
!
msg_vol = 1000
nwds = min(1000,lt)
nloop = 50
tmsg = 0.
call gop(tmsg,t1,'+ ',1)
len = 8*nwds
if (nid.eq.nodea) then
msg = irecv(1,y,1)
call csend(1,x,1,nodeb,0) ! Initiate send, to synch.
call msgwait(msg)
t0 = dnekclock()
do i=1,nloop
msg = irecv(i,y,len)
call csend(i,x,len,nodeb,0)
call msgwait(msg)
enddo
t1 = dnekclock()
tmsg = (t1-t0)/nloop
tpwd = tmsg/nwds
elseif (nid.eq.nodeb) then
call crecv(1,y,1) ! Initiate send, to synch.
call csend(1,x,1,nodea,0)
t0 = dnekclock()
do i=1,nloop
call crecv(i,y,len)
call csend(i,x,len,nodea,0)
enddo
t1 = dnekclock()
tmsg = (t1-t0)/nloop
tmsg = 0.
endif
call gop(tmsg,t1,'+ ',1)
msg_vol = nwds*(dt/tmsg)
c if (nid.eq.nodea) write(6,*) nid,msg_vol,nwds,dt,tmsg,' msgvol'
return
end
c-----------------------------------------------------------------------
subroutine gop_test(ivb)
include 'SIZE'
common /nekmpi/ mid,np,nekcomm,nekgroup,nekreal
include 'mpif.h'
integer status(mpi_status_size)
parameter (lt=lx1*ly1*lz1*lelt)
parameter (mwd = 3*lt)
common /scrns/ x(mwd),y(mwd)
common /scruz/ times(2,500)
common /scrcg/ nwd(500)
nwds = 1
mtest = 0
do itest = 1,500
nwds = (nwds+1)*1.016
if (nwds.gt.mwd) goto 100
mtest = mtest+1
nwd(mtest) = nwds
enddo
100 continue
nwds = 1
do itest = mtest,1,-1
tiny = 1.e-27
call cfill(x,tiny,mwd)
nwds = nwd(itest)
call nekgsync
t0 = mpi_wtime ()
call gop(x,y,'+ ',nwds)
call gop(x,y,'+ ',nwds)
call gop(x,y,'+ ',nwds)
call gop(x,y,'+ ',nwds)
call gop(x,y,'+ ',nwds)
call gop(x,y,'+ ',nwds)
t1 = mpi_wtime ()
tmsg = (t1-t0)/6 ! six calls
tpwd = tmsg
if (nwds.gt.0) tpwd = tmsg/nwds
times(1,itest) = tmsg
times(2,itest) = tpwd
enddo
101 continue
if (nid.eq.0) then
nwds = 1
do itest=1,500
if (ivb.gt.0.or.itest.eq.1)
$ write(6,1) np,nwds,(times(k,itest),k=1,2)
1 format(i12,i12,1p2e16.8,' gop')
nwds = (nwds+1)*1.016
if (nwds.gt.mwd) goto 102
enddo
102 continue
endif
return
end
c-----------------------------------------------------------------------
subroutine gp2_test(ivb)
include 'SIZE'
include 'mpif.h'
common /nekmpi/ mid,np,nekcomm,nekgroup,nekreal
integer status(mpi_status_size)
parameter (lt=lx1*ly1*lz1*lelt)
parameter (mwd = 3*lt)
common /scrns/ x(mwd),y(mwd)
common /scruz/ times(2,500)
call rzero(x,mwd)
nwds = 1
do itest = 1,500
call gp2(x,y,'+ ',1,nid,np)
t0 = mpi_wtime ()
call gp2(x,y,'+ ',nwds,nid,np)
call gp2(x,y,'+ ',nwds,nid,np)
call gp2(x,y,'+ ',nwds,nid,np)
call gp2(x,y,'+ ',nwds,nid,np)
t1 = mpi_wtime ()
tmsg = (t1-t0)/4 ! four calls
tpwd = tmsg
if (nwds.gt.0) tpwd = tmsg/nwds
times(1,itest) = tmsg
times(2,itest) = tpwd
nwds = (nwds+1)*1.016
if (nwds.gt.mwd) goto 101
enddo
101 continue
if (nid.eq.0) then
nwds = 1
do itest=1,500
if (ivb.gt.0.or.itest.eq.1)
$ write(6,1) np,nwds,(times(k,itest),k=1,2)
1 format(i12,i12,1p2e16.8,' gp2')
nwds = (nwds+1)*1.016
if (nwds.gt.mwd) goto 102
enddo
102 continue
endif
return
end
c-----------------------------------------------------------------------
integer function xor(m,n)
c
c If NOT running on a parallel processor, it is sufficient to
c have this routine return a value of XOR=1.
c
c Pick one of the following:
c
c UNIX 4.2, f77:
XOR = OR(M,N)-AND(M,N)
c
c Intel FTN286:
c XOR = M.NEQV.N
c
c Ryan-McFarland Fortran
C XOR = IEOR(M,N)
c
c XOR = 0
c IF(M.EQ.1 .OR. N.EQ.1) XOR=1
c IF(M.EQ.0 .AND. N.EQ.0) XOR=0
c IF(M.EQ.1 .AND. N.EQ.1) XOR=0
c IF(M.GT.1 .OR.N.GT.1 .OR.M.LT.0.OR.N.LT.0) THEN
c PRINT*,'ERROR IN XOR'
c STOP
c ENDIF
C
return
end
c-----------------------------------------------------------------------
subroutine gp2( x, w, op, n, nid, np)