root / synthbench / euroben-dm / mod2i / .svn / text-base / mod2i.f.svn-base @ 0:839f52ef7657
History | View | Annotate | Download (4.4 kB)
1 |
Program mod2i |
---|---|
2 |
! --------------------------------------------------------------------- |
3 |
! Program 'mod2i' tests an iterative Quicksort algorithm with |
4 |
! Integer and 8-byte Real data. Data are generated internally |
5 |
! by the Fortran 90-provided random generator. |
6 |
! --------------------------------------------------------------------- |
7 |
Use numerics |
8 |
Use dist_module |
9 |
Implicit None |
10 |
Include 'mpif.h' |
11 |
|
12 |
Integer, Allocatable :: idata(:), src(:) |
13 |
Real(l_), Allocatable :: ddata(:) |
14 |
Real(l_) :: cor, dlog2, speed1, speed2, time1, |
15 |
& time2, time1t, time2t |
16 |
Real(l_) :: start_time, end_time |
17 |
Integer :: comm, dtype, i, ier, ltype, m, mx, |
18 |
& m_new, n, nops, nrep |
19 |
Logical :: ok1, ok2, ok1t, ok2t |
20 |
! ---------------------------------------------------------------------- |
21 |
Call csetup |
22 |
comm = MPI_Comm_World |
23 |
dtype = MPI_Real8 |
24 |
ltype = MPI_Logical |
25 |
start_time = MPI_Wtime() |
26 |
If ( me == 0 ) Then |
27 |
Call state( 'mod2i ' ) |
28 |
End If |
29 |
Open( 1, File = 'mod2i.in' ) |
30 |
If ( me == 0 ) Print 1000, nodes |
31 |
10 Read( 1, *, End = 20 ) n, nrep |
32 |
Call evdist( n ) |
33 |
! Call bsaddr |
34 |
m = sizes( me ) |
35 |
mx = Maxval( sizes ) |
36 |
mx = mx + mx/2 ! --- Allow for more elements |
37 |
Allocate( idata(mx), ddata(mx), src(mx) )!after reshuffling. |
38 |
Call ranint( 1, n, m, src ) |
39 |
nops = Int( n*dlog2( n ) ) ! --- Average work estimate!! |
40 |
|
41 |
time1 = MPI_Wtime() ! --- Integer sort. |
42 |
Do i = 1, nrep |
43 |
idata = src |
44 |
Call i_psrs( m, mx, idata, m_new ) |
45 |
Call MPI_Barrier( comm, ier ) |
46 |
End Do |
47 |
time1 = MPI_Wtime() - time1 |
48 |
ok1 = .TRUE. ! --- Correctness check. |
49 |
Call icheck( idata, m_new, ok1 ) |
50 |
time2 = MPI_Wtime() ! --- 8-byte Real sort. |
51 |
Do i = 1, nrep |
52 |
ddata = Real( src, l_ ) |
53 |
Call d_psrs( m, mx, ddata, m_new ) |
54 |
Call MPI_Barrier( comm, ier ) |
55 |
End Do |
56 |
time2 = MPI_Wtime() - time2 |
57 |
ok2 = .TRUE. ! --- Correctness check. |
58 |
Call dcheck( ddata, m_new, ok2 ) |
59 |
ok1t = .TRUE. |
60 |
ok2t = .TRUE. |
61 |
Call MPI_Reduce( ok1, ok1t, 1, ltype, MPI_Land, 0, comm, ier ) |
62 |
Call MPI_Reduce( ok2, ok2t, 1, ltype, MPI_Land, 0, comm, ier ) |
63 |
|
64 |
cor = MPI_Wtime() ! --- Correct timings. |
65 |
Do i = 1, nrep |
66 |
idata = src |
67 |
Call MPI_Barrier( comm, ier ) |
68 |
End Do |
69 |
time1 = time1 - MPI_Wtime() + cor |
70 |
cor = MPI_Wtime() |
71 |
Do i = 1, nrep |
72 |
ddata = Real( src, l_ ) |
73 |
Call MPI_Barrier( comm, ier ) |
74 |
End Do |
75 |
time2 = time2 - MPI_Wtime() + cor |
76 |
|
77 |
Call MPI_Reduce( time1, time1t, 1, dtype, MPI_Max, 0, comm, ier ) |
78 |
Call MPI_Reduce( time2, time2t, 1, dtype, MPI_Max, 0, comm, ier ) |
79 |
speed1 = 1.0e-6_l_*Real( nrep*nops, l_ )/Max( time1t, 1.0e-9_l_ ) |
80 |
speed2 = 1.0e-6_l_*Real( nrep*nops, l_ )/Max( time2t, 1.0e-9_l_ ) |
81 |
|
82 |
If ( me == 0 ) Print 1010, n, time1t/nrep, speed1, ok1, |
83 |
& time2t/nrep, speed2, ok2 |
84 |
Deallocate( idata, ddata , src ) |
85 |
Go To 10 |
86 |
20 If ( me == 0 ) Print 1020 |
87 |
|
88 |
end_time = MPI_Wtime() - start_time |
89 |
If (me == 0) Then |
90 |
Write(6,22) 'Walltime: ', end_time, " s" |
91 |
22 Format(A,F9.3,A) |
92 |
End If |
93 |
Call MPI_Finalize( ier ) |
94 |
! --------------------------------------------------------------------- |
95 |
1000 Format( 'Quicksort test: No. of procs. = ', i3/ |
96 |
& '-------------------------------------------------------', |
97 |
& '----------------'/, |
98 |
& ' Order | Integer | Integer | | Double |', |
99 |
& ' Double | |'/, |
100 |
& ' n | Time (s) | (Mop/s) | OK? | Time (s) |', |
101 |
& ' (Mop/s) | OK? |'/, |
102 |
& '-------------------------------------------------------', |
103 |
& '----------------' ) |
104 |
1010 Format( I7,' |', G11.4,' |', G11.4, '|', L3,' |', G11.4, |
105 |
& ' |', G11.4, '|', L3, ' |' ) |
106 |
1020 Format( '-------------------------------------------------------', |
107 |
& '----------------' ) |
108 |
c ---------------------------------------------------------------------- |
109 |
End Program mod2i |