Statistics
| Branch: | Revision:

root / synthbench / euroben-dm / mod2i / .svn / text-base / mod2i.f.svn-base @ 0:839f52ef7657

History | View | Annotate | Download (4.4 kB)

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