Grid
Note
A Grid object can be safely destroyed after Transform objects have been created, since internal reference counting used to prevent the release of resources while still in use.
-
class Grid
A Grid, which provides pre-allocated memory for double precision transforms.
Public Functions
-
Grid(int maxDimX, int maxDimY, int maxDimZ, int maxNumLocalZColumns, SpfftProcessingUnitType processingUnit, int maxNumThreads)
Constructor for a local grid.
- Parameters:
maxDimX – [in] Maximum dimension in x.
maxDimY – [in] Maximum dimension in y.
maxDimZ – [in] Maximum dimension in z.
maxNumLocalZColumns – [in] Maximum number of z-columns in frequency domain.
processingUnit – [in] The processing unit type to prepare for. Can be SPFFT_PU_HOST or SPFFT_PU_GPU or SPFFT_PU_HOST | SPFFT_PU_GPU.
maxNumThreads – [in] The maximum number of threads, transforms created with this grid are allowed to use. If smaller than 1, the OpenMP default value is used.
- Throws:
GenericError – SpFFT error. Can be a derived type.
std::exception – Error from standard library calls. Can be a derived type.
-
Grid(int maxDimX, int maxDimY, int maxDimZ, int maxNumLocalZColumns, int maxLocalZLength, SpfftProcessingUnitType processingUnit, int maxNumThreads, MPI_Comm comm, SpfftExchangeType exchangeType)
Constructor for a distributed grid.
Thread-safe if MPI thread support is set to MPI_THREAD_MULTIPLE.
- Parameters:
maxDimX – [in] Maximum dimension in x.
maxDimY – [in] Maximum dimension in y.
maxDimZ – [in] Maximum dimension in z.
maxNumLocalZColumns – [in] Maximum number of z-columns in frequency domain of the local MPI rank.
maxLocalZLength – [in] Maximum length in z in space domain for the local MPI rank.
processingUnit – [in] The processing unit type to prepare for. Can be SPFFT_PU_HOST or SPFFT_PU_GPU or SPFFT_PU_HOST | SPFFT_PU_GPU.
maxNumThreads – [in] The maximum number of threads, transforms created with this grid are allowed to use. If smaller than 1, the OpenMP default value is used.
comm – [in] The MPI communicator to use. Will be duplicated for internal use.
exchangeType – [in] The type of MPI exchange to use. Possible values are SPFFT_EXCH_DEFAULT, SPFFT_EXCH_BUFFERED, SPFFT_EXCH_COMPACT_BUFFERED and SPFFT_EXCH_UNBUFFERED.
- Throws:
GenericError – SpFFT error. Can be a derived type.
std::exception – Error from standard library calls. Can be a derived type.
-
Grid(const Grid&)
Custom copy constructor.
Creates a independent copy. Calls MPI functions for the distributed case.
-
Grid &operator=(const Grid&)
Custom copy operator.
Creates a independent copy. Calls MPI functions for the distributed case.
-
Transform create_transform(SpfftProcessingUnitType processingUnit, SpfftTransformType transformType, int dimX, int dimY, int dimZ, int localZLength, int numLocalElements, SpfftIndexFormatType indexFormat, const int *indices) const
Creates a transform from this grid object.
Thread-safe if no FFTW calls are executed concurrently.
- Parameters:
processingUnit – [in] The processing unit type to use. Must be either SPFFT_PU_HOST or SPFFT_PU_GPU and be supported by the grid itself.
transformType – [in] The transform type (complex to complex or real to complex). Can be SPFFT_TRANS_C2C or SPFFT_TRANS_R2C.
dimX – [in] The dimension in x. The maximum allowed depends on the grid parameters.
dimY – [in] The dimension in y. The maximum allowed depends on the grid parameters.
dimZ – [in] The dimension in z. The maximum allowed depends on the grid parameters.
localZLength – [in] The length in z in space domain of the local MPI rank.
numLocalElements – [in] The number of elements in frequency domain of the local MPI rank.
indexFormat – [in] The index format. Only SPFFT_INDEX_TRIPLETS currently supported.
indices – [in] Pointer to the frequency indices. Posive and negative indexing is supported.
- Throws:
GenericError – SpFFT error. Can be a derived type.
std::exception – Error from standard library calls. Can be a derived type.
- Returns:
-
int max_dim_x() const
Access a grid parameter.
- Returns:
Maximum dimension in x.
-
int max_dim_y() const
Access a grid parameter.
- Returns:
Maximum dimension in y.
-
int max_dim_z() const
Access a grid parameter.
- Returns:
Maximum dimension in z.
-
int max_num_local_z_columns() const
Access a grid parameter.
- Returns:
Maximum number of z-columns in frequency domain of the local MPI rank.
-
int max_local_z_length() const
Access a grid parameter.
- Returns:
Maximum length in z in space domain of the local MPI rank.
-
SpfftProcessingUnitType processing_unit() const
Access a grid parameter.
- Returns:
The processing unit, the grid has prepared for. Can be SPFFT_PU_HOST or SPFFT_PU_GPU or SPFFT_PU_HOST | SPFFT_PU_GPU.
-
int device_id() const
Access a grid parameter.
- Returns:
The GPU device id used. Always returns 0, if no GPU support is enabled.
-
int num_threads() const
Access a grid parameter.
- Returns:
The exact number of threads used by transforms created from this grid. May be less than the maximum given to the constructor. Always 1, if not compiled with OpenMP support.
-
MPI_Comm communicator() const
Access a grid parameter.
- Returns:
The internal MPI communicator.
-
Grid(int maxDimX, int maxDimY, int maxDimZ, int maxNumLocalZColumns, SpfftProcessingUnitType processingUnit, int maxNumThreads)