Loading...
Searching...
No Matches
q3::SerialPocketFFTGrid Class Reference

#include <serial_pocket_fft_grid.hpp>

+ Inheritance diagram for q3::SerialPocketFFTGrid:

Public Member Functions

void execute_forward_on_buffers () const override
 
void execute_inverse_raw_on_buffers () const override
 
void forward (Complex *data) const override
 
int g_vector_to_fft_grid_index (int miller_1, int miller_2, int miller_3) const override
 
int grid_dimension_1 () const override
 
int grid_dimension_2 () const override
 
int grid_dimension_3 () const override
 
void init (int dimension_1, int dimension_2, int dimension_3, bool=false) override
 
Complex * input_buffer () const override
 
void inverse (Complex *data) const override
 
void inverse_raw (Complex *data) const override
 
int local_grid_points () const override
 
int local_offset () const override
 
Complex * output_buffer () const override
 
void prepare_forward_from_output () const override
 
void reduce_g_space (Complex *, int) const override
 
int total_grid_points () const override
 
- Public Member Functions inherited from q3::FFTGrid
virtual ~FFTGrid ()=default
 
virtual void assign_sticks (const std::vector< int > &)
 
virtual bool co_locates_mirrors () const
 
virtual int concurrent_transform_slots () const
 
virtual void execute_forward_on_slot (int) const
 Forward transform on slot slot, the slot-aware execute_forward_on_buffers().
 
virtual void execute_inverse_raw_on_slot (int) const
 Inverse transform on slot slot, the slot-aware execute_inverse_raw_on_buffers().
 
virtual void forward_batched (Complex *data, int batch_size) const
 
virtual void gather_local_g_space (const Complex *full_g_space, Complex *local_g_space) const
 
virtual int global_real_space_index (int local_index) const
 
virtual void initialize_batched_plans (int, bool=false) const
 
virtual int initialized_batched_plan_size () const
 
virtual void inverse_raw_batched (Complex *data, int batch_size) const
 
virtual void inverse_raw_on_slot (Complex *data, int) const
 
virtual int local_g_space_points () const
 
virtual bool owns_stick (int, int) const
 
virtual void prepare_forward_from_output_on_slot (int) const
 Output-to-input copy on slot slot, the slot-aware prepare_forward_from_output().
 
virtual void scatter_local_g_space (const Complex *local_g_space, Complex *full_g_space) const
 The reverse: place this rank's reciprocal-space points into a full array.
 
virtual int slab_dimension_1 () const
 
virtual Complex * slot_input_buffer (int) const
 
virtual Complex * slot_output_buffer (int) const
 

Detailed Description

SerialPocketFFTGrid — node-local 3D FFT implementation using PocketFFT.

PocketFFT (BSD-3-Clause, header-only; the C++ library NumPy and SciPy use) lets a build ship without any GPL-licensed FFT library. It has the same contract as the FFTW-backed serial grid: row-major [i1][i2][i3] storage, an exp(-iGr) forward transform, unnormalized forward and raw-inverse transforms, and out-of-place execution from input_buffer() to output_buffer().

PocketFFT has no planning step to tune, so use_measured_planning is accepted and ignored: every transform is deterministic by construction. Twiddle tables are cached by the library itself (POCKETFFT_CACHE_SIZE, set by the build). Threads follow OMP_NUM_THREADS, as the FFTW grid's do.

Definition at line 31 of file serial_pocket_fft_grid.hpp.

Member Function Documentation

◆ execute_forward_on_buffers()

void q3::SerialPocketFFTGrid::execute_forward_on_buffers ( ) const
inlineoverridevirtual

Execute a forward FFT on the internal buffers (no copy).

Caller must have populated input_buffer() before calling. Result is available in output_buffer() after this call.

Implements q3::FFTGrid.

Definition at line 120 of file serial_pocket_fft_grid.hpp.

References q3::ProfilingCounters::fft_call_count, and q3::ProfilingCounters::instance().

◆ execute_inverse_raw_on_buffers()

void q3::SerialPocketFFTGrid::execute_inverse_raw_on_buffers ( ) const
inlineoverridevirtual

Execute a raw inverse FFT on the internal buffers (no copy, no normalization).

Caller must have populated input_buffer() before calling. Result is available in output_buffer() after this call.

Implements q3::FFTGrid.

Definition at line 115 of file serial_pocket_fft_grid.hpp.

References q3::ProfilingCounters::fft_call_count, and q3::ProfilingCounters::instance().

◆ forward()

void q3::SerialPocketFFTGrid::forward ( Complex *  data) const
inlineoverridevirtual

Forward FFT: real-space -> reciprocal-space (unnormalized).

Implements q3::FFTGrid.

Definition at line 71 of file serial_pocket_fft_grid.hpp.

References q3::ProfilingCounters::fft_call_count, and q3::ProfilingCounters::instance().

◆ g_vector_to_fft_grid_index()

int q3::SerialPocketFFTGrid::g_vector_to_fft_grid_index ( int  miller_1,
int  miller_2,
int  miller_3 
) const
inlineoverridevirtual

Map a G-vector (integer Miller indices) to FFT array index. Handles negative indices via wrapping.

Implements q3::FFTGrid.

