1 ! Exercise three levels of parallelism using SGEMM from BLAS.
5 ! { dg-additional-options -Wuninitialized }
7 ! Explicitly set vector_length to 128 using a vector_length clause.
8 subroutine openacc_sgemm_128 (m
, n
, k
, alpha
, a
, b
, beta
, c
)
11 real :: a(k
,*), b(k
,*), c(m
,*)
15 ! { dg-note {'temp' was declared here} {} { target *-*-* } .-1 }
17 !$acc parallel loop copy(c(1:m,1:n)) copyin(a(1:k,1:m),b(1:k,1:n)) vector_length (128) firstprivate (temp)
18 ! { dg-warning {'temp' is used uninitialized} {} { target *-*-* } .-1 }
23 !$acc loop reduction(+:temp)
25 temp
= temp
+ a(l
,i
)*b(l
,j
)
30 c(i
,j
) = alpha
*temp
+ beta
*c(i
,j
)
34 end subroutine openacc_sgemm_128
36 subroutine host_sgemm (m
, n
, k
, alpha
, a
, b
, beta
, c
)
39 real :: a(k
,*), b(k
,*), c(m
,*)
48 temp
= temp
+ a(l
,i
)*b(l
,j
)
53 c(i
,j
) = alpha
*temp
+ beta
*c(i
,j
)
57 end subroutine host_sgemm
60 integer, parameter :: M
= 100, N
= 50, K
= 2000
61 real :: a(K
, M
), b(K
, N
), c(M
, N
), d (M
, N
), e (M
, N
)
75 call openacc_sgemm_128 (M
, N
, K
, alpha
, a
, b
, beta
, d
)
76 call host_sgemm (M
, N
, K
, alpha
, a
, b
, beta
, e
)
80 if (d(i
,j
) /= e(i
,j
)) stop 1