27 USE iso_c_binding,
ONLY: c_bool,&
41#include "../base/base_uses.f90"
52 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'fft_gpu'
53 LOGICAL,
PARAMETER,
PRIVATE :: debug_this_module = .false.
67 CHARACTER(len=*),
PARAMETER :: routinen =
'fft_gpu_r3dc1d_3d'
69 COMPLEX(KIND=dp),
POINTER :: ptr_pwout
70 INTEGER :: handle, l1, l2, l3, ngpts
71 INTEGER,
DIMENSION(:),
POINTER :: npts
72 INTEGER,
POINTER :: ptr_ghatmap
73 REAL(kind=
dp) :: scale
74 REAL(kind=
dp),
POINTER :: ptr_pwin
76 SUBROUTINE fft_gpu_cfffg_c(din, zout, ghatmap, npts, ngpts, scale)
BIND(C, name="fft_gpu_cfffg")
78 TYPE(c_ptr),
INTENT(IN),
VALUE :: din
79 TYPE(c_ptr),
VALUE :: zout
80 TYPE(c_ptr),
INTENT(IN),
VALUE :: ghatmap
81 INTEGER(KIND=C_INT),
DIMENSION(*),
INTENT(IN):: npts
82 INTEGER(KIND=C_INT),
INTENT(IN),
VALUE :: ngpts
83 REAL(kind=c_double),
INTENT(IN),
VALUE :: scale
85 END SUBROUTINE fft_gpu_cfffg_c
88 CALL timeset(routinen, handle)
90 scale = 1.0_dp/real(pw1%pw_grid%ngpts, kind=
dp)
92 ngpts =
SIZE(pw2%pw_grid%gsq)
93 l1 = lbound(pw1%array, 1)
94 l2 = lbound(pw1%array, 2)
95 l3 = lbound(pw1%array, 3)
96 npts => pw1%pw_grid%npts
99 ptr_pwin => pw1%array(l1, l2, l3)
100 ptr_pwout => pw2%array(1)
103 ptr_ghatmap => pw2%pw_grid%g_hatmap(1, 1)
106#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
107 CALL fft_gpu_cfffg_c(c_loc(ptr_pwin), c_loc(ptr_pwout), c_loc(ptr_ghatmap), npts, ngpts, scale)
109 cpabort(
"Compiled without pw offloading.")
112 CALL timestop(handle)
125 CHARACTER(len=*),
PARAMETER :: routinen =
'fft_gpu_c1dr3d_3d'
127 COMPLEX(KIND=dp),
POINTER :: ptr_pwin
128 INTEGER :: handle, l1, l2, l3, ngpts, nmaps
129 INTEGER,
DIMENSION(:),
POINTER :: npts
130 INTEGER,
POINTER :: ptr_ghatmap
131 REAL(kind=
dp) :: scale
132 REAL(kind=
dp),
POINTER :: ptr_pwout
134 SUBROUTINE fft_gpu_sfffc_c(zin, dout, ghatmap, npts, ngpts, nmaps, scale)
BIND(C, name="fft_gpu_sfffc")
136 TYPE(c_ptr),
INTENT(IN),
VALUE :: zin
137 TYPE(c_ptr),
VALUE :: dout
138 TYPE(c_ptr),
INTENT(IN),
VALUE :: ghatmap
139 INTEGER(KIND=C_INT),
DIMENSION(*),
INTENT(IN):: npts
140 INTEGER(KIND=C_INT),
INTENT(IN),
VALUE :: ngpts, nmaps
141 REAL(kind=c_double),
INTENT(IN),
VALUE :: scale
142 END SUBROUTINE fft_gpu_sfffc_c
145 CALL timeset(routinen, handle)
149 ngpts =
SIZE(pw1%pw_grid%gsq)
150 l1 = lbound(pw2%array, 1)
151 l2 = lbound(pw2%array, 2)
152 l3 = lbound(pw2%array, 3)
153 npts => pw1%pw_grid%npts
156 ptr_pwin => pw1%array(1)
157 ptr_pwout => pw2%array(l1, l2, l3)
160 nmaps =
SIZE(pw1%pw_grid%g_hatmap, 2)
161 ptr_ghatmap => pw1%pw_grid%g_hatmap(1, 1)
164#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
165 CALL fft_gpu_sfffc_c(c_loc(ptr_pwin), c_loc(ptr_pwout), c_loc(ptr_ghatmap), npts, ngpts, nmaps, scale)
167 cpabort(
"Compiled without pw offloading")
170 CALL timestop(handle)
183 CHARACTER(len=*),
PARAMETER :: routinen =
'fft_gpu_r3dc1d_3d_ps'
185 COMPLEX(KIND=dp),
DIMENSION(:, :),
POINTER :: grays, pbuf, qbuf, rbuf, sbuf
186 COMPLEX(KIND=dp),
DIMENSION(:, :, :),
POINTER :: tbuf
187 INTEGER :: g_pos, handle, lg, lmax, mg, mmax, mx2, &
188 mz2, n1, n2, ngpts, nmax, numtask, rp
189 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: p2p
190 INTEGER,
DIMENSION(2) :: r_dim, r_pos
191 INTEGER,
DIMENSION(:),
POINTER :: n, nloc, nyzray
192 INTEGER,
DIMENSION(:, :, :, :),
POINTER :: bo
193 REAL(kind=
dp) :: scale
198 CALL timeset(routinen, handle)
200 scale = 1.0_dp/real(pw1%pw_grid%ngpts, kind=
dp)
203 n => pw1%pw_grid%npts
204 nloc => pw1%pw_grid%npts_local
205 grays => pw1%pw_grid%grays
206 ngpts = nloc(1)*nloc(2)*nloc(3)
209 IF (pw1%pw_grid%para%ray_distribution)
THEN
210 rs_group = pw1%pw_grid%para%group
211 nyzray => pw1%pw_grid%para%nyzray
212 bo => pw1%pw_grid%para%bo
214 g_pos = rs_group%mepos
215 numtask = rs_group%num_pe
216 r_dim = rs_group%num_pe_cart
217 r_pos = rs_group%mepos_cart
222 lmax = max(lg, (ngpts/mmax + 1))
224 ALLOCATE (p2p(0:numtask - 1))
226 CALL rs_group%rank_compare(rs_group, p2p)
229 mx2 = bo(2, 1, rp, 2) - bo(1, 1, rp, 2) + 1
230 mz2 = bo(2, 3, rp, 2) - bo(1, 3, rp, 2) + 1
231 n1 = maxval(bo(2, 1, :, 1) - bo(1, 1, :, 1) + 1)
232 n2 = maxval(bo(2, 2, :, 1) - bo(1, 2, :, 1) + 1)
233 nmax = max((2*n2)/numtask, 2)*mx2*mz2
234 nmax = max(nmax, n1*maxval(nyzray))
236 fft_scratch_size%nx = nloc(1)
237 fft_scratch_size%ny = nloc(2)
238 fft_scratch_size%nz = nloc(3)
239 fft_scratch_size%lmax = lmax
240 fft_scratch_size%mmax = mmax
241 fft_scratch_size%mx1 = bo(2, 1, rp, 1) - bo(1, 1, rp, 1) + 1
242 fft_scratch_size%mx2 = mx2
243 fft_scratch_size%my1 = bo(2, 2, rp, 1) - bo(1, 2, rp, 1) + 1
244 fft_scratch_size%mz2 = mz2
245 fft_scratch_size%lg = lg
246 fft_scratch_size%mg = mg
247 fft_scratch_size%nbx = maxval(bo(2, 1, :, 2))
248 fft_scratch_size%nbz = maxval(bo(2, 3, :, 2))
249 fft_scratch_size%mcz1 = maxval(bo(2, 3, :, 1) - bo(1, 3, :, 1) + 1)
250 fft_scratch_size%mcx2 = maxval(bo(2, 1, :, 2) - bo(1, 1, :, 2) + 1)
251 fft_scratch_size%mcz2 = maxval(bo(2, 3, :, 2) - bo(1, 3, :, 2) + 1)
252 fft_scratch_size%nmax = nmax
253 fft_scratch_size%nmray = maxval(nyzray)
254 fft_scratch_size%nyzray = nyzray(g_pos)
255 fft_scratch_size%rs_group = rs_group
256 fft_scratch_size%g_pos = g_pos
257 fft_scratch_size%r_pos = r_pos
258 fft_scratch_size%r_dim = r_dim
259 fft_scratch_size%numtask = numtask
261 IF (r_dim(2) > 1)
THEN
266 IF (r_dim(1) == 1)
THEN
267 cpabort(
"This processor distribution is not supported.")
270 CALL get_fft_scratch(fft_scratch, tf_type=300, n=n, fft_sizes=fft_scratch_size)
273 qbuf => fft_scratch%p2buf
274 rbuf => fft_scratch%p3buf
275 pbuf => fft_scratch%p4buf
276 sbuf => fft_scratch%p5buf
279 CALL fft_gpu_cf(pw1, qbuf)
282 CALL cube_transpose_2(qbuf, bo(:, :, :, 1), bo(:, :, :, 2), rbuf, fft_scratch)
288 CALL fft_gpu_1d_local(rbuf, pbuf, +1, n(2), mx2*mz2)
291 CALL xz_to_yz(pbuf, rs_group, r_dim, g_pos, p2p, pw1%pw_grid%para%yzp, nyzray, &
292 bo(:, :, :, 2), sbuf, fft_scratch)
295 CALL fft_gpu_fg(sbuf, pw2, scale)
306 CALL get_fft_scratch(fft_scratch, tf_type=200, n=n, fft_sizes=fft_scratch_size)
309 tbuf => fft_scratch%tbuf
310 sbuf => fft_scratch%r1buf
313 CALL fft_gpu_cff(pw1, tbuf)
316 CALL yz_to_x(tbuf, rs_group, g_pos, p2p, pw1%pw_grid%para%yzp, nyzray, &
317 bo(:, :, :, 2), sbuf, fft_scratch)
320 CALL fft_gpu_fg(sbuf, pw2, scale)
330 cpabort(
"Not implemented (no ray_distr.) in: fft_gpu_r3dc1d_3d_ps.")
333 CALL timestop(handle)
346 CHARACTER(len=*),
PARAMETER :: routinen =
'fft_gpu_c1dr3d_3d_ps'
348 COMPLEX(KIND=dp),
DIMENSION(:, :),
POINTER :: grays, pbuf, qbuf, rbuf, sbuf
349 COMPLEX(KIND=dp),
DIMENSION(:, :, :),
POINTER :: tbuf
350 INTEGER :: g_pos, handle, lg, lmax, mg, mmax, mx2, &
351 mz2, n1, n2, ngpts, nmax, numtask, rp
352 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: p2p
353 INTEGER,
DIMENSION(2) :: r_dim, r_pos
354 INTEGER,
DIMENSION(:),
POINTER :: n, nloc, nyzray
355 INTEGER,
DIMENSION(:, :, :, :),
POINTER :: bo
356 REAL(kind=
dp) :: scale
361 CALL timeset(routinen, handle)
366 n => pw1%pw_grid%npts
367 nloc => pw1%pw_grid%npts_local
368 grays => pw1%pw_grid%grays
369 ngpts = nloc(1)*nloc(2)*nloc(3)
372 IF (pw1%pw_grid%para%ray_distribution)
THEN
373 rs_group = pw1%pw_grid%para%group
374 nyzray => pw1%pw_grid%para%nyzray
375 bo => pw1%pw_grid%para%bo
377 g_pos = rs_group%mepos
378 numtask = rs_group%num_pe
379 r_dim = rs_group%num_pe_cart
380 r_pos = rs_group%mepos_cart
385 lmax = max(lg, (ngpts/mmax + 1))
387 ALLOCATE (p2p(0:numtask - 1))
389 CALL rs_group%rank_compare(rs_group, p2p)
392 mx2 = bo(2, 1, rp, 2) - bo(1, 1, rp, 2) + 1
393 mz2 = bo(2, 3, rp, 2) - bo(1, 3, rp, 2) + 1
394 n1 = maxval(bo(2, 1, :, 1) - bo(1, 1, :, 1) + 1)
395 n2 = maxval(bo(2, 2, :, 1) - bo(1, 2, :, 1) + 1)
396 nmax = max((2*n2)/numtask, 2)*mx2*mz2
397 nmax = max(nmax, n1*maxval(nyzray))
399 fft_scratch_size%nx = nloc(1)
400 fft_scratch_size%ny = nloc(2)
401 fft_scratch_size%nz = nloc(3)
402 fft_scratch_size%lmax = lmax
403 fft_scratch_size%mmax = mmax
404 fft_scratch_size%mx1 = bo(2, 1, rp, 1) - bo(1, 1, rp, 1) + 1
405 fft_scratch_size%mx2 = mx2
406 fft_scratch_size%my1 = bo(2, 2, rp, 1) - bo(1, 2, rp, 1) + 1
407 fft_scratch_size%mz2 = mz2
408 fft_scratch_size%lg = lg
409 fft_scratch_size%mg = mg
410 fft_scratch_size%nbx = maxval(bo(2, 1, :, 2))
411 fft_scratch_size%nbz = maxval(bo(2, 3, :, 2))
412 fft_scratch_size%mcz1 = maxval(bo(2, 3, :, 1) - bo(1, 3, :, 1) + 1)
413 fft_scratch_size%mcx2 = maxval(bo(2, 1, :, 2) - bo(1, 1, :, 2) + 1)
414 fft_scratch_size%mcz2 = maxval(bo(2, 3, :, 2) - bo(1, 3, :, 2) + 1)
415 fft_scratch_size%nmax = nmax
416 fft_scratch_size%nmray = maxval(nyzray)
417 fft_scratch_size%nyzray = nyzray(g_pos)
418 fft_scratch_size%rs_group = rs_group
419 fft_scratch_size%g_pos = g_pos
420 fft_scratch_size%r_pos = r_pos
421 fft_scratch_size%r_dim = r_dim
422 fft_scratch_size%numtask = numtask
424 IF (r_dim(2) > 1)
THEN
429 IF (r_dim(1) == 1)
THEN
430 cpabort(
"This processor distribution is not supported.")
433 CALL get_fft_scratch(fft_scratch, tf_type=300, n=n, fft_sizes=fft_scratch_size)
436 pbuf => fft_scratch%p7buf
437 qbuf => fft_scratch%p4buf
438 rbuf => fft_scratch%p3buf
439 sbuf => fft_scratch%p2buf
442 CALL fft_gpu_sf(pw1, pbuf, scale)
446 CALL yz_to_xz(pbuf, rs_group, r_dim, g_pos, p2p, pw1%pw_grid%para%yzp, nyzray, &
447 bo(:, :, :, 2), qbuf, fft_scratch)
453 CALL fft_gpu_1d_local(qbuf, rbuf, -1, n(2), mx2*mz2)
458 CALL cube_transpose_1(rbuf, bo(:, :, :, 2), bo(:, :, :, 1), sbuf, fft_scratch)
461 CALL fft_gpu_fc(sbuf, pw2)
472 CALL get_fft_scratch(fft_scratch, tf_type=200, n=n, fft_sizes=fft_scratch_size)
475 sbuf => fft_scratch%r1buf
476 tbuf => fft_scratch%tbuf
479 CALL fft_gpu_sf(pw1, sbuf, scale)
483 CALL x_to_yz(sbuf, rs_group, g_pos, p2p, pw1%pw_grid%para%yzp, nyzray, &
484 bo(:, :, :, 2), tbuf, fft_scratch)
487 CALL fft_gpu_ffc(tbuf, pw2)
497 cpabort(
"Not implemented (no ray_distr.) in: fft_gpu_c1dr3d_3d_ps.")
500 CALL timestop(handle)
509 SUBROUTINE fft_gpu_cff(pw1, pwbuf)
511 COMPLEX(KIND=dp),
DIMENSION(:, :, :), &
512 INTENT(INOUT),
TARGET :: pwbuf
514 CHARACTER(len=*),
PARAMETER :: routinen =
'fft_gpu_cff'
516 COMPLEX(KIND=dp),
POINTER :: ptr_pwout
517 INTEGER :: handle, l1, l2, l3
518 INTEGER,
DIMENSION(:),
POINTER :: npts
519 REAL(kind=
dp),
POINTER :: ptr_pwin
521 SUBROUTINE fft_gpu_cff_c(din, zout, npts)
BIND(C, name="fft_gpu_cff")
523 TYPE(c_ptr),
INTENT(IN),
VALUE :: din
524 TYPE(c_ptr),
VALUE :: zout
525 INTEGER(KIND=C_INT),
DIMENSION(*),
INTENT(IN):: npts
526 END SUBROUTINE fft_gpu_cff_c
529 CALL timeset(routinen, handle)
532 npts => pw1%pw_grid%npts_local
533 l1 = lbound(pw1%array, 1)
534 l2 = lbound(pw1%array, 2)
535 l3 = lbound(pw1%array, 3)
538 ptr_pwin => pw1%array(l1, l2, l3)
539 ptr_pwout => pwbuf(1, 1, 1)
542#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
543 CALL fft_gpu_cff_c(c_loc(ptr_pwin), c_loc(ptr_pwout), npts)
545 cpabort(
"Compiled without pw offloading")
548 CALL timestop(handle)
549 END SUBROUTINE fft_gpu_cff
557 SUBROUTINE fft_gpu_ffc(pwbuf, pw2)
558 COMPLEX(KIND=dp),
DIMENSION(:, :, :),
INTENT(IN), &
562 CHARACTER(len=*),
PARAMETER :: routinen =
'fft_gpu_ffc'
564 COMPLEX(KIND=dp),
POINTER :: ptr_pwin
565 INTEGER :: handle, l1, l2, l3
566 INTEGER,
DIMENSION(:),
POINTER :: npts
567 REAL(kind=
dp),
POINTER :: ptr_pwout
569 SUBROUTINE fft_gpu_ffc_c(zin, dout, npts)
BIND(C, name="fft_gpu_ffc")
571 TYPE(c_ptr),
INTENT(IN),
VALUE :: zin
572 TYPE(c_ptr),
VALUE :: dout
573 INTEGER(KIND=C_INT),
DIMENSION(*),
INTENT(IN):: npts
574 END SUBROUTINE fft_gpu_ffc_c
577 CALL timeset(routinen, handle)
580 npts => pw2%pw_grid%npts_local
581 l1 = lbound(pw2%array, 1)
582 l2 = lbound(pw2%array, 2)
583 l3 = lbound(pw2%array, 3)
586 ptr_pwin => pwbuf(1, 1, 1)
587 ptr_pwout => pw2%array(l1, l2, l3)
590#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
591 CALL fft_gpu_ffc_c(c_loc(ptr_pwin), c_loc(ptr_pwout), npts)
593 cpabort(
"Compiled without pw offloading")
596 CALL timestop(handle)
597 END SUBROUTINE fft_gpu_ffc
605 SUBROUTINE fft_gpu_cf(pw1, pwbuf)
607 COMPLEX(KIND=dp),
DIMENSION(:, :),
INTENT(INOUT), &
610 CHARACTER(len=*),
PARAMETER :: routinen =
'fft_gpu_cf'
612 COMPLEX(KIND=dp),
POINTER :: ptr_pwout
613 INTEGER :: handle, l1, l2, l3
614 INTEGER,
DIMENSION(:),
POINTER :: npts
615 REAL(kind=
dp),
POINTER :: ptr_pwin
617 SUBROUTINE fft_gpu_cf_c(din, zout, npts)
BIND(C, name="fft_gpu_cf")
619 TYPE(c_ptr),
INTENT(IN),
VALUE :: din
620 TYPE(c_ptr),
VALUE :: zout
621 INTEGER(KIND=C_INT),
DIMENSION(*),
INTENT(IN):: npts
622 END SUBROUTINE fft_gpu_cf_c
625 CALL timeset(routinen, handle)
628 npts => pw1%pw_grid%npts_local
629 l1 = lbound(pw1%array, 1)
630 l2 = lbound(pw1%array, 2)
631 l3 = lbound(pw1%array, 3)
634 ptr_pwin => pw1%array(l1, l2, l3)
635 ptr_pwout => pwbuf(1, 1)
638#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
639 CALL fft_gpu_cf_c(c_loc(ptr_pwin), c_loc(ptr_pwout), npts)
641 cpabort(
"Compiled without pw offloading")
643 CALL timestop(handle)
644 END SUBROUTINE fft_gpu_cf
652 SUBROUTINE fft_gpu_fc(pwbuf, pw2)
653 COMPLEX(KIND=dp),
DIMENSION(:, :),
INTENT(IN), &
657 CHARACTER(len=*),
PARAMETER :: routinen =
'fft_gpu_fc'
659 COMPLEX(KIND=dp),
POINTER :: ptr_pwin
660 INTEGER :: handle, l1, l2, l3
661 INTEGER,
DIMENSION(:),
POINTER :: npts
662 REAL(kind=
dp),
POINTER :: ptr_pwout
664 SUBROUTINE fft_gpu_fc_c(zin, dout, npts)
BIND(C, name="fft_gpu_fc")
666 TYPE(c_ptr),
INTENT(IN),
VALUE :: zin
667 TYPE(c_ptr),
VALUE :: dout
668 INTEGER(KIND=C_INT),
DIMENSION(*),
INTENT(IN):: npts
669 END SUBROUTINE fft_gpu_fc_c
672 CALL timeset(routinen, handle)
674 npts => pw2%pw_grid%npts_local
675 l1 = lbound(pw2%array, 1)
676 l2 = lbound(pw2%array, 2)
677 l3 = lbound(pw2%array, 3)
680 ptr_pwin => pwbuf(1, 1)
681 ptr_pwout => pw2%array(l1, l2, l3)
684#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
685 CALL fft_gpu_fc_c(c_loc(ptr_pwin), c_loc(ptr_pwout), npts)
687 cpabort(
"Compiled without pw offloading")
690 CALL timestop(handle)
691 END SUBROUTINE fft_gpu_fc
702 SUBROUTINE fft_gpu_1d_local(pwbuf1, pwbuf2, dir, n, m)
703 COMPLEX(KIND=dp),
DIMENSION(:, :),
INTENT(IN), &
705 COMPLEX(KIND=dp),
DIMENSION(:, :),
INTENT(INOUT), &
707 INTEGER,
INTENT(IN) :: dir, n, m
709 CHARACTER(len=*),
PARAMETER :: routinen =
'fft_gpu_1d_local'
711 COMPLEX(KIND=dp),
POINTER :: ptr_pwin, ptr_pwout
712 INTEGER :: handle, ldx_in, ldx_out
713 LOGICAL :: transpose_in, transpose_out
715 SUBROUTINE fft_gpu_f_c(zin, zout, dir, n, m, transpose_in, transpose_out, ldx_in, ldx_out) &
716 BIND(C, name="fft_gpu_1d_local")
718 TYPE(c_ptr),
INTENT(IN),
VALUE :: zin
719 TYPE(c_ptr),
VALUE :: zout
720 LOGICAL(KIND=C_BOOL),
INTENT(IN),
VALUE :: dir, transpose_in, transpose_out
721 INTEGER(KIND=C_INT),
INTENT(IN),
VALUE :: n, m, ldx_in, ldx_out
722 END SUBROUTINE fft_gpu_f_c
725 CALL timeset(routinen, handle)
729 ptr_pwin => pwbuf1(1, 1)
730 ptr_pwout => pwbuf2(1, 1)
733 transpose_in = .true.
734 transpose_out = .false.
738 transpose_in = .false.
739 transpose_out = .true.
745#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
746 CALL fft_gpu_f_c(c_loc(ptr_pwin), c_loc(ptr_pwout),
LOGICAL(dir > 0, C_BOOL), &
747 int(n, c_int), int(m, c_int),
LOGICAL(transpose_in, C_BOOL), &
748 LOGICAL(transpose_out, C_BOOL), int(ldx_in, c_int), int(ldx_out, c_int))
751 cpabort(
"Compiled without pw offloading")
755 CALL timestop(handle)
756 END SUBROUTINE fft_gpu_1d_local
764 SUBROUTINE fft_gpu_fg(pwbuf, pw2, scale)
765 COMPLEX(KIND=dp),
DIMENSION(:, :),
INTENT(IN), &
768 REAL(kind=
dp),
INTENT(IN) :: scale
770 CHARACTER(len=*),
PARAMETER :: routinen =
'fft_gpu_fg'
772 COMPLEX(KIND=dp),
POINTER :: ptr_pwin, ptr_pwout
773 INTEGER :: handle, mg, mmax, ngpts
774 INTEGER,
DIMENSION(:),
POINTER :: npts
775 INTEGER,
POINTER :: ptr_ghatmap
777 SUBROUTINE fft_gpu_fg_c(zin, zout, ghatmap, npts, mmax, ngpts, scale)
BIND(C, name="fft_gpu_fg")
779 TYPE(c_ptr),
INTENT(IN),
VALUE :: zin
780 TYPE(c_ptr),
VALUE :: zout
781 TYPE(c_ptr),
INTENT(IN),
VALUE :: ghatmap
782 INTEGER(KIND=C_INT),
DIMENSION(*),
INTENT(IN):: npts
783 INTEGER(KIND=C_INT),
INTENT(IN),
VALUE :: mmax, ngpts
784 REAL(kind=c_double),
INTENT(IN),
VALUE :: scale
786 END SUBROUTINE fft_gpu_fg_c
789 CALL timeset(routinen, handle)
791 ngpts =
SIZE(pw2%pw_grid%gsq)
792 npts => pw2%pw_grid%npts
794 IF ((npts(1) /= 0) .AND. (ngpts /= 0))
THEN
795 mg =
SIZE(pw2%pw_grid%grays, 2)
799 ptr_pwin => pwbuf(1, 1)
800 ptr_pwout => pw2%array(1)
803 ptr_ghatmap => pw2%pw_grid%g_hatmap(1, 1)
806#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
807 CALL fft_gpu_fg_c(c_loc(ptr_pwin), c_loc(ptr_pwout), c_loc(ptr_ghatmap), npts, mmax, ngpts, scale)
810 cpabort(
"Compiled without pw offloading")
814 CALL timestop(handle)
815 END SUBROUTINE fft_gpu_fg
824 SUBROUTINE fft_gpu_sf(pw1, pwbuf, scale)
826 COMPLEX(KIND=dp),
DIMENSION(:, :),
INTENT(INOUT), &
828 REAL(kind=
dp),
INTENT(IN) :: scale
830 CHARACTER(len=*),
PARAMETER :: routinen =
'fft_gpu_sf'
832 COMPLEX(KIND=dp),
POINTER :: ptr_pwin, ptr_pwout
833 INTEGER :: handle, mg, mmax, ngpts, nmaps
834 INTEGER,
DIMENSION(:),
POINTER :: npts
835 INTEGER,
POINTER :: ptr_ghatmap
837 SUBROUTINE fft_gpu_sf_c(zin, zout, ghatmap, npts, mmax, ngpts, nmaps, scale)
BIND(C, name="fft_gpu_sf")
839 TYPE(c_ptr),
INTENT(IN),
VALUE :: zin
840 TYPE(c_ptr),
VALUE :: zout
841 TYPE(c_ptr),
INTENT(IN),
VALUE :: ghatmap
842 INTEGER(KIND=C_INT),
DIMENSION(*),
INTENT(IN):: npts
843 INTEGER(KIND=C_INT),
INTENT(IN),
VALUE :: mmax, ngpts, nmaps
844 REAL(kind=c_double),
INTENT(IN),
VALUE :: scale
846 END SUBROUTINE fft_gpu_sf_c
849 CALL timeset(routinen, handle)
851 ngpts =
SIZE(pw1%pw_grid%gsq)
852 npts => pw1%pw_grid%npts
854 IF ((npts(1) /= 0) .AND. (ngpts /= 0))
THEN
855 mg =
SIZE(pw1%pw_grid%grays, 2)
859 ptr_pwin => pw1%array(1)
860 ptr_pwout => pwbuf(1, 1)
863 nmaps =
SIZE(pw1%pw_grid%g_hatmap, 2)
864 ptr_ghatmap => pw1%pw_grid%g_hatmap(1, 1)
867#if defined(__OFFLOAD) && !defined(__NO_OFFLOAD_FFT)
868 CALL fft_gpu_sf_c(c_loc(ptr_pwin), c_loc(ptr_pwout), c_loc(ptr_ghatmap), npts, mmax, ngpts, nmaps, scale)
871 cpabort(
"Compiled without pw offloading")
875 CALL timestop(handle)
876 END SUBROUTINE fft_gpu_sf
subroutine, public fft_gpu_r3dc1d_3d_ps(pw1, pw2)
perform an parallel fft followed by a gather on the gpu
subroutine, public fft_gpu_c1dr3d_3d_ps(pw1, pw2)
perform an parallel scatter followed by a fft on the gpu
subroutine, public fft_gpu_r3dc1d_3d(pw1, pw2)
perform an fft followed by a gather on the gpu
subroutine, public fft_gpu_c1dr3d_3d(pw1, pw2)
perform an scatter followed by a fft on the gpu
Defines the basic variable types.
integer, parameter, public dp
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public z_zero
Interface to the message passing library MPI.
integer, parameter, public fullspace