File: matmul_blas_1.f

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (240 lines) | stat: -rw-r--r-- 6,695 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
C { dg-do  run }
C { dg-options "-fcheck=bounds -fdump-tree-optimized -fblas-matmul-limit=1 -O -fexternal-blas" }
C { dg-additional-sources blas_gemm_routines.f }
C Test calling of BLAS routines

      program main
      call sub_s
      call sub_d
      call sub_c
      call sub_z
      end

      subroutine sub_d
      implicit none
      real(8), dimension(3,2) :: a
      real(8), dimension(2,3) :: at
      real(8), dimension(2,4) :: b
      real(8), dimension(4,2) :: bt
      real(8), dimension(3,4) :: c
      real(8), dimension(3,4) :: cres
      real(8), dimension(:,:), allocatable :: c_alloc
      data a / 2.,  -3.,  5.,  -7., 11., -13./
      data b /17., -23., 29., -31., 37., -39., 41., -47./
      data cres /195., -304.,  384.,  275., -428.,  548.,  347., -540.,
     &           692.,  411., -640.,  816./

      c = matmul(a,b)
      if (any (c /= cres)) stop 31

      at = transpose(a)
      c = (1.2,-2.2)
      c = matmul(transpose(at), b)
      if (any (c /= cres)) stop 32

      bt = transpose(b)
      c = (1.2,-2.1)
      c = matmul(a, transpose(bt))
      if (any (c /= cres)) stop 33

      c_alloc = matmul(a,b)
      if (any (c /= cres)) stop 34

      at = transpose(a)
      deallocate (c_alloc)
      c = matmul(transpose(at), b)
      if (any (c /= cres)) stop 35

      bt = transpose(b)
      allocate (c_alloc(20,20))
      c = (1.2,-2.1)
      c = matmul(a, transpose(bt))
      if (any (c /= cres)) stop 36

      end

      subroutine sub_s
      implicit none
      real, dimension(3,2) :: a
      real, dimension(2,3) :: at
      real, dimension(2,4) :: b
      real, dimension(4,2) :: bt
      real, dimension(3,4) :: c
      real, dimension(3,4) :: cres
      real, dimension(:,:), allocatable :: c_alloc
      data a / 2.,  -3.,  5.,  -7., 11., -13./
      data b /17., -23., 29., -31., 37., -39., 41., -47./
      data cres /195., -304.,  384.,  275., -428.,  548.,  347., -540.,
     &           692.,  411., -640.,  816./

      c = matmul(a,b)
      if (any (c /= cres)) stop 21

      at = transpose(a)
      c = (1.2,-2.2)
      c = matmul(transpose(at), b)
      if (any (c /= cres)) stop 22

      bt = transpose(b)
      c = (1.2,-2.1)
      c = matmul(a, transpose(bt))
      if (any (c /= cres)) stop 23

      c_alloc = matmul(a,b)
      if (any (c /= cres)) stop 24

      at = transpose(a)
      deallocate (c_alloc)
      c = matmul(transpose(at), b)
      if (any (c /= cres)) stop 25

      bt = transpose(b)
      allocate (c_alloc(20,20))
      c = (1.2,-2.1)
      c = matmul(a, transpose(bt))
      if (any (c /= cres)) stop 26

      end

      subroutine sub_c
      implicit none
      complex, dimension(3,2) :: a
      complex, dimension(2,3) :: at, ah
      complex, dimension(2,4) :: b
      complex, dimension(4,2) :: bt, bh
      complex, dimension(3,4) :: c
      complex, dimension(3,4) :: cres
      complex, dimension(:,:), allocatable :: c_alloc
      
      data a / (2.,-3.), (-5.,7.), (11.,-13.), (17.,19), (-23., -29),
     &     (-31., 37.)/

      data b / (-41., 43.), (-47., 53.), (-59.,-61.), (-67., 71),
     &     ( 73.,79. ), (83.,-89.), (97.,-101.), (-107.,-109.)/
      data cres /(-1759.,217.), (2522.,-358.), (-396.,-2376.),
     &     (-2789.,-11.),
     &     (4322.,202.), (-1992.,-4584.), (3485.,3.), (-5408.,-244.),
     &     (2550.,5750.), (143.,-4379.), (-478.,6794.), (7104.,-2952.) /

      c = matmul(a,b)
      if (any (c /= cres)) stop 1

      at = transpose(a)
      c = (1.2,-2.2)
      c = matmul(transpose(at), b)
      if (any (c /= cres)) stop 2

      bt = transpose(b)
      c = (1.2,-2.1)
      c = matmul(a, transpose(bt))
      if (any (c /= cres)) stop 3

      ah = transpose(conjg(a))
      c = (1.2,-2.2)
      c = matmul(conjg(transpose(ah)), b)
      if (any (c /= cres)) stop 4

      bh = transpose(conjg(b))
      c = (1.2,-2.2)
      c = matmul(a, transpose(conjg(bh)))
      if (any (c /= cres)) stop 5

      c_alloc = matmul(a,b)
      if (any (c /= cres)) stop 6

      at = transpose(a)
      deallocate (c_alloc)
      c = matmul(transpose(at), b)
      if (any (c /= cres)) stop 7

      bt = transpose(b)
      allocate (c_alloc(20,20))
      c = (1.2,-2.1)
      c = matmul(a, transpose(bt))
      if (any (c /= cres)) stop 8

      ah = transpose(conjg(a))
      c = (1.2,-2.2)
      c = matmul(conjg(transpose(ah)), b)
      if (any (c /= cres)) stop 9

      deallocate (c_alloc)
      allocate (c_alloc(0,0))
      bh = transpose(conjg(b))
      c = (1.2,-2.2)
      c = matmul(a, transpose(conjg(bh)))
      if (any (c /= cres)) stop 10

      end

      subroutine sub_z
      implicit none
      complex(8), dimension(3,2) :: a
      complex(8), dimension(2,3) :: at, ah
      complex(8), dimension(2,4) :: b
      complex(8), dimension(4,2) :: bt, bh
      complex(8), dimension(3,4) :: c
      complex(8), dimension(3,4) :: cres
      complex(8), dimension(:,:), allocatable :: c_alloc
      
      data a / (2.,-3.), (-5._8,7.), (11.,-13.), (17.,19),
     &         (-23., -29), (-31., 37.)/

      data b / (-41., 43.), (-47., 53.), (-59.,-61.), (-67., 71),
     &     ( 73.,79. ), (83.,-89.), (97.,-101.), (-107.,-109.)/
      data cres /(-1759.,217.), (2522.,-358.), (-396.,-2376.),
     &     (-2789.,-11.),
     &     (4322.,202.), (-1992.,-4584.), (3485.,3.), (-5408.,-244.),
     &     (2550.,5750.), (143.,-4379.), (-478.,6794.), (7104.,-2952.) /

      c = matmul(a,b)
      if (any (c /= cres)) stop 11

      at = transpose(a)
      c = (1.2,-2.2)
      c = matmul(transpose(at), b)
      if (any (c /= cres)) stop 12

      bt = transpose(b)
      c = (1.2,-2.1)
      c = matmul(a, transpose(bt))
      if (any (c /= cres)) stop 13

      ah = transpose(conjg(a))
      c = (1.2,-2.2)
      c = matmul(conjg(transpose(ah)), b)
      if (any (c /= cres)) stop 14

      bh = transpose(conjg(b))
      c = (1.2,-2.2)
      c = matmul(a, transpose(conjg(bh)))
      if (any (c /= cres)) stop 15

      c_alloc = matmul(a,b)
      if (any (c /= cres)) stop 16

      at = transpose(a)
      deallocate (c_alloc)
      c = matmul(transpose(at), b)
      if (any (c /= cres)) stop 17

      bt = transpose(b)
      allocate (c_alloc(20,20))
      c = (1.2,-2.1)
      c = matmul(a, transpose(bt))
      if (any (c /= cres)) stop 18

      ah = transpose(conjg(a))
      c = (1.2,-2.2)
      c = matmul(conjg(transpose(ah)), b)
      if (any (c /= cres)) stop 19

      deallocate (c_alloc)
      allocate (c_alloc(0,0))
      bh = transpose(conjg(b))
      c = (1.2,-2.2)
      c = matmul(a, transpose(conjg(bh)))
      if (any (c /= cres)) stop 20

      end
! { dg-final { scan-tree-dump-times "_gfortran_matmul" 0 "optimized" } }