root / synthbench / euroben-dm / mod2as / .svn / text-base / mod2as.f.svn-base @ 0:839f52ef7657
History | View | Annotate | Download (3.2 kB)
1 |
Program mod2as |
---|---|
2 |
! ---------------------------------------------------------------------- |
3 |
! --- Sparse Matrix-vector product from a CRS format matrix. |
4 |
! The vector to be multplied with and the result vector are assumed |
5 |
! to be full. |
6 |
! ---------------------------------------------------------------------- |
7 |
Use numerics |
8 |
Use dist_module |
9 |
Implicit None |
10 |
Include 'mpif.h' |
11 |
|
12 |
Integer, Allocatable :: indx(:), rowp(:) |
13 |
Real(l_), Allocatable :: matvals(:), invec(:), outvec(:) |
14 |
Real(l_) :: gtime, time, mflops |
15 |
Real(l_), Parameter :: MICRO = 1.0e-6_l_, TWO = 2.0_l_, |
16 |
& PERC = 1.0e2_l_ |
17 |
Real(l_) :: start_time, end_time |
18 |
Integer :: lrows, lelmts, ncols, nrows, nelmts |
19 |
Integer :: part |
20 |
Integer :: ierr |
21 |
Logical :: lok, ok |
22 |
! ---------------------------------------------------------------------- |
23 |
Call csetup |
24 |
If ( me == 0 ) Then |
25 |
Call state( 'mod2as ' ) |
26 |
Print 1000, nodes |
27 |
End If |
28 |
start_time = MPI_Wtime() |
29 |
Open( 1, File = 'mod2as.in' ) |
30 |
10 Read( 1, *, End = 20 ) ncols, nrows, nelmts |
31 |
lrows = part( nrows ) |
32 |
lelmts = part( nelmts ) |
33 |
Allocate( indx(lelmts), rowp(lrows), matvals(lelmts), |
34 |
& invec(ncols), outvec(lrows) ) |
35 |
Call getmatvec( ncols, lrows, lelmts, indx, rowp, matvals, |
36 |
& invec ) |
37 |
time = MPI_Wtime() |
38 |
Call spmxv( lrows, lelmts, indx, rowp, matvals, invec, outvec ) |
39 |
time = MPI_Wtime() - time |
40 |
Call MPI_Reduce( time, gtime, 1, MPI_Real8, MPI_Max, 0, |
41 |
& MPI_Comm_World, ierr ) |
42 |
mflops = TWO*MICRO*Real( nelmts, l_ )/gtime |
43 |
lok = .TRUE. |
44 |
Call check( ncols, lrows, lelmts, indx, rowp, outvec, lok ) |
45 |
Call MPI_Reduce( lok, ok, 1, MPI_Logical, MPI_Land, 0, |
46 |
& MPI_Comm_World, ierr ) |
47 |
Deallocate ( indx, rowp, matvals, invec, outvec ) |
48 |
If ( me == 0 ) Then |
49 |
Print 1010, nrows, ncols, |
50 |
& PERC*Real( nelmts, l_ )/Real( nrows*ncols, l_ ), |
51 |
& time, mflops, ok |
52 |
End If |
53 |
Go To 10 |
54 |
! ---------------------------------------------------------------------- |
55 |
20 If ( me == 0 ) Print 1020 |
56 |
end_time = MPI_Wtime() - start_time |
57 |
If (me == 0) Then |
58 |
Write(6,22) 'Walltime: ', end_time, " s" |
59 |
22 Format(A,F9.3,A) |
60 |
End If |
61 |
Call MPI_Finalize( ierr ) |
62 |
! ---------------------------------------------------------------------- |
63 |
1000 Format( 'Program mod2as: Sparse (CRS) Matrix-vector Multiply'/ |
64 |
& 'No. of processors = ', i5/ |
65 |
& '-------------------------------------------------------'/ |
66 |
& ' #Rows | #Cols | %Fill | Time(s) | Mflop/s |OK|'/ |
67 |
& '------------------------------------------------------|') |
68 |
1010 Format( i7, '|', i7, '|', f6.2, ' |', g13.5, '|', g13.5, '|', l2, |
69 |
& '|' ) |
70 |
1020 Format( '-------------------------------------------------------') |
71 |
! ---------------------------------------------------------------------- |
72 |
End Program mod2as |