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 use accel_oct_m
23#ifdef HAVE_CUDA
24 use cuda_oct_m
25#endif
26 use debug_oct_m
27 use global_oct_m
28 use iso_c_binding
30 use types_oct_m
31
32 implicit none
33
34 private
35
36 public :: &
37 daccel_dot, &
38 zaccel_dot, &
51
52#if defined(HAVE_CUDA)
53 integer, parameter, public :: &
54 ACCEL_BLAS_LEFT = cublas_side_left, &
56
57 integer, parameter, public :: &
58 ACCEL_BLAS_LOWER = cublas_fill_mode_lower, &
60
61 integer, parameter, public :: &
62 ACCEL_BLAS_N = cublas_op_n, &
65
66 integer, parameter, public :: &
67 ACCEL_BLAS_DIAG_NON_UNIT = cublas_diag_non_unit, &
69#else
70 integer, parameter, public :: &
71 ACCEL_BLAS_LEFT = 0, &
73
74 integer, parameter, public :: &
75 ACCEL_BLAS_LOWER = 0, &
77
78 integer, parameter, public :: &
79 ACCEL_BLAS_N = 0, &
80 accel_blas_t = 1, &
81 accel_blas_c = 2
82
83 integer, parameter, public :: &
84 ACCEL_BLAS_DIAG_NON_UNIT = 0, &
86
87#endif
88
89 ! DOT
90 interface
91 subroutine cuda_blas_ddot(n, x, offx, incx, y, offy, incy, res, offres) bind(c, name="oct_cuda_blas_ddot")
92 use iso_c_binding
93 implicit none
94
95 integer(c_int64_t), intent(in) :: n
96 type(c_ptr), intent(in) :: x
97 integer(c_int64_t), intent(in) :: offx
98 integer(c_int64_t), intent(in) :: incx
99 type(c_ptr), intent(in) :: y
100 integer(c_int64_t), intent(in) :: offy
101 integer(c_int64_t), intent(in) :: incy
102 type(c_ptr), intent(inout) :: res
103 integer(c_int64_t), intent(in) :: offres
104 end subroutine cuda_blas_ddot
105
106 subroutine cuda_blas_zdotc(n, x, offx, incx, y, offy, incy, res, offres) bind(c, name="oct_cuda_blas_zdotc")
107 use iso_c_binding
108 implicit none
109
110 integer(c_int64_t), intent(in) :: n
111 type(c_ptr), intent(in) :: x
112 integer(c_int64_t), intent(in) :: offx
113 integer(c_int64_t), intent(in) :: incx
114 type(c_ptr), intent(in) :: y
115 integer(c_int64_t), intent(in) :: offy
116 integer(c_int64_t), intent(in) :: incy
117 type(c_ptr), intent(inout) :: res
118 integer(c_int64_t), intent(in) :: offres
119 end subroutine cuda_blas_zdotc
120
121 subroutine cuda_blas_zdotu(n, x, offx, incx, y, offy, incy, res, offres) bind(c, name="oct_cuda_blas_zdotu")
122 use iso_c_binding
123 implicit none
124
125 integer(c_int64_t), intent(in) :: n
126 type(c_ptr), intent(in) :: x
127 integer(c_int64_t), intent(in) :: offx
128 integer(c_int64_t), intent(in) :: incx
129 type(c_ptr), intent(in) :: y
130 integer(c_int64_t), intent(in) :: offy
131 integer(c_int64_t), intent(in) :: incy
132 type(c_ptr), intent(inout) :: res
133 integer(c_int64_t), intent(in) :: offres
134 end subroutine cuda_blas_zdotu
135 end interface
136
137 ! NRM2
138 interface
139 subroutine cuda_blas_dnrm2(n, x, offx, incx, res, offres) bind(c, name="oct_cuda_blas_dnrm2")
140 use iso_c_binding
141 implicit none
142
143 integer(c_int64_t), intent(in) :: n
144 type(c_ptr), intent(in) :: x
145 integer(c_int64_t), intent(in) :: offx
146 integer(c_int64_t), intent(in) :: incx
147 type(c_ptr), intent(inout) :: res
148 integer(c_int64_t), intent(in) :: offres
149 end subroutine cuda_blas_dnrm2
150
151 subroutine cuda_blas_znrm2(n, x, offx, incx, res, offres) bind(c, name="oct_cuda_blas_znrm2")
152 use iso_c_binding
153 implicit none
154
155 integer(c_int64_t), intent(in) :: n
156 type(c_ptr), intent(in) :: x
157 integer(c_int64_t), intent(in) :: offx
158 integer(c_int64_t), intent(in) :: incx
159 type(c_ptr), intent(inout) :: res
160 integer(c_int64_t), intent(in) :: offres
161 end subroutine cuda_blas_znrm2
162 end interface
163
164 ! GEMM
165 interface
166 subroutine cuda_blas_dgemm(transa, transb, m, n, k, alpha, A, lda, B, ldb, beta, C, ldc) &
167 bind(c, name="oct_cuda_blas_dgemm")
168 use iso_c_binding
169 implicit none
170
171 integer(c_int), intent(in) :: transa
172 integer(c_int), intent(in) :: transb
173 integer(c_int64_t), intent(in) :: m
174 integer(c_int64_t), intent(in) :: n
175 integer(c_int64_t), intent(in) :: k
176 real(c_double), intent(in) :: alpha
177 type(c_ptr), intent(in) :: A
178 integer(c_int64_t), intent(in) :: lda
179 type(c_ptr), intent(in) :: B
180 integer(c_int64_t), intent(in) :: ldb
181 real(c_double), intent(in) :: beta
182 type(c_ptr), intent(inout) :: C
183 integer(c_int64_t), intent(in) :: ldc
184 end subroutine cuda_blas_dgemm
185
186 subroutine cuda_blas_zgemm(transa, transb, m, n, k, alpha, A, lda, B, ldb, beta, C, ldc) &
187 bind(c, name="oct_cuda_blas_zgemm")
188 use iso_c_binding
189 implicit none
190
191 integer(c_int), intent(in) :: transa
192 integer(c_int), intent(in) :: transb
193 integer(c_int64_t), intent(in) :: m
194 integer(c_int64_t), intent(in) :: n
195 integer(c_int64_t), intent(in) :: k
196 complex(c_double_complex), intent(in) :: alpha
197 type(c_ptr), intent(in) :: A
198 integer(c_int64_t), intent(in) :: lda
199 type(c_ptr), intent(in) :: B
200 integer(c_int64_t), intent(in) :: ldb
201 complex(c_double_complex), intent(in) :: beta
202 type(c_ptr), intent(inout) :: C
203 integer(c_int64_t), intent(in) :: ldc
204 end subroutine cuda_blas_zgemm
205 end interface
206
207
208 ! GEMV
209 interface
210 subroutine cuda_blas_dgemv(transa, m, n, alpha, A, lda, x, incx, beta, y, incy) &
211 bind(c, name="oct_cuda_blas_dgemv")
212 use iso_c_binding
213 implicit none
214
215 integer(c_int), intent(in) :: transa
216 integer(c_int64_t), intent(in) :: m
217 integer(c_int64_t), intent(in) :: n
218 real(c_double), intent(in) :: alpha
219 type(c_ptr), intent(in) :: A
220 integer(c_int64_t), intent(in) :: lda
221 type(c_ptr), intent(in) :: x
222 integer(c_int64_t), intent(in) :: incx
223 real(c_double), intent(in) :: beta
224 type(c_ptr), intent(inout) :: y
225 integer(c_int64_t), intent(in) :: incy
226 end subroutine cuda_blas_dgemv
227
228 subroutine cuda_blas_zgemv(transa, m, n, alpha, A, lda, x, incx, beta, y, incy) &
229 bind(c, name="oct_cuda_blas_zgemv")
230 use iso_c_binding
231 implicit none
232
233 integer(c_int), intent(in) :: transa
234 integer(c_int64_t), intent(in) :: m
235 integer(c_int64_t), intent(in) :: n
236 complex(c_double_complex), intent(in) :: alpha
237 type(c_ptr), intent(in) :: A
238 integer(c_int64_t), intent(in) :: lda
239 type(c_ptr), intent(in) :: x
240 integer(c_int64_t), intent(in) :: incx
241 complex(c_double_complex), intent(in) :: beta
242 type(c_ptr), intent(inout) :: y
243 integer(c_int64_t), intent(in) :: incy
244 end subroutine cuda_blas_zgemv
245 end interface
246 ! SYRK/HERK
247 interface
248 subroutine cuda_blas_dsyrk(uplo, trans, n, k, alpha, A, lda, beta, C, ldc) bind(c, name="oct_cuda_blas_dsyrk")
249 use iso_c_binding
250 implicit none
251
252 integer(c_int), intent(in) :: uplo
253 integer(c_int), intent(in) :: trans
254 integer(c_int64_t), intent(in) :: n
255 integer(c_int64_t), intent(in) :: k
256 real(c_double), intent(in) :: alpha
257 type(c_ptr), intent(in) :: A
258 integer(c_int64_t), intent(in) :: lda
259 real(c_double), intent(in) :: beta
260 type(c_ptr), intent(inout) :: C
261 integer(c_int64_t), intent(in) :: ldc
262 end subroutine cuda_blas_dsyrk
264 subroutine cuda_blas_zherk(uplo, trans, n, k, alpha, A, lda, beta, C, ldc) bind(c, name="oct_cuda_blas_zherk")
265 use iso_c_binding
266 implicit none
267
268 integer(c_int), intent(in) :: uplo
269 integer(c_int), intent(in) :: trans
270 integer(c_int64_t), intent(in) :: n
271 integer(c_int64_t), intent(in) :: k
272 real(c_double), intent(in) :: alpha
273 type(c_ptr), intent(in) :: A
274 integer(c_int64_t), intent(in) :: lda
275 real(c_double), intent(in) :: beta
276 type(c_ptr), intent(inout) :: C
277 integer(c_int64_t), intent(in) :: ldc
278 end subroutine cuda_blas_zherk
279 end interface
280
281 ! TRSM
282 interface
283 subroutine cuda_blas_dtrsm(side, uplo, trans, diag, m, n, alpha, A, lda, B, ldb) &
284 bind(c, name="oct_cuda_blas_dtrsm")
285 use iso_c_binding
286 implicit none
288 integer(c_int), intent(in) :: side
289 integer(c_int), intent(in) :: uplo
290 integer(c_int), intent(in) :: trans
291 integer(c_int), intent(in) :: diag
292 integer(c_int64_t), intent(in) :: m
293 integer(c_int64_t), intent(in) :: n
294 real(c_double), intent(in) :: alpha
295 type(c_ptr), intent(in) :: A
296 integer(c_int64_t), intent(in) :: lda
297 type(c_ptr), intent(inout) :: B
298 integer(c_int64_t), intent(in) :: ldb
299 end subroutine cuda_blas_dtrsm
300
301 subroutine cuda_blas_ztrsm(side, uplo, trans, diag, m, n, alpha, A, lda, B, ldb) &
302 bind(c, name="oct_cuda_blas_ztrsm")
303 use iso_c_binding
304 implicit none
306 integer(c_int), intent(in) :: side
307 integer(c_int), intent(in) :: uplo
308 integer(c_int), intent(in) :: trans
309 integer(c_int), intent(in) :: diag
310 integer(c_int64_t), intent(in) :: m
311 integer(c_int64_t), intent(in) :: n
312 complex(c_double_complex), intent(in) :: alpha
313 type(c_ptr), intent(in) :: A
314 integer(c_int64_t), intent(in) :: lda
315 type(c_ptr), intent(inout) :: B
316 integer(c_int64_t), intent(in) :: ldb
317 end subroutine cuda_blas_ztrsm
318 end interface
319
320contains
321
322#include "undef.F90"
323#include "complex.F90"
324#include "accel_blas_inc.F90"
326#include "undef.F90"
327#include "real.F90"
328#include "accel_blas_inc.F90"
329
330end module accel_blas_oct_m
integer, parameter, public accel_blas_diag_unit
Definition: accel_blas.F90:160
subroutine, public zaccel_trsm(side, uplo, trans, diag, m, n, alpha, a, offa, lda, b, offb, ldb)
Definition: accel_blas.F90:492
subroutine, public daccel_gemv(transa, m, n, alpha, A, lda, x, incx, beta, y, incy)
Definition: accel_blas.F90:845
subroutine, public daccel_dot(n, x, offx, incx, y, offy, incy, res, offres)
Definition: accel_blas.F90:787
subroutine, public daccel_gemm(transa, transb, m, n, k, alpha, A, offa, lda, B, offb, ldb, beta, C, offc, ldc, async)
Definition: accel_blas.F90:757
subroutine, public daccel_nrm2(n, x, offx, incx, res, offres)
Definition: accel_blas.F90:825
subroutine, public daccel_trsm(side, uplo, trans, diag, m, n, alpha, a, offa, lda, b, offb, ldb)
Definition: accel_blas.F90:724
subroutine, public zaccel_nrm2(n, x, offx, incx, res, offres)
Definition: accel_blas.F90:593
integer, parameter, public accel_blas_right
Definition: accel_blas.F90:147
subroutine, public daccel_dotu(n, x, offx, incx, y, offy, incy, res, offres)
Definition: accel_blas.F90:806
subroutine, public daccel_herk(uplo, trans, n, k, alpha, a, offa, lda, beta, c, offc, ldc)
Definition: accel_blas.F90:699
subroutine, public zaccel_gemv(transa, m, n, alpha, A, lda, x, incx, beta, y, incy)
Definition: accel_blas.F90:613
subroutine, public zaccel_dotu(n, x, offx, incx, y, offy, incy, res, offres)
Definition: accel_blas.F90:574
integer, parameter, public accel_blas_upper
Definition: accel_blas.F90:151
integer, parameter, public accel_blas_t
Definition: accel_blas.F90:155
subroutine, public zaccel_gemm(transa, transb, m, n, k, alpha, A, offa, lda, B, offb, ldb, beta, C, offc, ldc, async)
Definition: accel_blas.F90:525
integer, parameter, public accel_blas_c
Definition: accel_blas.F90:155
subroutine, public zaccel_herk(uplo, trans, n, k, alpha, a, offa, lda, beta, c, offc, ldc)
Definition: accel_blas.F90:467
subroutine, public zaccel_dot(n, x, offx, incx, y, offy, incy, res, offres)
Definition: accel_blas.F90:555
integer, parameter, public cublas_side_left
Definition: cuda.F90:198
integer, parameter, public cublas_fill_mode_upper
Definition: cuda.F90:189
integer, parameter, public cublas_op_n
Definition: cuda.F90:178
integer, parameter, public cublas_op_c
Definition: cuda.F90:178
integer, parameter, public cublas_diag_non_unit
Definition: cuda.F90:169
integer, parameter, public cublas_op_t
Definition: cuda.F90:178
integer, parameter, public cublas_fill_mode_lower
Definition: cuda.F90:189
integer, parameter, public cublas_side_right
Definition: cuda.F90:198
integer, parameter, public cublas_diag_unit
Definition: cuda.F90:169