Branch data Line data Source code
1 : : !{\src2tex{textfont=tt}}
2 : : !!****f* m_abi_linalg/abi_xaxpy
3 : : !! NAME
4 : : !! abi_xaxpy
5 : : !!
6 : : !! FUNCTION
7 : : !! abi_xaxpy is the generic function for BLAS-1 AXPY (y = alpha * x + y)
8 : : !! with optional GPU dispatch.
9 : : !!
10 : : !! COPYRIGHT
11 : : !! Copyright (C) 2001-2026 ABINIT group
12 : : !! This file is distributed under the terms of the
13 : : !! GNU General Public License, see ~abinit/COPYING
14 : : !! or http://www.gnu.org/copyleft/gpl.txt .
15 : : !!
16 : : !! SOURCE
17 : :
18 : : !!***
19 : :
20 : : !----------------------------------------------------------------------
21 : :
22 : : !!****f* m_abi_linalg/abi_daxpy
23 : : !! NAME
24 : : !! abi_daxpy
25 : : !!
26 : : !! FUNCTION
27 : : !! Real AXPY: y = alpha * x + y, with real(dp) alpha and real(dp) arrays.
28 : : !! On GPU, calls abi_gpu_xaxpy_cptr with cplx=1.
29 : : !!
30 : : !! INPUTS
31 : : !!
32 : : !! SOURCE
33 : :
34 : 0 : subroutine abi_daxpy(n, alpha, x, incx, y, incy, gpu_option)
35 : :
36 : : !Arguments ------------------------------------
37 : : integer, intent(in) :: n
38 : : real(dp), intent(in) :: alpha
39 : : real(dp), target, intent(in) :: x(*)
40 : : integer, intent(in) :: incx
41 : : real(dp), target, intent(inout) :: y(*)
42 : : integer, intent(in) :: incy
43 : : !Optionals -----------------------------------
44 : : integer, intent(in), optional :: gpu_option
45 : :
46 : : !Local variables-------------------------------
47 : : integer :: gpu_option_
48 : :
49 : : ! *********************************************************************
50 : :
51 [ # # ]: 0 : gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
52 : :
53 : 0 : call abi_d2zaxpy(n, dcmplx(alpha, 0.0_dp), x, incx, y, incy, x_cplx=1, gpu_option=gpu_option_)
54 : :
55 : 0 : end subroutine abi_daxpy
56 : : !!***
57 : :
58 : : !----------------------------------------------------------------------
59 : :
60 : : !!****f* m_abi_linalg/abi_daxpy_2d
61 : : !! NAME
62 : : !! abi_daxpy_2d
63 : : !!
64 : : !! FUNCTION
65 : : !! Real AXPY: y = alpha * x + y, with real(dp) alpha and real(dp) arrays.
66 : : !! On GPU, calls abi_gpu_xaxpy_cptr with cplx=1.
67 : : !!
68 : : !! INPUTS
69 : : !!
70 : : !! SOURCE
71 : :
72 [ # # # # ]: 0 : subroutine abi_daxpy_2d(n, alpha, x, incx, y, incy, gpu_option)
73 : :
74 : : !Arguments ------------------------------------
75 : : integer, intent(in) :: n
76 : : real(dp), intent(in) :: alpha
77 : : real(dp), target, intent(in) :: x(:,:)
78 : : integer, intent(in) :: incx
79 : : real(dp), target, intent(inout) :: y(:,:)
80 : : integer, intent(in) :: incy
81 : : !Optionals -----------------------------------
82 : : integer, intent(in), optional :: gpu_option
83 : :
84 : : !Local variables-------------------------------
85 : : integer :: gpu_option_
86 : :
87 : : ! *********************************************************************
88 : :
89 [ # # ]: 0 : gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
90 : :
91 [ # # # # : 0 : call abi_d2zaxpy(n, dcmplx(alpha, 0.0_dp), x, incx, y, incy, x_cplx=1, gpu_option=gpu_option_)
# # # # #
# # # # #
# # # # #
# # # #
# ]
92 : :
93 : 0 : end subroutine abi_daxpy_2d
94 : : !!***
95 : :
96 : : !----------------------------------------------------------------------
97 : :
98 : : !!****f* m_abi_linalg/abi_d2zaxpy_2d
99 : : !! NAME
100 : : !! abi_d2zaxpy_2d
101 : : !!
102 : : !! FUNCTION
103 : : !! Real AXPY: y = alpha * x + y, with real(dp) alpha and real(dp) arrays.
104 : : !! On GPU, calls abi_gpu_xaxpy_cptr with cplx=1.
105 : : !!
106 : : !! INPUTS
107 : : !!
108 : : !! SOURCE
109 : :
110 [ - + - + ]: 414239 : subroutine abi_d2zaxpy_2d(n, alpha, x, incx, y, incy, x_cplx, gpu_option)
111 : :
112 : : !Arguments ------------------------------------
113 : : integer, intent(in) :: n
114 : : complex(dp), intent(in) :: alpha
115 : : real(dp), target, intent(in) :: x(:,:)
116 : : integer, intent(in) :: incx
117 : : real(dp), target, intent(inout) :: y(:,:)
118 : : integer, intent(in) :: incy
119 : : !Optionals -----------------------------------
120 : : integer, intent(in), optional :: x_cplx, gpu_option
121 : :
122 : : !Local variables-------------------------------
123 : : integer :: cplx_,gpu_option_
124 : :
125 : : ! *********************************************************************
126 : :
127 [ + - ]: 414239 : gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
128 [ + - ]: 414239 : cplx_=1 ; if(PRESENT(x_cplx)) cplx_ = x_cplx
129 : :
130 [ - + - - : 414239 : call abi_d2zaxpy(n, alpha, x, incx, y, incy, x_cplx=cplx_, gpu_option=gpu_option_)
- - - - -
+ - - - -
- - - + -
+ - - -
- ]
131 : :
132 : 414239 : end subroutine abi_d2zaxpy_2d
133 : : !!***
134 : :
135 : : !----------------------------------------------------------------------
136 : :
137 : : !!****f* m_abi_linalg/abi_d2zaxpy_3d
138 : : !! NAME
139 : : !! abi_d2zaxpy_3d
140 : : !!
141 : : !! FUNCTION
142 : : !! Real AXPY: y = alpha * x + y, with real(dp) alpha and real(dp) arrays.
143 : : !! On GPU, calls abi_gpu_xaxpy_cptr with cplx=1.
144 : : !!
145 : : !! INPUTS
146 : : !!
147 : : !! SOURCE
148 : :
149 [ # # # # ]: 0 : subroutine abi_d2zaxpy_3d(n, alpha, x, incx, y, incy, x_cplx, gpu_option)
150 : :
151 : : !Arguments ------------------------------------
152 : : integer, intent(in) :: n
153 : : complex(dp), intent(in) :: alpha
154 : : real(dp), target, intent(in) :: x(:,:,:)
155 : : integer, intent(in) :: incx
156 : : real(dp), target, intent(inout) :: y(:,:,:)
157 : : integer, intent(in) :: incy
158 : : !Optionals -----------------------------------
159 : : integer, intent(in), optional :: x_cplx, gpu_option
160 : :
161 : : !Local variables-------------------------------
162 : : integer :: cplx_,gpu_option_
163 : :
164 : : ! *********************************************************************
165 : :
166 [ # # ]: 0 : gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
167 [ # # ]: 0 : cplx_=1 ; if(PRESENT(x_cplx)) cplx_ = x_cplx
168 : :
169 [ # # # # : 0 : call abi_d2zaxpy(n, alpha, x, incx, y, incy, x_cplx=cplx_, gpu_option=gpu_option_)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# ]
170 : :
171 : 0 : end subroutine abi_d2zaxpy_3d
172 : : !!***
173 : :
174 : :
175 : :
176 : : !----------------------------------------------------------------------
177 : :
178 : : !!****f* m_abi_linalg/abi_d2zaxpy_5d
179 : : !! NAME
180 : : !! abi_d2zaxpy_5d
181 : : !!
182 : : !! FUNCTION
183 : : !! Real AXPY: y = alpha * x + y, with real(dp) alpha and real(dp) arrays.
184 : : !! On GPU, calls abi_gpu_xaxpy_cptr with cplx=1.
185 : : !!
186 : : !! INPUTS
187 : : !!
188 : : !! SOURCE
189 : :
190 [ # # # # ]: 0 : subroutine abi_d2zaxpy_5d(n, alpha, x, incx, y, incy, x_cplx, gpu_option)
191 : :
192 : : !Arguments ------------------------------------
193 : : integer, intent(in) :: n
194 : : complex(dp), intent(in) :: alpha
195 : : real(dp), target, intent(in) :: x(:,:,:,:,:)
196 : : integer, intent(in) :: incx
197 : : real(dp), target, intent(inout) :: y(:,:,:,:,:)
198 : : integer, intent(in) :: incy
199 : : !Optionals -----------------------------------
200 : : integer, intent(in), optional :: x_cplx, gpu_option
201 : :
202 : : !Local variables-------------------------------
203 : : integer :: cplx_,gpu_option_
204 : :
205 : : ! *********************************************************************
206 : :
207 [ # # ]: 0 : gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
208 [ # # ]: 0 : cplx_=1 ; if(PRESENT(x_cplx)) cplx_ = x_cplx
209 : :
210 [ # # # # : 0 : call abi_d2zaxpy(n, alpha, x, incx, y, incy, x_cplx=cplx_, gpu_option=gpu_option_)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# # # ]
211 : :
212 : 0 : end subroutine abi_d2zaxpy_5d
213 : : !!***
214 : :
215 : :
216 : : !----------------------------------------------------------------------
217 : :
218 : : !!****f* m_abi_linalg/abi_d2zaxpy
219 : : !! NAME
220 : : !! abi_d2zaxpy
221 : : !!
222 : : !! FUNCTION
223 : : !! Real AXPY: y = alpha * x + y, with real(dp) alpha and real(dp) arrays.
224 : : !! On GPU, calls abi_gpu_xaxpy_cptr with cplx=1.
225 : : !!
226 : : !! INPUTS
227 : : !!
228 : : !! SOURCE
229 : :
230 : 414239 : subroutine abi_d2zaxpy(n, alpha, x, incx, y, incy, x_cplx, gpu_option)
231 : :
232 : : !Arguments ------------------------------------
233 : : integer, intent(in) :: n
234 : : complex(dp), intent(in) :: alpha
235 : : real(dp), target, intent(in) :: x(*)
236 : : integer, intent(in) :: incx
237 : : real(dp), target, intent(inout) :: y(*)
238 : : integer, intent(in) :: incy
239 : : !Optionals -----------------------------------
240 : : integer, intent(in), optional :: x_cplx, gpu_option
241 : :
242 : : !Local variables-------------------------------
243 : : integer :: cplx_,gpu_option_
244 : :
245 : : ! *********************************************************************
246 : :
247 [ + - ]: 414239 : gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
248 [ + - ]: 414239 : cplx_=1 ; if(PRESENT(x_cplx)) cplx_ = x_cplx
249 : :
250 : : #if defined(DEBUG_VERBOSE) && defined(HAVE_OPENMP_OFFLOAD)
251 : : if ( gpu_option_ == ABI_GPU_OPENMP ) then
252 : : ABI_CHECK(xomp_target_is_present(c_loc(x)), "Array isn't mapped on GPU")
253 : : ABI_CHECK(xomp_target_is_present(c_loc(y)), "Array isn't mapped on GPU")
254 : : end if
255 : : #endif
256 : :
257 [ - + ]: 414239 : if(gpu_option_/=ABI_GPU_DISABLED) then
258 [ # # ]: 0 : if(gpu_option_==ABI_GPU_OPENMP) then
259 : : #ifdef HAVE_OPENMP_OFFLOAD
260 : : !$OMP TARGET DATA USE_DEVICE_ADDR(x,y)
261 : : call abi_gpu_xaxpy_cptr(cplx_, n, alpha, c_loc(x), incx, c_loc(y), incy)
262 : : !$OMP END TARGET DATA
263 : : #endif
264 : : else
265 : 0 : call abi_gpu_xaxpy_cptr(cplx_, n, alpha, c_loc(x), incx, c_loc(y), incy)
266 : : end if
267 : : else
268 [ + - ]: 414239 : if(cplx_==1) then
269 : 414239 : call daxpy(n, alpha, x, incx, y, incy)
270 : : else
271 : 0 : call zaxpy(n, alpha, x, incx, y, incy)
272 : : end if
273 : : end if
274 : :
275 : 414239 : end subroutine abi_d2zaxpy
276 : : !!***
277 : :
278 : : !----------------------------------------------------------------------
279 : :
280 : : !!****f* m_abi_linalg/abi_zaxpy
281 : : !! NAME
282 : : !! abi_zaxpy
283 : : !!
284 : : !! FUNCTION
285 : : !! Complex AXPY: y = alpha * x + y, with complex(dp) alpha and complex(dp) arrays.
286 : : !! On GPU, calls abi_gpu_xaxpy_cptr with cplx=2.
287 : : !!
288 : : !! INPUTS
289 : : !!
290 : : !! SOURCE
291 : :
292 : 705498 : subroutine abi_zaxpy(n, alpha, x, incx, y, incy, gpu_option)
293 : :
294 : : !Arguments ------------------------------------
295 : : integer, intent(in) :: n
296 : : complex(dp), intent(in) :: alpha
297 : : complex(dp), target, intent(in) :: x(*)
298 : : integer, intent(in) :: incx
299 : : complex(dp), target, intent(inout) :: y(*)
300 : : integer, intent(in) :: incy
301 : : !Optionals -----------------------------------
302 : : integer, intent(in), optional :: gpu_option
303 : :
304 : : !Local variables-------------------------------
305 : : integer :: gpu_option_
306 : :
307 : : ! *********************************************************************
308 : :
309 [ + - ]: 705498 : gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
310 : :
311 : : #if defined(DEBUG_VERBOSE) && defined(HAVE_OPENMP_OFFLOAD)
312 : : if ( gpu_option_ == ABI_GPU_OPENMP ) then
313 : : ABI_CHECK(xomp_target_is_present(c_loc(x)), "Array isn't mapped on GPU")
314 : : ABI_CHECK(xomp_target_is_present(c_loc(y)), "Array isn't mapped on GPU")
315 : : end if
316 : : #endif
317 : :
318 [ - + ]: 705498 : if(gpu_option_/=ABI_GPU_DISABLED) then
319 [ # # ]: 0 : if(gpu_option_==ABI_GPU_OPENMP) then
320 : : #ifdef HAVE_OPENMP_OFFLOAD
321 : : !$OMP TARGET DATA USE_DEVICE_ADDR(x,y)
322 : : call abi_gpu_xaxpy_cptr(2, n, alpha, c_loc(x), incx, c_loc(y), incy)
323 : : !$OMP END TARGET DATA
324 : : #endif
325 : : else
326 : 0 : call abi_gpu_xaxpy_cptr(2, n, alpha, c_loc(x), incx, c_loc(y), incy)
327 : : end if
328 : : else
329 : 705498 : call zaxpy(n, alpha, x, incx, y, incy)
330 : : end if
331 : :
332 : 705498 : end subroutine abi_zaxpy
333 : : !!***
334 : :
335 : : !----------------------------------------------------------------------
336 : :
337 : : !!****f* m_abi_linalg/abi_zaxpy_2d
338 : : !! NAME
339 : : !! abi_zaxpy_2d
340 : : !!
341 : : !! FUNCTION
342 : : !! Complex AXPY: y = alpha * x + y, with complex(dp) alpha and complex(dp) arrays.
343 : : !! On GPU, calls abi_gpu_xaxpy_cptr with cplx=2.
344 : : !!
345 : : !! INPUTS
346 : : !!
347 : : !! SOURCE
348 : :
349 [ - + - + ]: 705498 : subroutine abi_zaxpy_2d(n, alpha, x, incx, y, incy, gpu_option)
350 : :
351 : : !Arguments ------------------------------------
352 : : integer, intent(in) :: n
353 : : complex(dp), intent(in) :: alpha
354 : : complex(dp), target, intent(in) :: x(:,:)
355 : : integer, intent(in) :: incx
356 : : complex(dp), target, intent(inout) :: y(:,:)
357 : : integer, intent(in) :: incy
358 : : !Optionals -----------------------------------
359 : : integer, intent(in), optional :: gpu_option
360 : :
361 : : !Local variables-------------------------------
362 : : integer :: gpu_option_
363 : :
364 : : ! *********************************************************************
365 : :
366 [ + - ]: 705498 : gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
367 : :
368 [ - + - - : 705498 : call abi_zaxpy(n, alpha, x, incx, y, incy, gpu_option=gpu_option_)
- - - - -
+ - - - -
- - - + -
+ - - -
- ]
369 : :
370 : 705498 : end subroutine abi_zaxpy_2d
371 : : !!***
372 : :
373 : : !----------------------------------------------------------------------
374 : :
375 : : !!****f* m_abi_linalg/abi_zaxpy_3d
376 : : !! NAME
377 : : !! abi_zaxpy_3d
378 : : !!
379 : : !! FUNCTION
380 : : !! Complex AXPY: y = alpha * x + y, with complex(dp) alpha and complex(dp) arrays.
381 : : !! On GPU, calls abi_gpu_xaxpy_cptr with cplx=2.
382 : : !!
383 : : !! INPUTS
384 : : !!
385 : : !! SOURCE
386 : :
387 [ # # # # ]: 0 : subroutine abi_zaxpy_3d(n, alpha, x, incx, y, incy, gpu_option)
388 : :
389 : : !Arguments ------------------------------------
390 : : integer, intent(in) :: n
391 : : complex(dp), intent(in) :: alpha
392 : : complex(dp), target, intent(in) :: x(:,:,:)
393 : : integer, intent(in) :: incx
394 : : complex(dp), target, intent(inout) :: y(:,:,:)
395 : : integer, intent(in) :: incy
396 : : !Optionals -----------------------------------
397 : : integer, intent(in), optional :: gpu_option
398 : :
399 : : !Local variables-------------------------------
400 : : integer :: gpu_option_
401 : :
402 : : ! *********************************************************************
403 : :
404 [ # # ]: 0 : gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
405 : :
406 [ # # # # : 0 : call abi_zaxpy(n, alpha, x, incx, y, incy, gpu_option=gpu_option_)
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
# ]
407 : :
408 : 0 : end subroutine abi_zaxpy_3d
409 : : !!***
|