Octopus
accel_blas.F90
Go to the documentation of this file.
1!! Copyright (C) 2016 X. Andrade
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include <global.h>
20
22#if defined(HAVE_CLBLAS) || defined(HAVE_CLBLAST)
23 use clblas_oct_m
24#endif
25 use accel_oct_m
26#ifdef HAVE_CUDA
27 use cuda_oct_m
28#endif
29 use debug_oct_m
30 use global_oct_m
31 use iso_c_binding
33 use types_oct_m
34
35 implicit none
36
37 private
38
39 public :: &
40 daccel_dot, &
41 zaccel_dot, &
54
55#ifdef HAVE_OPENCL
56 integer, parameter, public :: &
57 ACCEL_BLAS_LEFT = clblasleft, &
59
60 integer, parameter, public :: &
61 ACCEL_BLAS_LOWER = clblaslower, &
63
64 integer, parameter, public :: &
65 ACCEL_BLAS_N = clblasnotrans, &
68
69 integer, parameter, public :: &
70 ACCEL_BLAS_DIAG_NON_UNIT = clblasnonunit, &
72#elif defined(HAVE_CUDA)
73 integer, parameter, public :: &
74 ACCEL_BLAS_LEFT = cublas_side_left, &
76
77 integer, parameter, public :: &
78 ACCEL_BLAS_LOWER = cublas_fill_mode_lower, &
80
81 integer, parameter, public :: &
82 ACCEL_BLAS_N = cublas_op_n, &
85
86 integer, parameter, public :: &
87 ACCEL_BLAS_DIAG_NON_UNIT = cublas_diag_non_unit, &
89#else
90 integer, parameter, public :: &
91 ACCEL_BLAS_LEFT = 0, &
93
94 integer, parameter, public :: &
95 ACCEL_BLAS_LOWER = 0, &
97
98 integer, parameter, public :: &
99 ACCEL_BLAS_N = 0, &
100 accel_blas_t = 1, &
101 accel_blas_c = 2
102
103 integer, parameter, public :: &
104 ACCEL_BLAS_DIAG_NON_UNIT = 0, &
106
107#endif
108
109 ! DOT
110 interface
111 subroutine cuda_blas_ddot(handle, n, x, offx, incx, y, offy, incy, res, offres)
112 use iso_c_binding
113 use, intrinsic :: iso_fortran_env
115 implicit none
116
117 type(c_ptr), intent(in) :: handle
118 integer(int64), intent(in) :: n
119 type(c_ptr), intent(in) :: x
120 integer(int64), intent(in) :: offx
121 integer(int64), intent(in) :: incx
122 type(c_ptr), intent(in) :: y
123 integer(int64), intent(in) :: offy
124 integer(int64), intent(in) :: incy
125 type(c_ptr), intent(inout) :: res
126 integer(int64), intent(in) :: offres
127 end subroutine cuda_blas_ddot
128
129 subroutine cuda_blas_zdotc(handle, n, x, offx, incx, y, offy, incy, res, offres)
130 use iso_c_binding
131 use, intrinsic :: iso_fortran_env
132
133 implicit none
134
135 type(c_ptr), intent(in) :: handle
136 integer(int64), intent(in) :: n
137 type(c_ptr), intent(in) :: x
138 integer(int64), intent(in) :: offx
139 integer(int64), intent(in) :: incx
140 type(c_ptr), intent(in) :: y
141 integer(int64), intent(in) :: offy
142 integer(int64), intent(in) :: incy
143 type(c_ptr), intent(inout) :: res
144 integer(int64), intent(in) :: offres
145 end subroutine cuda_blas_zdotc
146
147 subroutine cuda_blas_zdotu(handle, n, x, offx, incx, y, offy, incy, res, offres)
148 use iso_c_binding
149 use, intrinsic :: iso_fortran_env
150
151 implicit none
152
153 type(c_ptr), intent(in) :: handle
154 integer(int64), intent(in) :: n
155 type(c_ptr), intent(in) :: x
156 integer(int64), intent(in) :: offx
157 integer(int64), intent(in) :: incx
158 type(c_ptr), intent(in) :: y
159 integer(int64), intent(in) :: offy
160 integer(int64), intent(in) :: incy
161 type(c_ptr), intent(inout) :: res
162 integer(int64), intent(in) :: offres
163 end subroutine cuda_blas_zdotu
164 end interface
165
166 ! NRM2
167 interface
168 subroutine cuda_blas_dnrm2(handle, n, x, offx, incx, res, offres)
169 use iso_c_binding
170 use, intrinsic :: iso_fortran_env
171
172 implicit none
173
174 type(c_ptr), intent(in) :: handle
175 integer(int64), intent(in) :: n
176 type(c_ptr), intent(in) :: x
177 integer(int64), intent(in) :: offx
178 integer(int64), intent(in) :: incx
179 type(c_ptr), intent(inout) :: res
180 integer(int64), intent(in) :: offres
181 end subroutine cuda_blas_dnrm2
182
183 subroutine cuda_blas_znrm2(handle, n, x, offx, incx, res, offres)
184 use iso_c_binding
185 use, intrinsic :: iso_fortran_env
187 implicit none
188
189 type(c_ptr), intent(in) :: handle
190 integer(int64), intent(in) :: n
191 type(c_ptr), intent(in) :: x
192 integer(int64), intent(in) :: offx
193 integer(int64), intent(in) :: incx
194 type(c_ptr), intent(inout) :: res
195 integer(int64), intent(in) :: offres
196 end subroutine cuda_blas_znrm2
197 end interface
198
199 ! GEMM
200 interface
201 subroutine cuda_blas_dgemm(handle, transa, transb, m, n, k, alpha, A, lda, B, ldb, beta, C, ldc)
202 use iso_c_binding
203 use, intrinsic :: iso_fortran_env
205 implicit none
206
207 type(c_ptr), intent(in) :: handle
208 integer, intent(in) :: transa
209 integer, intent(in) :: transb
210 integer(int64), intent(in) :: m
211 integer(int64), intent(in) :: n
212 integer(int64), intent(in) :: k
213 type(c_ptr), intent(in) :: alpha
214 type(c_ptr), intent(in) :: A
215 integer(int64), intent(in) :: lda
216 type(c_ptr), intent(in) :: B
217 integer(int64), intent(in) :: ldb
218 type(c_ptr), intent(in) :: beta
219 type(c_ptr), intent(inout) :: C
220 integer(int64), intent(in) :: ldc
221 end subroutine cuda_blas_dgemm
222
223 subroutine cuda_blas_zgemm(handle, transa, transb, m, n, k, alpha, A, lda, B, ldb, beta, C, ldc)
224 use iso_c_binding
225 use, intrinsic :: iso_fortran_env
226
227 implicit none
228
229 type(c_ptr), intent(in) :: handle
230 integer, intent(in) :: transa
231 integer, intent(in) :: transb
232 integer(int64), intent(in) :: m
233 integer(int64), intent(in) :: n
234 integer(int64), intent(in) :: k
235 type(c_ptr), intent(in) :: alpha
236 type(c_ptr), intent(in) :: A
237 integer(int64), intent(in) :: lda
238 type(c_ptr), intent(in) :: B
239 integer(int64), intent(in) :: ldb
240 type(c_ptr), intent(in) :: beta
241 type(c_ptr), intent(inout) :: C
242 integer(int64), intent(in) :: ldc
243 end subroutine cuda_blas_zgemm
244 end interface
245
246
247 ! GEMV
248 interface
249 subroutine cuda_blas_dgemv(handle, transa, m, n, alpha, A, lda, x, incx, beta, y, incy)
250 use iso_c_binding
251 use, intrinsic :: iso_fortran_env
252
253 implicit none
254
255 type(c_ptr), intent(in) :: handle
256 integer, intent(in) :: transa
257 integer(int64), intent(in) :: m
258 integer(int64), intent(in) :: n
259 type(c_ptr), intent(in) :: alpha
260 type(c_ptr), intent(in) :: A
261 integer(int64), intent(in) :: lda
262 type(c_ptr), intent(in) :: x
263 integer(int64), intent(in) :: incx
264 type(c_ptr), intent(in) :: beta
265 type(c_ptr), intent(inout) :: y
266 integer(int64), intent(in) :: incy
267 end subroutine cuda_blas_dgemv
268
269 subroutine cuda_blas_zgemv(handle, transa, m, n, alpha, A, lda, x, incx, beta, y, incy)
270 use iso_c_binding
271 use, intrinsic :: iso_fortran_env
272
273 implicit none
274
275 type(c_ptr), intent(in) :: handle
276 integer, intent(in) :: transa
277 integer(int64), intent(in) :: m
278 integer(int64), intent(in) :: n
279 type(c_ptr), intent(in) :: alpha
280 type(c_ptr), intent(in) :: A
281 integer(int64), intent(in) :: lda
282 type(c_ptr), intent(in) :: x
283 integer(int64), intent(in) :: incx
284 type(c_ptr), intent(in) :: beta
285 type(c_ptr), intent(inout) :: y
286 integer(int64), intent(in) :: incy
287 end subroutine cuda_blas_zgemv
288 end interface
289 ! SYRK/HERK
290 interface
291 subroutine cuda_blas_dsyrk(handle, uplo, trans, n, k, alpha, A, lda, beta, C, ldc)
292 use iso_c_binding
293 use, intrinsic :: iso_fortran_env
294
295 implicit none
296
297 type(c_ptr), intent(in) :: handle
298 integer, intent(in) :: uplo
299 integer, intent(in) :: trans
300 integer(int64), intent(in) :: n
301 integer(int64), intent(in) :: k
302 type(c_ptr), intent(in) :: alpha
303 type(c_ptr), intent(in) :: A
304 integer(int64), intent(in) :: lda
305 type(c_ptr), intent(in) :: beta
306 type(c_ptr), intent(inout) :: C
307 integer(int64), intent(in) :: ldc
308 end subroutine cuda_blas_dsyrk
309
310 subroutine cuda_blas_zherk(handle, uplo, trans, n, k, alpha, A, lda, beta, C, ldc)
311 use iso_c_binding
312 use, intrinsic :: iso_fortran_env
313
314 implicit none
315
316 type(c_ptr), intent(in) :: handle
317 integer, intent(in) :: uplo
318 integer, intent(in) :: trans
319 integer(int64), intent(in) :: n
320 integer(int64), intent(in) :: k
321 type(c_ptr), intent(in) :: alpha
322 type(c_ptr), intent(in) :: A
323 integer(int64), intent(in) :: lda
324 type(c_ptr), intent(in) :: beta
325 type(c_ptr), intent(inout) :: C
326 integer(int64), intent(in) :: ldc
327 end subroutine cuda_blas_zherk
328 end interface
329
330 ! TRSM
331 interface
332 subroutine cuda_blas_dtrsm(handle, side, uplo, trans, diag, m, n, alpha, A, lda, B, ldb)
333 use iso_c_binding
334 use, intrinsic :: iso_fortran_env
335
336 implicit none
337
338 type(c_ptr), intent(in) :: handle
339 integer, intent(in) :: side
340 integer, intent(in) :: uplo
341 integer, intent(in) :: trans
342 integer, intent(in) :: diag
343 integer(int64), intent(in) :: m
344 integer(int64), intent(in) :: n
345 type(c_ptr), intent(in) :: alpha
346 type(c_ptr), intent(in) :: A
347 integer(int64), intent(in) :: lda
348 type(c_ptr), intent(inout) :: B
349 integer(int64), intent(in) :: ldb
350 end subroutine cuda_blas_dtrsm
351
352 subroutine cuda_blas_ztrsm(handle, side, uplo, trans, diag, m, n, alpha, A, lda, B, ldb)
353 use iso_c_binding
354 use, intrinsic :: iso_fortran_env
355
356 implicit none
357
358 type(c_ptr), intent(in) :: handle
359 integer, intent(in) :: side
360 integer, intent(in) :: uplo
361 integer, intent(in) :: trans
362 integer, intent(in) :: diag
363 integer(int64), intent(in) :: m
364 integer(int64), intent(in) :: n
365 type(c_ptr), intent(in) :: alpha
366 type(c_ptr), intent(in) :: A
367 integer(int64), intent(in) :: lda
368 type(c_ptr), intent(inout) :: B
369 integer(int64), intent(in) :: ldb
370 end subroutine cuda_blas_ztrsm
371 end interface
372
373contains
374
375#include "undef.F90"
376#include "complex.F90"
377#include "accel_blas_inc.F90"
378
379#include "undef.F90"
380#include "real.F90"
381#include "accel_blas_inc.F90"
382
383end module accel_blas_oct_m
integer, parameter, public accel_blas_diag_unit
Definition: accel_blas.F90:162
subroutine, public zaccel_trsm(side, uplo, trans, diag, m, n, alpha, a, offa, lda, b, offb, ldb)
Definition: accel_blas.F90:568
subroutine, public daccel_gemv(transa, m, n, alpha, A, lda, x, incx, beta, y, incy)
subroutine, public daccel_gemm(transa, transb, m, n, k, alpha, A, offa, lda, B, offb, ldb, beta, C, offc, ldc)
subroutine, public daccel_dot(n, x, offx, incx, y, offy, incy, res, offres)
subroutine, public daccel_nrm2(n, x, offx, incx, res, offres)
subroutine, public daccel_trsm(side, uplo, trans, diag, m, n, alpha, a, offa, lda, b, offb, ldb)
subroutine, public zaccel_nrm2(n, x, offx, incx, res, offres)
Definition: accel_blas.F90:803
subroutine, public zaccel_gemm(transa, transb, m, n, k, alpha, A, offa, lda, B, offb, ldb, beta, C, offc, ldc)
Definition: accel_blas.F90:626
integer, parameter, public accel_blas_right
Definition: accel_blas.F90:149
subroutine, public daccel_dotu(n, x, offx, incx, y, offy, incy, res, offres)
subroutine, public daccel_herk(uplo, trans, n, k, alpha, a, offa, lda, beta, c, offc, ldc)
Definition: accel_blas.F90:974
subroutine, public zaccel_gemv(transa, m, n, alpha, A, lda, x, incx, beta, y, incy)
Definition: accel_blas.F90:847
subroutine, public zaccel_dotu(n, x, offx, incx, y, offy, incy, res, offres)
Definition: accel_blas.F90:750
integer, parameter, public accel_blas_upper
Definition: accel_blas.F90:153
integer, parameter, public accel_blas_t
Definition: accel_blas.F90:157
integer, parameter, public accel_blas_c
Definition: accel_blas.F90:157
subroutine, public zaccel_herk(uplo, trans, n, k, alpha, a, offa, lda, beta, c, offc, ldc)
Definition: accel_blas.F90:500
subroutine, public zaccel_dot(n, x, offx, incx, y, offy, incy, res, offres)
Definition: accel_blas.F90:698
integer, parameter, public clblasunit
Definition: clblas.F90:160
integer, parameter, public clblasupper
Definition: clblas.F90:156
integer, parameter, public clblasnonunit
Definition: clblas.F90:160
integer, parameter, public clblasleft
Definition: clblas.F90:164
integer, parameter, public clblastrans
Definition: clblas.F90:151
integer, parameter, public clblaslower
Definition: clblas.F90:156
integer, parameter, public clblasright
Definition: clblas.F90:164
integer, parameter, public clblasconjtrans
Definition: clblas.F90:151
integer, parameter, public clblasnotrans
Definition: clblas.F90:151
integer, parameter, public cublas_side_left
Definition: cuda.F90:182
integer, parameter, public cublas_fill_mode_upper
Definition: cuda.F90:173
integer, parameter, public cublas_op_n
Definition: cuda.F90:162
integer, parameter, public cublas_op_c
Definition: cuda.F90:162
integer, parameter, public cublas_diag_non_unit
Definition: cuda.F90:153
integer, parameter, public cublas_op_t
Definition: cuda.F90:162
integer, parameter, public cublas_fill_mode_lower
Definition: cuda.F90:173
integer, parameter, public cublas_side_right
Definition: cuda.F90:182
integer, parameter, public cublas_diag_unit
Definition: cuda.F90:153