2 C { dg-options "-fcheck=bounds -fdump-tree-optimized -fblas-matmul-limit=1 -O -fexternal-blas" }
3 C { dg-additional-sources blas_gemm_routines.f }
4 C Test calling of BLAS routines
15 real(8), dimension(3,2) :: a
16 real(8), dimension(2,3) :: at
17 real(8), dimension(2,4) :: b
18 real(8), dimension(4,2) :: bt
19 real(8), dimension(3,4) :: c
20 real(8), dimension(3,4) :: cres
21 real(8), dimension(:,:), allocatable
:: c_alloc
22 data a
/ 2., -3., 5., -7., 11., -13./
23 data b
/17., -23., 29., -31., 37., -39., 41., -47./
24 data cres
/195., -304., 384., 275., -428., 548., 347., -540.,
25 & 692., 411., -640., 816./
28 if (any
(c
/= cres
)) stop 31
32 c
= matmul
(transpose
(at
), b
)
33 if (any
(c
/= cres
)) stop 32
37 c
= matmul
(a
, transpose
(bt
))
38 if (any
(c
/= cres
)) stop 33
41 if (any
(c
/= cres
)) stop 34
45 c
= matmul
(transpose
(at
), b
)
46 if (any
(c
/= cres
)) stop 35
49 allocate
(c_alloc
(20,20))
51 c
= matmul
(a
, transpose
(bt
))
52 if (any
(c
/= cres
)) stop 36
58 real, dimension(3,2) :: a
59 real, dimension(2,3) :: at
60 real, dimension(2,4) :: b
61 real, dimension(4,2) :: bt
62 real, dimension(3,4) :: c
63 real, dimension(3,4) :: cres
64 real, dimension(:,:), allocatable
:: c_alloc
65 data a
/ 2., -3., 5., -7., 11., -13./
66 data b
/17., -23., 29., -31., 37., -39., 41., -47./
67 data cres
/195., -304., 384., 275., -428., 548., 347., -540.,
68 & 692., 411., -640., 816./
71 if (any
(c
/= cres
)) stop 21
75 c
= matmul
(transpose
(at
), b
)
76 if (any
(c
/= cres
)) stop 22
80 c
= matmul
(a
, transpose
(bt
))
81 if (any
(c
/= cres
)) stop 23
84 if (any
(c
/= cres
)) stop 24
88 c
= matmul
(transpose
(at
), b
)
89 if (any
(c
/= cres
)) stop 25
92 allocate
(c_alloc
(20,20))
94 c
= matmul
(a
, transpose
(bt
))
95 if (any
(c
/= cres
)) stop 26
101 complex, dimension(3,2) :: a
102 complex, dimension(2,3) :: at
, ah
103 complex, dimension(2,4) :: b
104 complex, dimension(4,2) :: bt
, bh
105 complex, dimension(3,4) :: c
106 complex, dimension(3,4) :: cres
107 complex, dimension(:,:), allocatable
:: c_alloc
109 data a
/ (2.,-3.), (-5.,7.), (11.,-13.), (17.,19), (-23., -29),
112 data b
/ (-41., 43.), (-47., 53.), (-59.,-61.), (-67., 71),
113 & ( 73.,79. ), (83.,-89.), (97.,-101.), (-107.,-109.)/
114 data cres
/(-1759.,217.), (2522.,-358.), (-396.,-2376.),
116 & (4322.,202.), (-1992.,-4584.), (3485.,3.), (-5408.,-244.),
117 & (2550.,5750.), (143.,-4379.), (-478.,6794.), (7104.,-2952.) /
120 if (any
(c
/= cres
)) stop 1
124 c
= matmul
(transpose
(at
), b
)
125 if (any
(c
/= cres
)) stop 2
129 c
= matmul
(a
, transpose
(bt
))
130 if (any
(c
/= cres
)) stop 3
132 ah
= transpose
(conjg
(a
))
134 c
= matmul
(conjg
(transpose
(ah
)), b
)
135 if (any
(c
/= cres
)) stop 4
137 bh
= transpose
(conjg
(b
))
139 c
= matmul
(a
, transpose
(conjg
(bh
)))
140 if (any
(c
/= cres
)) stop 5
142 c_alloc
= matmul
(a
,b
)
143 if (any
(c
/= cres
)) stop 6
147 c
= matmul
(transpose
(at
), b
)
148 if (any
(c
/= cres
)) stop 7
151 allocate
(c_alloc
(20,20))
153 c
= matmul
(a
, transpose
(bt
))
154 if (any
(c
/= cres
)) stop 8
156 ah
= transpose
(conjg
(a
))
158 c
= matmul
(conjg
(transpose
(ah
)), b
)
159 if (any
(c
/= cres
)) stop 9
162 allocate
(c_alloc
(0,0))
163 bh
= transpose
(conjg
(b
))
165 c
= matmul
(a
, transpose
(conjg
(bh
)))
166 if (any
(c
/= cres
)) stop 10
172 complex(8), dimension(3,2) :: a
173 complex(8), dimension(2,3) :: at
, ah
174 complex(8), dimension(2,4) :: b
175 complex(8), dimension(4,2) :: bt
, bh
176 complex(8), dimension(3,4) :: c
177 complex(8), dimension(3,4) :: cres
178 complex(8), dimension(:,:), allocatable
:: c_alloc
180 data a
/ (2.,-3.), (-5._8
,7.), (11.,-13.), (17.,19),
181 & (-23., -29), (-31., 37.)/
183 data b
/ (-41., 43.), (-47., 53.), (-59.,-61.), (-67., 71),
184 & ( 73.,79. ), (83.,-89.), (97.,-101.), (-107.,-109.)/
185 data cres
/(-1759.,217.), (2522.,-358.), (-396.,-2376.),
187 & (4322.,202.), (-1992.,-4584.), (3485.,3.), (-5408.,-244.),
188 & (2550.,5750.), (143.,-4379.), (-478.,6794.), (7104.,-2952.) /
191 if (any
(c
/= cres
)) stop 11
195 c
= matmul
(transpose
(at
), b
)
196 if (any
(c
/= cres
)) stop 12
200 c
= matmul
(a
, transpose
(bt
))
201 if (any
(c
/= cres
)) stop 13
203 ah
= transpose
(conjg
(a
))
205 c
= matmul
(conjg
(transpose
(ah
)), b
)
206 if (any
(c
/= cres
)) stop 14
208 bh
= transpose
(conjg
(b
))
210 c
= matmul
(a
, transpose
(conjg
(bh
)))
211 if (any
(c
/= cres
)) stop 15
213 c_alloc
= matmul
(a
,b
)
214 if (any
(c
/= cres
)) stop 16
218 c
= matmul
(transpose
(at
), b
)
219 if (any
(c
/= cres
)) stop 17
222 allocate
(c_alloc
(20,20))
224 c
= matmul
(a
, transpose
(bt
))
225 if (any
(c
/= cres
)) stop 18
227 ah
= transpose
(conjg
(a
))
229 c
= matmul
(conjg
(transpose
(ah
)), b
)
230 if (any
(c
/= cres
)) stop 19
233 allocate
(c_alloc
(0,0))
234 bh
= transpose
(conjg
(b
))
236 c
= matmul
(a
, transpose
(conjg
(bh
)))
237 if (any
(c
/= cres
)) stop 20
240 ! { dg
-final
{ scan
-tree
-dump
-times
"_gfortran_matmul" 0 "optimized" } }