Appearance
adam_fnl_poisson_fft_object
ADAM, FNL FFT Poisson solver on uniform periodic grids (cuFFT).
Extends poisson_fft_object (issue #81, P2): the gather to rank 0, the placement and the scatter of phi with its ghosts are the CPU ones; the spectral solve runs on rank 0's GPU through cuFFT (-D_CUFFT, -cudalib=cufft). The global source goes to the device, a D2Z transform, the division by the eigenvalues of L_h (the same host-computed lam1..3 as the CPU solver), a Z2D transform, and the potential comes back. cuFFT runs on the stream of the synchronous OpenACC queue, so the transforms and the kernel between them are ordered.
Isolated boundaries (issue #81, M8-P4): the transforms are the padded ones (m), the kernel's spectrum khat is computed once on the device (transform_kernel) and stays there (enter data, released by destroy_plans); the solve multiplies by it instead of dividing by the eigenvalues.
cuFFT is NVIDIA only: built without _CUFFT (an AMD build), making the plans stops the run.
Source: src/lib/fnl/adam_fnl_poisson_fft_object.F90
Dependencies
Contents
Derived Types
poisson_fft_fnl_object
FNL FFT Poisson solver on uniform periodic grids (cuFFT).
Inheritance
Extends: poisson_fft_object
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
is_initialized | logical | Initialization status. | |
n | integer(kind=I4P) | Global cells per direction. | |
m | integer(kind=I4P) | Transform cells per direction: n, or 2 (n + ngc) isolated. | |
isolated | logical | Isolated boundaries (zero padding), else periodic. | |
dirichlet | logical | Homogeneous Dirichlet boundaries (odd extension, #87). | |
nt | integer(kind=I4P) | Cells of the periodic transform the eigenvalues refer to: n, | |
nijk | integer(kind=I4P) | Cells per block per direction. | |
ngc | integer(kind=I4P) | Ghost cells per side. | |
level | integer(kind=I4P) | Level of every block. | |
dxyz | real(kind=R8P) | Cell spacing per direction. | |
lam1 | real(kind=R8P) | allocatable | Eigenvalue part along x [0:n(1)/2]. |
lam2 | real(kind=R8P) | allocatable | Eigenvalue part along y [0:n(2)-1]. |
lam3 | real(kind=R8P) | allocatable | Eigenvalue part along z [0:n(3)-1]. |
f_global | real(kind=R8P) | allocatable | Rank 0: the source, then the potential [m(1),m(2),m(3)]. |
f_source | real(kind=R8P) | allocatable | Rank 0: a copy of the source, for the energy. |
f_hat | complex(kind=R8P) | allocatable | Rank 0: the transform [m(1)/2+1,m(2),m(3)]. |
khat | real(kind=R8P) | allocatable | Rank 0, isolated: the kernel's spectrum over prod(m). |
plan_r2c | type(c_ptr) | FFTW forward plan (rank 0). | |
plan_c2r | type(c_ptr) | FFTW backward plan (rank 0). | |
plan_d2z | integer(kind=c_int) | cuFFT forward plan (rank 0). | |
plan_z2d | integer(kind=c_int) | cuFFT backward plan (rank 0). | |
has_plans | logical | The cuFFT plans exist. | |
khat_on_device | logical | khat is on the device (isolated). |
Type-Bound Procedures
| Name | Attributes | Description |
|---|---|---|
destroy | pass(self) | Destroy the solver. |
initialize | pass(self) | Check the grid, size the solver, make the plans. |
solve | pass(self) | Solve for phi from one variable of q. |
solve_packed | pass(self) | Solve for phi from the packed interior source. |
initialize_blocks | pass(self) | Size the solver from block counts and spacing (no grid, no field). |
solve_blocks | pass(self) | Solve from an explicit list of blocks (coordinates and source). |
destroy_plans | pass(self) | Destroy the cuFFT plans. |
make_plans | pass(self) | Make the cuFFT plans (rank 0). |
transform | pass(self) | The spectral solve on the GPU (rank 0). |
transform_kernel | pass(self) | The kernel's spectrum on the GPU (isolated). |
Subroutines
destroy_plans_fnl
Destroy the cuFFT plans.
fortran
subroutine destroy_plans_fnl(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(poisson_fft_fnl_object) | inout | The solver. |
make_plans_fnl
Make the cuFFT plans (D2Z and Z2D, cuFFT is row-major: the slowest dimension first) on the synchronous queue.
fortran
subroutine make_plans_fnl(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(poisson_fft_fnl_object) | inout | The solver. |
Call graph
transform_fnl
Rank 0: f_global <- factor * L_h^-1 f_global on the GPU, the modes of zero eigenvalue (the mean) set to zero.
fortran
subroutine transform_fnl(self, factor)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(poisson_fft_fnl_object) | inout | The solver. | |
factor | real(kind=R8P) | in | Source factor. |
Call graph
transform_kernel_fnl
Rank 0, isolated: khat <- FFT(f_global) / prod(m) on the GPU (real: the kernel is even); khat stays on the device for every solve.
fortran
subroutine transform_kernel_fnl(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(poisson_fft_fnl_object) | inout | The solver. |
Call graph