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

#include <fft_grid_sticks.hpp>

+ Inheritance diagram for q3::FFTGridSticks:

Public Member Functions

 FFTGridSticks (const FFTGridSticks &)=delete
 
 FFTGridSticks (MPI_Comm communicator)
 
 ~FFTGridSticks () override
 
void assign_sticks (const std::vector< int > &stick_weights) override
 
bool co_locates_mirrors () const override
 
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
 
void gather_local_g_space (const Complex *full_g_space, Complex *local_g_space) const override
 
int global_real_space_index (int local_index) const override
 Local real space is [plane][i1][i2], the plane counted from local_offset().
 
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 use_measured_planning=false) override
 
Complex * input_buffer () const override
 
void inverse (Complex *data) const override
 
void inverse_raw (Complex *data) const override
 
int local_g_space_points () const override
 
int local_grid_points () const override
 
int local_offset () const override
 First plane along the third dimension held here.
 
int local_sticks () const
 
FFTGridSticks & operator= (const FFTGridSticks &)=delete
 
Complex * output_buffer () const override
 
bool owns_stick (int miller_1, int miller_2) const override
 
const FFTStickPartition & partition () const
 
void prepare_forward_from_output () const override
 The forward transform consumes the plane buffer directly.
 
void reduce_g_space (Complex *data, int number_of_elements) const override
 
void scatter_local_g_space (const Complex *local_g_space, Complex *full_g_space) const override
 The reverse: place this rank's reciprocal-space points into a full array.
 
int slab_dimension_1 () const override
 No restriction along the first dimension: ownership is by stick.
 
int total_grid_points () const override
 
- Public Member Functions inherited from q3::FFTGrid
virtual ~FFTGrid ()=default
 
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 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 void prepare_forward_from_output_on_slot (int) const
 Output-to-input copy on slot slot, the slot-aware prepare_forward_from_output().
 
virtual Complex * slot_input_buffer (int) const
 
virtual Complex * slot_output_buffer (int) const
 

Detailed Description

Definition at line 56 of file fft_grid_sticks.hpp.

Constructor & Destructor Documentation

◆ FFTGridSticks() [1/2]

q3::FFTGridSticks::FFTGridSticks ( MPI_Comm  communicator)
inlineexplicit

Definition at line 58 of file fft_grid_sticks.hpp.

◆ ~FFTGridSticks()

q3::FFTGridSticks::~FFTGridSticks ( )
inlineoverride

Definition at line 63 of file fft_grid_sticks.hpp.

◆ FFTGridSticks() [2/2]

q3::FFTGridSticks::FFTGridSticks ( const FFTGridSticks &  )
delete

Member Function Documentation

◆ assign_sticks()

void q3::FFTGridSticks::assign_sticks ( const std::vector< int > &  stick_weights)
inlineoverridevirtual

Assign sticks to ranks from a weight per stick – the number of G-vectors on it inside the cutoff, zero for an empty stick – and rebuild the communication plan and the FFTW plans to match.

Every rank enumerates every rank's sticks in the same order, so the transpose can be unpacked without exchanging index lists.

All-to-all counts. Rank r sends, to rank q, the plane range of q for each of r's sticks; it receives from q the plane range of r for each of q's sticks.

Reimplemented from q3::FFTGrid.

Definition at line 115 of file fft_grid_sticks.hpp.

References q3::FFTStickPartition::build(), q3::FFTStickPartition::owner_of(), and q3::FFTStickPartition::unassigned.

Referenced by init().

◆ co_locates_mirrors()

bool q3::FFTGridSticks::co_locates_mirrors ( ) const
inlineoverridevirtual

Whether a G-vector and its negative are always held by the same rank. True for a serial grid and for the stick layout; false for slabs, which is what forced the gamma-only path off under MPI.

Reimplemented from q3::FFTGrid.

Definition at line 228 of file fft_grid_sticks.hpp.

◆ execute_forward_on_buffers()

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

The interface promises the result of any transform in output_buffer(). The forward transform lands in the stick buffer, so it is copied across – one memcpy of the G-space count, the same order as the transpose pack – rather than making every consumer learn which buffer to read.

Implements q3::FFTGrid.

Definition at line 286 of file fft_grid_sticks.hpp.

◆ execute_inverse_raw_on_buffers()

void q3::FFTGridSticks::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 276 of file fft_grid_sticks.hpp.

◆ forward()

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

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

Implements q3::FFTGrid.

Definition at line 298 of file fft_grid_sticks.hpp.

◆ g_vector_to_fft_grid_index()

int q3::FFTGridSticks::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 255 of file fft_grid_sticks.hpp.

References q3::FFTStickPartition::wrap().

◆ gather_local_g_space()

void q3::FFTGridSticks::gather_local_g_space ( const Complex *  full_g_space,
Complex *  local_g_space 
) const
inlineoverridevirtual

