Octopus
clblas.F90
Go to the documentation of this file.
1!! Copyright (C) 2016 X. Andrade
2!! Copyright (C) 2022 N. Tancogne-Dejean
3!!
4!! This program is free software; you can redistribute it and/or modify
5!! it under the terms of the GNU General Public License as published by
6!! the Free Software Foundation; either version 2, or (at your option)
7!! any later version.
8!!
9!! This program is distributed in the hope that it will be useful,
10!! but WITHOUT ANY WARRANTY; without even the implied warranty of
11!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12!! GNU General Public License for more details.
13!!
14!! You should have received a copy of the GNU General Public License
15!! along with this program; if not, write to the Free Software
16!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17!! 02110-1301, USA.
18!!
19
20#include "global.h"
21
22module clblas_oct_m
23#ifdef HAVE_OPENCL
24 use cl
25#endif
26
27 implicit none
28
29 private
30
31#ifdef HAVE_OPENCL
32 public :: &
33#ifdef HAVE_CLBLAS
37#endif
46 clblasddot, &
51#endif
52
53#ifdef HAVE_CLBLAS
54 integer, public, parameter :: &
55 clblasRowMajor = 0, &
57
58 integer, public, parameter :: &
59 clblasNoTrans = 0, &
60 clblastrans = 1, &
62
63 integer, public, parameter :: &
64 clblasUpper = 0, &
65 clblaslower = 1
66
67 integer, public, parameter :: &
68 clblasUnit = 0, &
70
71 integer, public, parameter :: &
72 clblasLeft = 0, &
73 clblasright = 1
74#endif
75
76#ifdef HAVE_CLBLAST
77 integer, public, parameter :: &
78 clblasRowMajor = 101, &
80
81 integer, public, parameter :: &
82 clblasNoTrans = 111, &
83 clblastrans = 112, &
84 clblasconjtrans = 113
85
86 integer, public, parameter :: &
87 clblasUpper = 121, &
88 clblaslower = 122
89
90 integer, public, parameter :: &
91 clblasUnit = 132, &
92 clblasnonunit = 131
93
94 integer, public, parameter :: &
95 clblasLeft = 141, &
96 clblasright = 142
97#endif
98
99#if defined(HAVE_CLBLAS) || defined(HAVE_CLBLAST)
100 integer, public, parameter :: &
101 clblasSuccess = cl_success, &
102 clblasinvalidvalue = cl_invalid_value, &
103 clblasinvalidcommandqueue = cl_invalid_command_queue, &
104 clblasinvalidcontext = cl_invalid_context, &
105 clblasinvalidmemobject = cl_invalid_mem_object, &
106 clblasinvaliddevice = cl_invalid_device, &
107 clblasinvalideventwaitlist = cl_invalid_event_wait_list, &
108 clblasoutofresources = cl_out_of_resources, &
109 clblasoutofhostmemory = cl_out_of_host_memory, &
110 clblasinvalidoperation = cl_invalid_operation, &
111 clblascompilernotavailable = cl_compiler_not_available, &
112 clblasbuildprogramfailure = cl_build_program_failure
113
114 integer, public, parameter :: &
115 clblasNotImplemented = -1024, &
116 clblasnotinitialized = -1023, &
117 clblasinvalidmata = -1022, &
118 clblasinvalidmatb = -1021, &
119 clblasinvalidmatc = -1020, &
120 clblasinvalidvecx = -1019, &
121 clblasinvalidvecy = -1018, &
122 clblasinvaliddim = -1017, &
123 clblasinvalidleaddima = -1016, &
124 clblasinvalidleaddimb = -1015, &
125 clblasinvalidleaddimc = -1014, &
126 clblasinvalidincx = -1013, &
127 clblasinvalidincy = -1012, &
133
134 ! Custom additional status codes for CLBlast
135 integer, public, parameter :: &
136 clblastInsufficientMemoryTemp = -2050, &! Temporary buffer provided to GEMM routine is too small
137 clblastinvalidbatchcount = -2049, &! The batch count needs to be positive
138 clblastinvalidoverridekernel = -2048, &! Trying to override parameters for an invalid kernel
139 clblastmissingoverrideparameter = -2047, &! Missing override parameter(s) for the target kernel
140 clblastinvalidlocalmemusage = -2046, &! Not enough local memory available on this device
141 clblastnohalfprecision = -2045, &! Half precision (16-bits) not supported by the device
142 clblastnodoubleprecision = -2044, &! Double precision (64-bits) not supported by the device
143 clblastinvalidvectorscalar = -2043, &! The unit-sized vector is not a valid OpenCL buffer
144 clblastinsufficientmemoryscalar = -2042, &! The unit-sized vector`s OpenCL buffer is too small
145 clblastdatabaseerror = -2041, &! Entry for the device was not found in the database
146 clblastunknownerror = -2040, &! A catch-all error code representing an unspecified error
147 clblastunexpectederror = -2039 ! A catch-all error code representing an unexpected exception
148#endif
149
150 ! SUPPORT FUNCTIONS
152#ifdef HAVE_CLBLAS
153 interface clblasgetversion
154 subroutine clblasgetversion_low(major, minor, patch, status)
155 implicit none
157 integer, intent(out) :: major
158 integer, intent(out) :: minor
159 integer, intent(out) :: patch
160 integer, intent(out) :: status
161 end subroutine clblasgetversion_low
162 end interface clblasgetversion
163
164 interface clblassetup
165 subroutine clblassetup_low(status)
166 implicit none
167
168 integer, intent(out) :: status
169 end subroutine clblassetup_low
170 end interface clblassetup
171
172 interface clblasteardown
173 subroutine clblasteardown_low()
174 end subroutine clblasteardown_low
175 end interface clblasteardown
176#endif
177
178
179#if defined(HAVE_CLBLAS) || defined(HAVE_CLBLAST)
180 ! -------------------------------------------------
181
182 interface clblasdtrsmex
183 subroutine clblasdtrsmex_low(order, side, uplo, transA, diag, M, N, alpha, A, offA, lda, B, offB, ldb, commandQueue, status)
184 use cl
185
186 implicit none
187
188 integer, intent(in) :: order
189 integer, intent(in) :: side
190 integer, intent(in) :: uplo
191 integer, intent(in) :: transa
192 integer, intent(in) :: diag
193 integer(8), intent(in) :: m
194 integer(8), intent(in) :: n
195 real(8), intent(in) :: alpha
196 type(cl_mem), intent(inout) :: a
197 integer(8), intent(in) :: offa
198 integer(8), intent(in) :: lda
199 type(cl_mem), intent(inout) :: b
200 integer(8), intent(in) :: offb
201 integer(8), intent(in) :: ldb
202 type(cl_command_queue), intent(inout) :: commandqueue
203 integer, intent(out) :: status
204 end subroutine clblasdtrsmex_low
205 end interface clblasdtrsmex
206
207 ! -------------------------------------------------
208
209 interface clblasztrsmex
210 subroutine clblasztrsmex_low(order, side, uplo, transA, diag, M, N, alpha, A, offA, lda, B, offB, ldb, commandQueue, status)
211 use cl
212
213 implicit none
214
215 integer, intent(in) :: order
216 integer, intent(in) :: side
217 integer, intent(in) :: uplo
218 integer, intent(in) :: transa
219 integer, intent(in) :: diag
220 integer(8), intent(in) :: m
221 integer(8), intent(in) :: n
222 complex(8), intent(in) :: alpha
223 type(cl_mem), intent(inout) :: a
224 integer(8), intent(in) :: offa
225 integer(8), intent(in) :: lda
226 type(cl_mem), intent(inout) :: b
227 integer(8), intent(in) :: offb
228 integer(8), intent(in) :: ldb
229 type(cl_command_queue), intent(inout) :: commandqueue
230 integer, intent(out) :: status
231 end subroutine clblasztrsmex_low
232 end interface clblasztrsmex
233
234 ! -------------------------------------------------
235
236 interface clblasdgemvex
237 subroutine clblasdgemvex_low(order, transA, M, N, &
238 alpha, A, offA, lda, X, offX, incx, beta, Y, offY, incy, commandQueue, status)
239 use cl
240
241 implicit none
242
243 integer, intent(in) :: order
244 integer, intent(in) :: transa
245 integer(8), intent(in) :: m
246 integer(8), intent(in) :: N
247 real(8), intent(in) :: alpha
248 type(cl_mem), intent(in) :: A
249 integer(8), intent(in) :: offA
250 integer(8), intent(in) :: lda
251 type(cl_mem), intent(in) :: X
252 integer(8), intent(in) :: offX
253 integer(8), intent(in) :: incx
254 real(8), intent(in) :: beta
255 type(cl_mem), intent(inout) :: Y
256 integer(8), intent(in) :: offY
257 integer(8), intent(in) :: incy
258 type(cl_command_queue), intent(inout) :: CommandQueue
259 integer, intent(out) :: status
260 end subroutine clblasdgemvex_low
261 end interface clblasdgemvex
262
263 ! -------------------------------------------------
264
266 subroutine clblaszgemvex_low(order, transA, M, N, &
267 alpha, A, offA, lda, X, offX, incx, beta, Y, offY, incy, commandQueue, status)
268 use cl
269
270 implicit none
271
272 integer, intent(in) :: order
273 integer, intent(in) :: transA
274 integer(8), intent(in) :: M
275 integer(8), intent(in) :: N
276 complex(8), intent(in) :: alpha
277 type(cl_mem), intent(in) :: A
278 integer(8), intent(in) :: offA
279 integer(8), intent(in) :: lda
280 type(cl_mem), intent(in) :: X
281 integer(8), intent(in) :: offX
282 integer(8), intent(in) :: incx
283 complex(8), intent(in) :: beta
284 type(cl_mem), intent(inout) :: Y
285 integer(8), intent(in) :: offY
286 integer(8), intent(in) :: incy
287 type(cl_command_queue), intent(inout) :: CommandQueue
288 integer, intent(out) :: status
289 end subroutine clblaszgemvex_low
290 end interface clblaszgemvex
291
292
293 ! -------------------------------------------------
294
295 interface clblasdgemmex
296 subroutine clblasdgemmex_low(order, transA, transB, M, N, K, &
297 alpha, A, offA, lda, B, offB, ldb, beta, C, offC, ldc, commandQueue, status)
298 use cl
299
300 implicit none
301
302 integer, intent(in) :: order
303 integer, intent(in) :: transA
304 integer, intent(in) :: transB
305 integer(8), intent(in) :: M
306 integer(8), intent(in) :: N
307 integer(8), intent(in) :: K
308 real(8), intent(in) :: alpha
309 type(cl_mem), intent(in) :: A
310 integer(8), intent(in) :: offA
311 integer(8), intent(in) :: lda
312 type(cl_mem), intent(in) :: B
313 integer(8), intent(in) :: offB
314 integer(8), intent(in) :: ldb
315 real(8), intent(in) :: beta
316 type(cl_mem), intent(inout) :: C
317 integer(8), intent(in) :: offC
318 integer(8), intent(in) :: ldc
319 type(cl_command_queue), intent(inout) :: CommandQueue
320 integer, intent(out) :: status
321 end subroutine clblasdgemmex_low
322 end interface clblasdgemmex
323
324 ! -------------------------------------------------
325
326 interface clblaszgemmex
327 subroutine clblaszgemmex_low(order, transA, transB, M, N, K, &
328 alpha, A, offA, lda, B, offB, ldb, beta, C, offC, ldc, commandQueue, status)
329 use cl
331 implicit none
332
333 integer, intent(in) :: order
334 integer, intent(in) :: transA
335 integer, intent(in) :: transB
336 integer(8), intent(in) :: M
337 integer(8), intent(in) :: N
338 integer(8), intent(in) :: K
339 complex(8), intent(in) :: alpha
340 type(cl_mem), intent(in) :: A
341 integer(8), intent(in) :: offA
342 integer(8), intent(in) :: lda
343 type(cl_mem), intent(in) :: B
344 integer(8), intent(in) :: offB
345 integer(8), intent(in) :: ldb
346 complex(8), intent(in) :: beta
347 type(cl_mem), intent(inout) :: C
348 integer(8), intent(in) :: offC
349 integer(8), intent(in) :: ldc
350 type(cl_command_queue), intent(inout) :: CommandQueue
351 integer, intent(out) :: status
352 end subroutine clblaszgemmex_low
353 end interface clblaszgemmex
354
355 ! -------------------------------------------------
356
357 interface clblasdsyrkex
358 subroutine clblasdsyrkex_low(order, uplo, transA, N, K, &
359 alpha, A, offA, lda, beta, C, offC, ldc, commandQueue, status)
360 use cl
361
362 implicit none
363
364 integer, intent(in) :: order
365 integer, intent(in) :: uplo
366 integer, intent(in) :: transA
367 integer(8), intent(in) :: N
368 integer(8), intent(in) :: K
369 real(8), intent(in) :: alpha
370 type(cl_mem), intent(in) :: A
371 integer(8), intent(in) :: offA
372 integer(8), intent(in) :: lda
373 real(8), intent(in) :: beta
374 type(cl_mem), intent(inout) :: C
375 integer(8), intent(in) :: offC
376 integer(8), intent(in) :: ldc
377 type(cl_command_queue), intent(inout) :: CommandQueue
378 integer, intent(out) :: status
379 end subroutine clblasdsyrkex_low
380 end interface clblasdsyrkex
381 ! -------------------------------------------------
382
383 interface clblaszherkex
384 subroutine clblaszherkex_low(order, uplo, transA, N, K, &
385 alpha, A, offA, lda, beta, C, offC, ldc, commandQueue, status)
386 use cl
387
388 implicit none
390 integer, intent(in) :: order
391 integer, intent(in) :: uplo
392 integer, intent(in) :: transA
393 integer(8), intent(in) :: N
394 integer(8), intent(in) :: K
395 real(8), intent(in) :: alpha
396 type(cl_mem), intent(in) :: A
397 integer(8), intent(in) :: offA
398 integer(8), intent(in) :: lda
399 real(8), intent(in) :: beta
400 type(cl_mem), intent(inout) :: C
401 integer(8), intent(in) :: offC
402 integer(8), intent(in) :: ldc
403 type(cl_command_queue), intent(inout) :: CommandQueue
404 integer, intent(out) :: status
405 end subroutine clblaszherkex_low
406 end interface clblaszherkex
407
408
409 ! --------------------------------------------------
410
411 interface clblasddot
412 subroutine clblasddot_low(N, dotProduct, offDP, X, offx, incx, Y, offY, incy, scratchBuff, CommandQueue, status)
413 use cl
414
415 implicit none
416
417 integer(8), intent(in) :: N
418 type(cl_mem), intent(inout) :: dotProduct
419 integer(8), intent(in) :: offDP
420 type(cl_mem), intent(in) :: X
421 integer(8), intent(in) :: offX
422 integer, intent(in) :: incx
423 type(cl_mem), intent(in) :: Y
424 integer(8), intent(in) :: offy
425 integer, intent(in) :: incy
426 type(cl_mem), intent(inout) :: scratchBuff
427 type(cl_command_queue), intent(inout) :: CommandQueue
428 integer, intent(out) :: status
429 end subroutine clblasddot_low
430 end interface clblasddot
431
432
433 ! --------------------------------------------------
434
435 interface clblaszdotc
436 subroutine clblaszdotc_low(N, dotProduct, offDP, X, offx, incx, Y, offY, incy, scratchBuff, CommandQueue, status)
437 use cl
438
439 implicit none
440
441 integer(8), intent(in) :: N
442 type(cl_mem), intent(inout) :: dotProduct
443 integer(8), intent(in) :: offDP
444 type(cl_mem), intent(in) :: X
445 integer(8), intent(in) :: offX
446 integer, intent(in) :: incx
447 type(cl_mem), intent(in) :: Y
448 integer(8), intent(in) :: offy
449 integer, intent(in) :: incy
450 type(cl_mem), intent(inout) :: scratchBuff
451 type(cl_command_queue), intent(inout) :: CommandQueue
452 integer, intent(out) :: status
453 end subroutine clblaszdotc_low
454 end interface clblaszdotc
455
456 ! --------------------------------------------------
457
458 interface clblaszdotu
459 subroutine clblaszdotu_low(N, dotProduct, offDP, X, offx, incx, Y, offY, incy, scratchBuff, CommandQueue, status)
460 use cl
461
462 implicit none
463
464 integer(8), intent(in) :: N
465 type(cl_mem), intent(inout) :: dotProduct
466 integer(8), intent(in) :: offDP
467 type(cl_mem), intent(in) :: X
468 integer(8), intent(in) :: offX
469 integer, intent(in) :: incx
470 type(cl_mem), intent(in) :: Y
471 integer(8), intent(in) :: offy
472 integer, intent(in) :: incy
473 type(cl_mem), intent(inout) :: scratchBuff
474 type(cl_command_queue), intent(inout) :: CommandQueue
475 integer, intent(out) :: status
476 end subroutine clblaszdotu_low
477 end interface clblaszdotu
478
479
480 ! --------------------------------------------------
481
482 interface clblasdnrm2
483 subroutine clblasdnrm2_low(N, NRM2, offNRM2, X, offx, incx, scratchBuff, CommandQueue, status)
484 use cl
485
486 implicit none
487
488 integer(8), intent(in) :: N
489 type(cl_mem), intent(inout) :: NRM2
490 integer(8), intent(in) :: offNRM2
491 type(cl_mem), intent(in) :: X
492 integer(8), intent(in) :: offX
493 integer, intent(in) :: incx
494 type(cl_mem), intent(inout) :: scratchBuff
495 type(cl_command_queue), intent(inout) :: CommandQueue
496 integer, intent(out) :: status
497 end subroutine clblasdnrm2_low
498 end interface clblasdnrm2
499
500 ! --------------------------------------------------
501
502 interface clblasdznrm2
503 subroutine clblasdznrm2_low(N, NRM2, offNRM2, X, offx, incx, scratchBuff, CommandQueue, status)
504 use cl
506 implicit none
507
508 integer(8), intent(in) :: N
509 type(cl_mem), intent(inout) :: NRM2
510 integer(8), intent(in) :: offNRM2
511 type(cl_mem), intent(in) :: X
512 integer(8), intent(in) :: offX
513 integer, intent(in) :: incx
514 type(cl_mem), intent(inout) :: scratchBuff
515 type(cl_command_queue), intent(inout) :: CommandQueue
516 integer, intent(out) :: status
517 end subroutine clblasdznrm2_low
518 end interface clblasdznrm2
519
520#endif
521
522end module clblas_oct_m
integer, parameter, public clblastnohalfprecision
Definition: clblas.F90:228
integer, parameter, public clblastunknownerror
Definition: clblas.F90:228
integer, parameter, public clblasbuildprogramfailure
Definition: clblas.F90:193
integer, parameter, public clblasinvalidleaddimb
Definition: clblas.F90:207
integer, parameter, public clblasinvalidoperation
Definition: clblas.F90:193
integer, parameter, public clblasnonunit
Definition: clblas.F90:160
integer, parameter, public clblasinvalideventwaitlist
Definition: clblas.F90:193
integer, parameter, public clblasinvalidcontext
Definition: clblas.F90:193
integer, parameter, public clblasinvalidmata
Definition: clblas.F90:207
integer, parameter, public clblasinvalidleaddimc
Definition: clblas.F90:207
integer, parameter, public clblasoutofresources
Definition: clblas.F90:193
integer, parameter, public clblascolumnmajor
Definition: clblas.F90:147
integer, parameter, public clblastinvalidvectorscalar
Definition: clblas.F90:228
integer, parameter, public clblastnodoubleprecision
Definition: clblas.F90:228
integer, parameter, public clblascompilernotavailable
Definition: clblas.F90:193
integer, parameter, public clblasinvalidvecy
Definition: clblas.F90:207
integer, parameter, public clblasinsufficientmemvecy
Definition: clblas.F90:207
integer, parameter, public clblastrans
Definition: clblas.F90:151
integer, parameter, public clblastinvalidlocalmemusage
Definition: clblas.F90:228
integer, parameter, public clblasinvalidcommandqueue
Definition: clblas.F90:193
integer, parameter, public clblasinvalidleaddima
Definition: clblas.F90:207
integer, parameter, public clblaslower
Definition: clblas.F90:156
integer, parameter, public clblasright
Definition: clblas.F90:164
integer, parameter, public clblasinvalidvecx
Definition: clblas.F90:207
integer, parameter, public clblastdatabaseerror
Definition: clblas.F90:228
integer, parameter, public clblasnotinitialized
Definition: clblas.F90:207
integer, parameter, public clblasinsufficientmemvecx
Definition: clblas.F90:207
integer, parameter, public clblastinvalidoverridekernel
Definition: clblas.F90:228
integer, parameter, public clblasoutofhostmemory
Definition: clblas.F90:193
integer, parameter, public clblasinvaliddim
Definition: clblas.F90:207
integer, parameter, public clblasinvalidincx
Definition: clblas.F90:207
integer, parameter, public clblasinvalidvalue
Definition: clblas.F90:193
integer, parameter, public clblastinvalidbatchcount
Definition: clblas.F90:228
integer, parameter, public clblasinsufficientmemmatb
Definition: clblas.F90:207
integer, parameter, public clblastinsufficientmemoryscalar
Definition: clblas.F90:228
integer, parameter, public clblasinvalidmatb
Definition: clblas.F90:207
integer, parameter, public clblastmissingoverrideparameter
Definition: clblas.F90:228
integer, parameter, public clblasinsufficientmemmatc
Definition: clblas.F90:207
integer, parameter, public clblasinvaliddevice
Definition: clblas.F90:193
integer, parameter, public clblasconjtrans
Definition: clblas.F90:151
integer, parameter, public clblasinvalidmatc
Definition: clblas.F90:207
integer, parameter, public clblasinvalidmemobject
Definition: clblas.F90:193
integer, parameter, public clblastunexpectederror
Definition: clblas.F90:228
integer, parameter, public clblasinsufficientmemmata
Definition: clblas.F90:207
integer, parameter, public clblasinvalidincy
Definition: clblas.F90:207