Transform

Note

This class only holds an internal reference counted object. The object remains in a usable state even if the associated Grid object is destroyed. In addition, copying a transform only requires an internal copy of a shared pointer.

class Transform

A transform in double precision with fixed dimensions.

Shares memory with other transform created from the same Grid object.

Public Functions

Transform(int maxNumThreads, SpfftProcessingUnitType processingUnit, SpfftTransformType transformType, int dimX, int dimY, int dimZ, int numLocalElements, SpfftIndexFormatType indexFormat, const int *indices)

Create a transform without a grid handle.

Thread-safe if no FFTW calls are executed concurrently.

Parameters:
  • maxNumThreads[in] The maximum number of threads to use.

  • processingUnit[in] The processing unit type to use. Must be either SPFFT_PU_HOST or SPFFT_PU_GPU.

  • 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.

  • dimY[in] The dimension in y.

  • dimZ[in] The dimension in z.

  • numLocalElements[in] The number of elements in frequency domain.

  • indexFormat[in] The index format. Only SPFFT_INDEX_TRIPLETS currently supported.

  • indices[in] Pointer to frequency indices. Centered indexing is allowed.

Transform(int maxNumThreads, MPI_Comm comm, SpfftExchangeType exchangeType, SpfftProcessingUnitType processingUnit, SpfftTransformType transformType, int dimX, int dimY, int dimZ, int localZLength, int numLocalElements, SpfftIndexFormatType indexFormat, const int *indices)

Create a distributed transform without a grid handle.

Thread-safe if no FFTW calls are executed concurrently.

Parameters:
  • maxNumThreads[in] The maximum number of threads to use.

  • 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.

  • processingUnit[in] The processing unit type to use. Must be either SPFFT_PU_HOST or SPFFT_PU_GPU.

  • 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.

  • dimY[in] The dimension in y.

  • dimZ[in] The dimension in z.

  • 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 frequency indices. Centered indexing is allowed.

Transform(const Transform&) = default

Default copy constructor.

Transform(Transform&&) = default

Default move constructor.

Transform &operator=(const Transform&) = default

Default copy operator.

Transform &operator=(Transform&&) = default

Default move operator.

Transform clone() const

Clone transform.

Returns:

Independent transform with the same parameters, but with new underlying grid.

SpfftTransformType type() const

Access a transform parameter.

Returns:

Type of transform.

int dim_x() const

Access a transform parameter.

Returns:

Dimension in x.

int dim_y() const

Access a transform parameter.

Returns:

Dimension in y.

int dim_z() const

Access a transform parameter.

Returns:

Dimension in z.

int local_z_length() const

Access a transform parameter.

Returns:

Length in z of the space domain slice held by the local MPI rank.

int local_z_offset() const

Access a transform parameter.

Returns:

Offset in z of the space domain slice held by the local MPI rank.

int local_slice_size() const

Access a transform parameter.

Returns:

Number of elements in the space domain slice held by the local MPI rank.

long long int global_size() const

Access a transform parameter.

Returns:

Global number of elements in space domain. Equals dim_x() * dim_y() * dim_z().

int num_local_elements() const

Access a transform parameter.

Returns:

Number of elements in frequency domain.

long long int num_global_elements() const

Access a transform parameter.

Returns:

Global number of elements in frequency domain.

SpfftProcessingUnitType processing_unit() const

Access a transform parameter.

Returns:

The processing unit used for calculations. Can be SPFFT_PU_HOST or SPFFT_PU_GPU.

int device_id() const

Access a transform parameter.

Returns:

The GPU device id used. Returns always 0, if no GPU support is enabled.

int num_threads() const

Access a transform 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.

SpfftExecType execution_mode() const

Access a transform parameter.

Returns:

The execution mode. Only affects execution on GPU. Defaults to SPFFT_EXEC_SYNCHRONOUS.

void set_execution_mode(SpfftExecType mode)

Set a transform parameter.

Parameters:

mode[in] The execution mode to change to. Only affects execution on GPU. Defaults to SPFFT_EXEC_SYNCHRONOUS.

MPI_Comm communicator() const

Access a transform parameter.

Returns:

The internal MPI communicator.

double *space_domain_data(SpfftProcessingUnitType dataLocation)

Provides access to the space domain data.

Parameters:

dataLocation[in] The processing unit to query for the data. Can be SPFFT_PU_HOST or SPFFT_PU_GPU (if GPU is set as execution unit).

Throws:
  • GenericError – SpFFT error. Can be a derived type.

  • std::exception – Error from standard library calls. Can be a derived type.

Returns:

Pointer to space domain data on given processing unit. Alignment is guaranteed to fulfill requirements for std::complex and C language complex types.

void forward(SpfftProcessingUnitType inputLocation, double *output, SpfftScalingType scaling = SPFFT_NO_SCALING)

Execute a forward transform from space domain to frequency domain.

Parameters:
  • inputLocation[in] The processing unit, to take the input from. Can be SPFFT_PU_HOST or SPFFT_PU_GPU (if GPU is set as execution unit).

  • output[out] Pointer to memory, where the frequency domain elements are written to. Can be located at Host or GPU memory (if GPU is set as processing unit).

  • scaling[in] Controls scaling of output. SPFFT_NO_SCALING to disable or SPFFT_FULL_SCALING to scale by factor 1 / (dim_x() * dim_y() * dim_z()).

Throws:
  • GenericError – SpFFT error. Can be a derived type.

  • std::exception – Error from standard library calls. Can be a derived type.

void forward(const double *input, double *output, SpfftScalingType scaling = SPFFT_NO_SCALING)

Execute a forward transform from space domain to frequency domain.

Parameters:
  • input[in] Pointer to memory, to read space domain data from. Can be located at Host or GPU memory (if GPU is set as processing unit).

  • output[out] Pointer to memory, where the frequency domain elements are written to. Can be located at Host or GPU memory (if GPU is set as processing unit).

  • scaling[in] Controls scaling of output. SPFFT_NO_SCALING to disable or SPFFT_FULL_SCALING to scale by factor 1 / (dim_x() * dim_y() * dim_z()).

Throws:
  • GenericError – SpFFT error. Can be a derived type.

  • std::exception – Error from standard library calls. Can be a derived type.

void backward(const double *input, SpfftProcessingUnitType outputLocation)

Execute a backward transform from frequency domain to space domain.

Parameters:
  • input[in] Input data in frequency domain. Must match the indices provided at transform creation. Can be located at Host or GPU memory, if GPU is set as processing unit.

  • outputLocation[in] The processing unit, to place the output at. Can be SPFFT_PU_HOST or SPFFT_PU_GPU (if GPU is set as execution unit).

Throws:
  • GenericError – SpFFT error. Can be a derived type.

  • std::exception – Error from standard library calls. Can be a derived type.

void backward(const double *input, double *output)

Execute a backward transform from frequency domain to space domain.

Parameters:
  • input[in] Input data in frequency domain. Must match the indices provided at transform creation. Can be located at Host or GPU memory, if GPU is set as processing unit.

  • output[out] Pointer to memory to write output in frequency domain to. Can be located at Host or GPU memory, if GPU is set as processing unit.

Throws:
  • GenericError – SpFFT error. Can be a derived type.

  • std::exception – Error from standard library calls. Can be a derived type.