root / synthbench / euroben-dm / mod2a / libver.f @ 0:839f52ef7657
History | View | Annotate | Download (3.4 kB)
1 |
Subroutine libver( trans, m, n, a, lda, x, y, nrep, extime, |
---|---|
2 |
& perfor ) |
3 |
! ---------------------------------------------------------------------- |
4 |
! --- This routine performs the timing and calculates the performance |
5 |
! of the Special library version of Matrix-Vector multiplication |
6 |
! routine DGEMV. |
7 |
*** If DGEMV is not available, replace it with the appropriate *** |
8 |
*** equivalent. *** |
9 |
! |
10 |
! Parameters |
11 |
! ========== |
12 |
! |
13 |
! TRANS - Input - Determines the operation te be performed by MVSR |
14 |
! M, N - Input - Dimension of the problem |
15 |
! A(M,N) - Input - Contains the matrix A |
16 |
! LDA - Input - Leading Dimension of A |
17 |
! X(*) - Input - Contains the vector x |
18 |
! Y(*) - Output - Contains result vector y |
19 |
! NREP - Input - The initial repetition factor to increase |
20 |
! accuracy of the timing |
21 |
! EXTIME - Output - Contains the execution time for the operation |
22 |
! PERFOR - Output - Contains the performance in Mflop/s |
23 |
! ---------------------------------------------------------------------- |
24 |
Use numerics |
25 |
Include 'mpif.h' |
26 |
|
27 |
Character*1 :: trans |
28 |
Integer :: m, n, lda, nrep |
29 |
Real(l_) :: a(lda,*), x(*), y(*) |
30 |
Real(l_) :: extime, perfor |
31 |
! ---------------------------------------------------------------------- |
32 |
! --- Local Constants |
33 |
Real(l_), Parameter :: zero = 0.0_l_, p9 = 0.9_l_, one = 0.0_l_ |
34 |
! |
35 |
! --- Local variables |
36 |
Integer :: nop, k, krep, limrep |
37 |
Real(l_) :: t1, t2 |
38 |
Real(l_) :: alpha1, alphak, beta1, betak |
39 |
! ---------------------------------------------------------------------- |
40 |
! --- Operation count. |
41 |
|
42 |
nop = 2*m*n + m + n |
43 |
|
44 |
! --- Set the ALPHA and BETA parameters |
45 |
! |
46 |
alpha1 = one |
47 |
beta1 = zero |
48 |
alphak = p9 |
49 |
betak = p9 |
50 |
|
51 |
! --- Set the initial and maximum repetition factor. |
52 |
! |
53 |
krep = nrep |
54 |
limrep = 100 * nrep |
55 |
! |
56 |
10 Continue |
57 |
! |
58 |
If( trans == 'N' ) Then |
59 |
! |
60 |
****** Please insert the appropriate call for DGEMV, i.e. the library |
61 |
****** routine that calculates y := alpha*A*x + beta*y |
62 |
! |
63 |
t1 = MPI_Wtime() |
64 |
|
65 |
! --- Activate the following statement, or the appropriate equivalent |
66 |
canceled CALL DGEMV( TRANS, M, N, ALPHA1, A, LDA, X, 1, BETA1, Y, 1 ) |
67 |
Do 20 k = 2,krep |
68 |
|
69 |
! --- Activate the following statement, or the appropriate equivalent |
70 |
canceled CALL DGEMV( TRANS, M, N, ALPHAK, A, LDA, X, 1, BETAK, Y, 1 ) |
71 |
20 Continue |
72 |
t2 = MPI_Wtime() - t1 |
73 |
Else |
74 |
! |
75 |
****** Please insert the appropriate call for DGEMV, i.e. the library |
76 |
****** routine that calculates y := alpha*A'*x + beta*y |
77 |
! |
78 |
t1 = MPI_Wtime() |
79 |
|
80 |
! --- Activate the following statement, or the appropriate equivalent |
81 |
canceled CALL DGEMV( TRANS, M, N, ALPHA1, A, LDA, X, 1, BETA1, Y, 1 ) |
82 |
Do 30 k = 2,krep |
83 |
|
84 |
! --- Activate the following statement, or the appropriate equivalent |
85 |
canceled CALL DGEMV( TRANS, M, N, ALPHAK, A, LDA, X, 1, BETAK, Y, 1 ) |
86 |
30 Continue |
87 |
t2 = MPI_Wtime() - t1 |
88 |
Endif |
89 |
|
90 |
! --- Prevent smart compilers optimizing too much ... |
91 |
! |
92 |
Call ddummy( y, 1 ) |
93 |
! |
94 |
If ( t2 <= 1.0E-9_l_ .AND. krep < limrep ) Then |
95 |
krep = 5 * krep |
96 |
Goto 10 |
97 |
Endif |
98 |
! |
99 |
extime = t2 / krep |
100 |
perfor = ( nop * 1.0E-06_l_ )/Max( extime, 1.0E-9_l_ ) |
101 |
! ---------------------------------------------------------------------- |
102 |
End Subroutine libver |