Copy this rank's reciprocal-space points out of a full, replicated G-space array laid out [i1][i2][i3], into the local G-space layout. The slab layout is a contiguous run at local_offset(); the stick layout is not, so consumers must go through this rather than a memcpy.

Reimplemented from q3::FFTGrid.

Definition at line 232 of file fft_grid_sticks.hpp.

◆ global_real_space_index()

int q3::FFTGridSticks::global_real_space_index ( int  local_index) const
inlineoverridevirtual

Local real space is [plane][i1][i2], the plane counted from local_offset().

Reimplemented from q3::FFTGrid.

Definition at line 209 of file fft_grid_sticks.hpp.

◆ grid_dimension_1()

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

Grid size along the first dimension.

Implements q3::FFTGrid.

Definition at line 186 of file fft_grid_sticks.hpp.

◆ grid_dimension_2()

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

Grid size along the second dimension.

Implements q3::FFTGrid.

Definition at line 189 of file fft_grid_sticks.hpp.

◆ grid_dimension_3()

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

Grid size along the third dimension.

Implements q3::FFTGrid.

Definition at line 192 of file fft_grid_sticks.hpp.

◆ init()

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

Size the grid and, until told otherwise, treat every stick as occupied. assign_sticks() narrows that to the sticks inside a cutoff once the basis knows which those are.

Planes along the third dimension, contiguous ranges, the remainder spread one plane at a time over the lowest ranks.

Implements q3::FFTGrid.

Definition at line 75 of file fft_grid_sticks.hpp.

References assign_sticks().

◆ input_buffer()

Complex * q3::FFTGridSticks::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 269 of file fft_grid_sticks.hpp.

◆ inverse()

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

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

Implements q3::FFTGrid.

Definition at line 310 of file fft_grid_sticks.hpp.

References inverse_raw().

◆ inverse_raw()

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

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

Implements q3::FFTGrid.

Definition at line 304 of file fft_grid_sticks.hpp.

Referenced by inverse().

◆ local_g_space_points()

int q3::FFTGridSticks::local_g_space_points ( ) const
inlineoverridevirtual

Number of reciprocal-space points this rank holds.

Equal to local_grid_points() for every layout in which G-space and real space share a buffer. The stick decomposition holds G-space as whole sticks and real space as whole planes, so the two counts differ, and a caller sizing a G-space scatter must ask this rather than assume.

Reimplemented from q3::FFTGrid.

Definition at line 201 of file fft_grid_sticks.hpp.

◆ local_grid_points()

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

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

Implements q3::FFTGrid.

Definition at line 198 of file fft_grid_sticks.hpp.

◆ local_offset()

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

First plane along the third dimension held here.

Implements q3::FFTGrid.

Definition at line 205 of file fft_grid_sticks.hpp.

◆ local_sticks()

int q3::FFTGridSticks::local_sticks ( ) const
inline

Definition at line 221 of file fft_grid_sticks.hpp.

◆ operator=()

FFTGridSticks & q3::FFTGridSticks::operator= ( const FFTGridSticks &  )
delete

◆ output_buffer()

Complex * q3::FFTGridSticks::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 272 of file fft_grid_sticks.hpp.

◆ owns_stick()

bool q3::FFTGridSticks::owns_stick ( int  ,
int   
) const
inlineoverridevirtual

Whether this rank holds the G-vectors sharing the first two Miller indices. True everywhere for a layout that does not distribute G-space by stick; the plane-wave selector asks this to decide what to keep.

Reimplemented from q3::FFTGrid.

Definition at line 250 of file fft_grid_sticks.hpp.

References q3::FFTStickPartition::owner_of_miller().

◆ partition()

const FFTStickPartition & q3::FFTGridSticks::partition ( ) const
inline

Definition at line 224 of file fft_grid_sticks.hpp.

◆ prepare_forward_from_output()

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

The forward transform consumes the plane buffer directly.

Implements q3::FFTGrid.

Definition at line 294 of file fft_grid_sticks.hpp.

◆ reduce_g_space()

void q3::FFTGridSticks::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 318 of file fft_grid_sticks.hpp.

◆ scatter_local_g_space()

void q3::FFTGridSticks::scatter_local_g_space ( const Complex *  local_g_space,
Complex *  full_g_space 
) const
inlineoverridevirtual

The reverse: place this rank's reciprocal-space points into a full array.

Reimplemented from q3::FFTGrid.

Definition at line 241 of file fft_grid_sticks.hpp.

◆ slab_dimension_1()

int q3::FFTGridSticks::slab_dimension_1 ( ) const
inlineoverridevirtual

No restriction along the first dimension: ownership is by stick.

Reimplemented from q3::FFTGrid.

Definition at line 218 of file fft_grid_sticks.hpp.

◆ total_grid_points()

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

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

Implements q3::FFTGrid.

Definition at line 195 of file fft_grid_sticks.hpp.


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