Definition at line 87 of file serial_pocket_fft_grid.hpp.

◆ grid_dimension_1()

int q3::SerialPocketFFTGrid::grid_dimension_1 ( ) const
inlineoverridevirtual

Grid size along the first dimension.

Implements q3::FFTGrid.

Definition at line 58 of file serial_pocket_fft_grid.hpp.

◆ grid_dimension_2()

int q3::SerialPocketFFTGrid::grid_dimension_2 ( ) const
inlineoverridevirtual

Grid size along the second dimension.

Implements q3::FFTGrid.

Definition at line 61 of file serial_pocket_fft_grid.hpp.

◆ grid_dimension_3()

int q3::SerialPocketFFTGrid::grid_dimension_3 ( ) const
inlineoverridevirtual

Grid size along the third dimension.

Implements q3::FFTGrid.

Definition at line 64 of file serial_pocket_fft_grid.hpp.

◆ init()

void q3::SerialPocketFFTGrid::init ( int  dimension_1,
int  dimension_2,
int  dimension_3,
bool  use_measured_planning = false 
)
inlineoverridevirtual

Initialize with grid dimensions (dimension_1 x dimension_2 x dimension_3).

Implements q3::FFTGrid.

Definition at line 33 of file serial_pocket_fft_grid.hpp.

References total_grid_points().

◆ input_buffer()

Complex * q3::SerialPocketFFTGrid::input_buffer ( ) const
inlineoverridevirtual

Access the FFT grid's internal input buffer for zero-copy transforms.

Callers scatter G-space data directly into this buffer, then call execute_inverse_raw_on_buffers() to transform in-place. This eliminates the memcpy overhead of inverse_raw() / forward().

The buffer has at least local_grid_points() elements of usable space.

Implements q3::FFTGrid.

Definition at line 107 of file serial_pocket_fft_grid.hpp.

◆ inverse()

void q3::SerialPocketFFTGrid::inverse ( Complex *  data) const
inlineoverridevirtual

Inverse FFT: reciprocal-space -> real-space (includes 1/N normalization).

Implements q3::FFTGrid.

Definition at line 76 of file serial_pocket_fft_grid.hpp.

References q3::ProfilingCounters::fft_call_count, q3::ProfilingCounters::instance(), and total_grid_points().

◆ inverse_raw()

void q3::SerialPocketFFTGrid::inverse_raw ( Complex *  data) const
inlineoverridevirtual

Inverse FFT without 1/N normalization (raw FFTW backward).

Implements q3::FFTGrid.

Definition at line 81 of file serial_pocket_fft_grid.hpp.

References q3::ProfilingCounters::fft_call_count, and q3::ProfilingCounters::instance().

◆ local_grid_points()

int q3::SerialPocketFFTGrid::local_grid_points ( ) const
inlineoverridevirtual

Number of real-space grid points stored on the local rank.

Implements q3::FFTGrid.

Definition at line 95 of file serial_pocket_fft_grid.hpp.

References total_grid_points().

◆ local_offset()

int q3::SerialPocketFFTGrid::local_offset ( ) const
inlineoverridevirtual

Offset into the global grid for the local segment (e.g., start of slab).

Implements q3::FFTGrid.

Definition at line 99 of file serial_pocket_fft_grid.hpp.

◆ output_buffer()

Complex * q3::SerialPocketFFTGrid::output_buffer ( ) const
inlineoverridevirtual

Access the FFT grid's internal output buffer for zero-copy transforms.

After execute_inverse_raw_on_buffers(), real-space data is here. After execute_forward_on_buffers(), G-space data is here.

For in-place plans (MPI FFT), this returns the same pointer as input_buffer(). For out-of-place plans (Serial FFT), this is a separate buffer.

Implements q3::FFTGrid.

Definition at line 111 of file serial_pocket_fft_grid.hpp.

◆ prepare_forward_from_output()

void q3::SerialPocketFFTGrid::prepare_forward_from_output ( ) const
inlineoverridevirtual

Prepare the input buffer for a forward transform after modifying the output buffer.

For out-of-place plans (Serial FFT), this copies output_buffer → input_buffer. For in-place plans (MPI FFT), this is a no-op (same buffer).

Call this between the real-space multiply and execute_forward_on_buffers().

Implements q3::FFTGrid.

Definition at line 125 of file serial_pocket_fft_grid.hpp.

References total_grid_points().

◆ reduce_g_space()

void q3::SerialPocketFFTGrid::reduce_g_space ( Complex *  data,
int  number_of_elements 
) const
inlineoverridevirtual

Reduce G-space data across the pool to make it redundant on all ranks.

Serial: no-op. MPI: MPI_Allreduce(MPI_IN_PLACE, ..., MPI_SUM, pool_comm).

Implements q3::FFTGrid.

Definition at line 103 of file serial_pocket_fft_grid.hpp.

◆ total_grid_points()

int q3::SerialPocketFFTGrid::total_grid_points ( ) const
inlineoverridevirtual

Total number of real-space grid points across all processes.

Implements q3::FFTGrid.

Definition at line 67 of file serial_pocket_fft_grid.hpp.

Referenced by init(), inverse(), local_grid_points(), and prepare_forward_from_output().


The documentation for this class was generated from the following file: