root / synthbench / euroben-dm / mod1k / .svn / text-base / mod1k.f.svn-base @ 0:839f52ef7657
History | View | Annotate | Download (5.6 kB)
1 |
Program mod1k |
---|---|
2 |
! ---------------------------------------------------------------------- |
3 |
Use numerics |
4 |
Use dist_module |
5 |
Implicit None |
6 |
Include 'mpif.h' |
7 |
|
8 |
Integer :: comm, ierr, status, |
9 |
& istat(MPI_Status_Size), my_win |
10 |
Integer :: i, ireps, length, nreps |
11 |
Integer(8), Parameter :: disp = 0 |
12 |
Integer(8), Parameter :: mlen = 8000000 ! <=== Max window size. |
13 |
Logical :: ok |
14 |
|
15 |
Integer :: message(mlen) |
16 |
Real(l_) :: incpt, perc, slope, time |
17 |
Real(l_) :: bw, bwmax, latency, lperc |
18 |
|
19 |
Common /buffer/ message |
20 |
! ---------------------------------------------------------------------- |
21 |
! --- Initialise MPI, make window, initialise message array. |
22 |
! Also initialise the least-squares routine and max. bandwidth. |
23 |
! ---------------------------------------------------------------------- |
24 |
Call csetup |
25 |
comm = MPI_Comm_World |
26 |
Call MPI_Win_Create( message, mlen, 4, MPI_Info_Null, |
27 |
& comm, my_win, ierr ) |
28 |
If ( me == 0 ) Then |
29 |
Call lsq( 0, 0.0_l_, 0.0_l_, slope, incpt, perc ) |
30 |
bwmax = 0.0_l_ |
31 |
End If |
32 |
message = 0 |
33 |
If ( me == 0 ) Then |
34 |
Do i = 1, mlen |
35 |
message(i) = i |
36 |
End Do |
37 |
End If |
38 |
! ---------------------------------------------------------------------- |
39 |
! --- Call identification routine. |
40 |
! ---------------------------------------------------------------------- |
41 |
If ( me == 0 ) Then |
42 |
Call state('mod1k ') |
43 |
Print 1000 |
44 |
End If |
45 |
Open( 1, File = 'mod1k.in' ) |
46 |
! --------------------------------------------------------------------- |
47 |
! --- Get new case from the input file for the MPI_Get test. |
48 |
! --------------------------------------------------------------------- |
49 |
10 Read( 1, *, End = 20 ) length, nreps |
50 |
! ---------------------------------------------------------------------- |
51 |
! --- Measure MPI_Get: |
52 |
! ---------------------------------------------------------------------- |
53 |
If ( me == 1 ) Then |
54 |
time = MPI_Wtime() |
55 |
Do ireps = 1, nreps |
56 |
Call MPI_Get( message, length, MPI_Integer, 0, disp, length, |
57 |
& MPI_Integer, my_win, ierr ) |
58 |
End Do |
59 |
time = ( MPI_Wtime() - time )/( Real( nreps, l_ ) ) |
60 |
Call lsq( 1, Real( length, l_ ), time, slope, incpt, perc ) |
61 |
If ( length == 50 ) Then |
62 |
latency = incpt*1.0e6_l_ |
63 |
lperc = perc |
64 |
End If |
65 |
bw = 1.0e-6_l_*Real( 4*length, l_ )/time |
66 |
bwmax = Max( bwmax, bw ) |
67 |
ok = .TRUE. |
68 |
Call check( message, length, ok ) |
69 |
Print 1010, 4*length, time, bw, ok |
70 |
End If |
71 |
Call MPI_Win_Fence( 0, my_win, ierr ) |
72 |
Go To 10 ! <================================= |
73 |
20 If ( me == 1 ) Then |
74 |
Print 1020 |
75 |
Print 1040, bwmax, latency, lperc |
76 |
End If |
77 |
Call MPI_Barrier( comm, ierr ) |
78 |
! ---------------------------------------------------------------------- |
79 |
! --- Measure MPI_Put: |
80 |
! ---------------------------------------------------------------------- |
81 |
Rewind 1 |
82 |
If ( me == 1 ) message = 0 |
83 |
If ( me == 0 ) Then |
84 |
Print 1030 |
85 |
Call lsq( 0, 0.0_l_, 0.0_l_, slope, incpt, perc ) |
86 |
bwmax = 0.0_l_ |
87 |
End If |
88 |
30 Read( 1, *, End = 40 ) length, nreps |
89 |
If ( me == 0 ) Then |
90 |
time = MPI_Wtime() |
91 |
Do ireps = 1, nreps |
92 |
Call MPI_Put( message, length, MPI_Integer, 1, disp, length, |
93 |
& MPI_Integer, my_win, ierr ) |
94 |
End Do |
95 |
time = ( MPI_Wtime() - time )/( Real( nreps, l_ ) ) |
96 |
End If |
97 |
ok = .TRUE. |
98 |
If ( me == 1 ) Call check( message, length, ok ) |
99 |
If ( me == 0 ) Then |
100 |
Call MPI_Get( ok, 1, MPI_Logical, 1, disp, 1, MPI_Logical, |
101 |
& my_win, ierr ) |
102 |
Call lsq( 1, Real( length, l_ ), time, slope, incpt, perc ) |
103 |
If ( length == 50 ) Then |
104 |
latency = incpt*1.0e6_l_ |
105 |
lperc = perc |
106 |
End If |
107 |
bw = 1.0e-6_l_*Real( 4*length, l_ )/time |
108 |
bwmax = Max( bwmax, bw ) |
109 |
Print 1010, 4*length, time, bw, ok |
110 |
End If |
111 |
Call MPI_Win_Fence( 0, my_win, ierr ) |
112 |
Go To 30 ! <================================= |
113 |
40 If ( me == 0 ) Then |
114 |
Print 1020 |
115 |
Print 1040, bwmax, latency, lperc |
116 |
End If |
117 |
Call MPI_Finalize( ierr ) |
118 |
! --------------------------------------------------------------------- |
119 |
1000 Format('Program mod1k: One-sided distr. memory communication'/ |
120 |
& '----------------------------------------------------'/ |
121 |
& '| Mess. length | MPI_Get time | Bandwidth | |'/ |
122 |
& '| (Bytes) | (seconds) | (Mbyte/s) |OK?|'/ |
123 |
& '----------------------------------------------------' ) |
124 |
1010 Format('|', 3x, i8, 3x, '|', 1x, g13.5, 1x, '|', 1x, g13.5, 1x, |
125 |
& '|', l2,' |' ) |
126 |
1020 Format('----------------------------------------------------' ) |
127 |
1030 Format(// |
128 |
& '----------------------------------------------------'/ |
129 |
& '| Mess. length | MPI_Put time | Bandwidth | |'/ |
130 |
& '| (Bytes) | (seconds) | (Mbyte/s) |OK?|'/ |
131 |
& '----------------------------------------------------' ) |
132 |
1040 Format( 'Maximum bandwidth = ' g12.5, ' MB/s'/ |
133 |
& 'Latency = ', g11.4, ' microsec., Error = ', f6.2, '%'/ |
134 |
& '-------------------------------------------------------') |
135 |
! --------------------------------------------------------------------- |
136 |
End Program mod1k |