Python API Reference¶
This page provides the generated Python API reference for dtfft with explicit per-object documentation.
Exceptions¶
- dtfft.dtfft_Exception¶
alias of
Exception
Enumerations and Constants¶
- class dtfft.Version¶
dtFFT version information
- CODE = 302000¶
- MAJOR = 3¶
- MINOR = 2¶
- PATCH = 0¶
- static get(*args, **kwargs)¶
Overloaded function.
get() -> int
Get Version Code defined during compilation
get(major: typing.SupportsInt | typing.SupportsIndex, minor: typing.SupportsInt | typing.SupportsIndex, patch: typing.SupportsInt | typing.SupportsIndex) -> int
Get Version Code based on input parameters
- enum dtfft.Execute(value)¶
This class lists valid execute_type parameters that can be passed to Plan.execute.
Valid values are as follows:
- FORWARD = <Execute.FORWARD: 11>¶
Perform XYZ –> YZX –> ZXY plan execution (Forward)
- BACKWARD = <Execute.BACKWARD: 12>¶
Perform ZXY –> YZX –> XYZ plan execution (Backward)
- enum dtfft.Transpose(value)¶
This class lists valid
transpose_typeparameters that can be passed to Plan.transpose.Valid values are as follows:
- X_TO_Y = <Transpose.X_TO_Y: 1>¶
Transpose from Fortran X aligned to Fortran Y aligned
- Y_TO_X = <Transpose.Y_TO_X: -1>¶
Transpose from Fortran Y aligned to Fortran X aligned
- Y_TO_Z = <Transpose.Y_TO_Z: 2>¶
Transpose from Fortran Y aligned to Fortran Z aligned
- Z_TO_Y = <Transpose.Z_TO_Y: -2>¶
Transpose from Fortran Z aligned to Fortran Y aligned
- X_TO_Z = <Transpose.X_TO_Z: 3>¶
Transpose from Fortran X aligned to Fortran Z aligned. Note: This value is valid to pass only in 3D Plan and value returned by Plan.get_z_slab_enabled must be true
- Z_TO_X = <Transpose.Z_TO_X: -3>¶
Transpose from Fortran Z aligned to Fortran X aligned. Note: This value is valid to pass only in 3D Plan and value returned by Plan.get_z_slab_enabled must be true
- enum dtfft.Reshape(value)¶
This class lists valid reshape types that can be passed to Plan.reshape.
Valid values are as follows:
- X_BRICKS_TO_PENCILS = <Reshape.X_BRICKS_TO_PENCILS: 11>¶
Reshape from X bricks to X pencils
- X_PENCILS_TO_BRICKS = <Reshape.X_PENCILS_TO_BRICKS: 12>¶
Reshape from X pencils to X bricks
- Z_BRICKS_TO_PENCILS = <Reshape.Z_BRICKS_TO_PENCILS: 14>¶
Reshape from Y bricks to Y pencils
- Z_PENCILS_TO_BRICKS = <Reshape.Z_PENCILS_TO_BRICKS: 13>¶
Reshape from Y pencils to Y bricks
- enum dtfft.Layout(value)¶
This class lists valid layout parameters that can be passed to Plan.get_pencil.
Valid values are as follows:
- X_BRICKS = <Layout.X_BRICKS: 1>¶
X-brick layout
- X_PENCILS = <Layout.X_PENCILS: 2>¶
X-pencil layout
- X_PENCILS_FOURIER = <Layout.X_PENCILS_FOURIER: 3>¶
X-pencil Fourier layout for R2C plans
- Y_PENCILS = <Layout.Y_PENCILS: 4>¶
Y-pencil layout
- Z_PENCILS = <Layout.Z_PENCILS: 5>¶
Z-pencil layout
- Z_BRICKS = <Layout.Z_BRICKS: 6>¶
Z-brick layout
- enum dtfft.Precision(value)¶
This class lists valid precision parameters that can be passed to Plan constructors.
Valid values are as follows:
- SINGLE = <Precision.SINGLE: 0>¶
Use Single precision
- DOUBLE = <Precision.DOUBLE: 1>¶
Use Double precision
- enum dtfft.Effort(value)¶
This class lists valid effort parameters that can be passed to Plan constructors.
Valid values are as follows:
- ESTIMATE = <Effort.ESTIMATE: 0>¶
Create plan as fast as possible
- MEASURE = <Effort.MEASURE: 1>¶
Will attempt to find best MPI Grid decomposition. Passing this flag and MPI Communicator with cartesian topology to any Plan Constructor is same as Effort::ESTIMATE.
- PATIENT = <Effort.PATIENT: 2>¶
Same as Effort::MEASURE plus cycle through various send and receive MPI_Datatypes. For GPU Build this flag will run autotune procedure to find best backend
- EXHAUSTIVE = <Effort.EXHAUSTIVE: 3>¶
Same as Effort::PATIENT plus autotune all possible kernels and reshape backends.
- enum dtfft.Executor(value)¶
This class lists available FFT executors.
Valid values are as follows:
- NONE = <Executor.NONE: 0>¶
Do not create any FFT plans. Creates transpose only plan.
- FFTW3 = <Executor.FFTW3: 1>¶
FFTW3 Executor (Host only)
- MKL = <Executor.MKL: 2>¶
MKL DFTI Executor (Host only)
- CUFFT = <Executor.CUFFT: 3>¶
CUFFT Executor (GPU Only)
- VKFFT = <Executor.VKFFT: 4>¶
VkFFT Executor (GPU Only)
- enum dtfft.R2RKind(value)¶
Real-to-Real FFT kinds available in dtFFT
Valid values are as follows:
- DCT_1 = <R2RKind.DCT_1: 3>¶
DCT-I (Logical N=2*(n-1), inverse is R2RKind::DCT_1)
- DCT_2 = <R2RKind.DCT_2: 5>¶
DCT-II (Logical N=2*n, inverse is R2RKind::DCT_3)
- DCT_3 = <R2RKind.DCT_3: 4>¶
DCT-III (Logical N=2*n, inverse is R2RKind::DCT_2)
- DCT_4 = <R2RKind.DCT_4: 6>¶
DCT-IV (Logical N=2*n, inverse is R2RKind::DCT_4)
- DST_1 = <R2RKind.DST_1: 7>¶
DST-I (Logical N=2*(n+1), inverse is R2RKind::DST_1)
- DST_2 = <R2RKind.DST_2: 9>¶
DST-II (Logical N=2*n, inverse is R2RKind::DST_3)
- DST_3 = <R2RKind.DST_3: 8>¶
DST-III (Logical N=2*n, inverse is R2RKind::DST_2)
- DST_4 = <R2RKind.DST_4: 10>¶
DST-IV (Logical N=2*n, inverse is R2RKind::DST_4)
- enum dtfft.TransposeMode(value)¶
This class lists possible local transposition modes for generic backends.
Valid values are as follows:
- PACK = <TransposeMode.PACK: 15>¶
Perform transposition during packing
- UNPACK = <TransposeMode.UNPACK: 16>¶
Perform transposition during unpacking
- enum dtfft.AccessMode(value)¶
This class lists memory access modes for local transposition in generic backends.
Valid values are as follows:
- WRITE = <AccessMode.WRITE: -1>¶
Write-aligned access
- READ = <AccessMode.READ: 1>¶
Read-aligned access
- enum dtfft.Backend(value)¶
Various backends available in dtFFT.
Valid values are as follows:
- MPI_DATATYPE = <Backend.MPI_DATATYPE: 21>¶
Backend that uses MPI datatypes.
- MPI_P2P = <Backend.MPI_P2P: 22>¶
MPI peer-to-peer algorithm
- MPI_P2P_PIPELINED = <Backend.MPI_P2P_PIPELINED: 26>¶
MPI peer-to-peer algorithm with overlapping data copying and unpacking
- MPI_A2A = <Backend.MPI_A2A: 23>¶
MPI backend using MPI_Alltoall[v]
- MPI_RMA = <Backend.MPI_RMA: 29>¶
MPI backend using one-sided communications
- MPI_RMA_PIPELINED = <Backend.MPI_RMA_PIPELINED: 30>¶
MPI backend using pipelined one-sided communications
- MPI_P2P_SCHEDULED = <Backend.MPI_P2P_SCHEDULED: 31>¶
MPI peer-to-peer algorithm with scheduled communication
- MPI_P2P_FUSED = <Backend.MPI_P2P_FUSED: 32>¶
MPI peer-to-peer pipelined algorithm with overlapping packing, exchange and unpacking with scheduled communication
- MPI_RMA_FUSED = <Backend.MPI_RMA_FUSED: 33>¶
MPI RMA pipelined algorithm with overlapping packing, exchange and unpacking with scheduled communication
- MPI_P2P_COMPRESSED = <Backend.MPI_P2P_COMPRESSED: 34>¶
MPI peer-to-peer fused backend with compression
- MPI_RMA_COMPRESSED = <Backend.MPI_RMA_COMPRESSED: 35>¶
MPI RMA fused backend with compression
- NCCL = <Backend.NCCL: 24>¶
NCCL backend
- NCCL_PIPELINED = <Backend.NCCL_PIPELINED: 27>¶
NCCL backend with overlapping data copying and unpacking
- NCCL_COMPRESSED = <Backend.NCCL_COMPRESSED: 37>¶
NCCL backend with compression
- CUFFTMP = <Backend.CUFFTMP: 25>¶
cuFFTMp backend
- CUFFTMP_PIPELINED = <Backend.CUFFTMP_PIPELINED: 28>¶
cuFFTMp backend with an additional internal buffer
- ADAPTIVE = <Backend.ADAPTIVE: 36>¶
Adaptive backend selection
- NONE = <Backend.NONE: -111>¶
Backend is not defined
- enum dtfft.Platform(value)¶
Runtime platform enum used by dtFFT plans.
Valid values are as follows:
- HOST = <Platform.HOST: 0>¶
- CUDA = <Platform.CUDA: 1>¶
- enum dtfft.CompressionMode(value)¶
Compression mode.
Valid values are as follows:
- LOSSLESS = <CompressionMode.LOSSLESS: 1>¶
Lossless compression mode.
- FIXED_RATE = <CompressionMode.FIXED_RATE: 2>¶
Fixed rate compression mode.
- FIXED_PRECISION = <CompressionMode.FIXED_PRECISION: 3>¶
Fixed precision compression mode.
- FIXED_ACCURACY = <CompressionMode.FIXED_ACCURACY: 4>¶
Fixed accuracy compression mode.
Functions¶
- dtfft.get_backend_string(backend: Backend) str[source]¶
Return string representation of a
Backendvalue.
Core Classes¶
- class dtfft.Config(*, enable_log: bool | None = None, enable_z_slab: bool | None = None, enable_y_slab: bool | None = None, measure_warmup_iters: int | None = None, measure_iters: int | None = None, backend: Backend | None = None, reshape_backend: Backend | None = None, enable_datatype_backend: bool | None = None, enable_mpi_backends: bool | None = None, enable_pipelined_backends: bool | None = None, enable_rma_backends: bool | None = None, enable_fused_backends: bool | None = None, enable_kernel_autotune: bool | None = None, enable_fourier_reshape: bool | None = None, transpose_mode: TransposeMode | None = None, access_mode: AccessMode | None = None, platform: Platform | None = None, stream: cp.cuda.Stream | None = None, enable_nccl_backends: bool | None = None, enable_nvshmem_backends: bool | None = None, enable_compressed_backends: bool | None = None, compression_config_transpose: CompressionConfig | None = None, compression_config_reshape: CompressionConfig | None = None)[source]¶
Configuration object applied before plan creation.
- Parameters:
enable_log (bool, optional) – Whether dtFFT should print additional information (default:
False).enable_z_slab (bool, optional) – Whether dtFFT uses Z-slab optimisation (default:
True).enable_y_slab (bool, optional) – Whether dtFFT uses Y-slab optimisation (default:
False).measure_warmup_iters (int, optional) – Number of warmup iterations used during autotuning.
measure_iters (int, optional) – Number of measurement iterations used during autotuning.
backend (Backend, optional) – Backend used when
effortisESTIMATEorMEASURE.reshape_backend (Backend, optional) – Backend used for reshape operations when
effortisESTIMATEorMEASURE.enable_datatype_backend (bool, optional) – Whether MPI datatype backend is enabled for autotuning (default:
True).enable_mpi_backends (bool, optional) – Whether MPI backends are enabled for
PATIENTeffort (default:False).enable_pipelined_backends (bool, optional) – Whether pipelined backends are enabled for
PATIENTeffort (default:True).enable_rma_backends (bool, optional) – Whether RMA backends are enabled for
PATIENTeffort (default:True).enable_fused_backends (bool, optional) – Whether fused backends are enabled for
PATIENTeffort (default:True).enable_kernel_autotune (bool, optional) – Whether kernel launch parameter autotuning is enabled below
EXHAUSTIVE(default:False).enable_fourier_reshape (bool, optional) – Whether Fourier-space reshapes are executed during
Plan.execute(default:False).transpose_mode (TransposeMode, optional) – At which stage local transposition is performed for generic backends.
access_mode (AccessMode, optional) – Memory access mode for local transposition in generic backends.
platform (Platform, optional) – Execution platform (default:
Platform.HOST). CUDA builds only.stream (cp.cuda.Stream, optional) – CUDA stream to use for all operations. If not specified, dtFFT will create stream internally. Such stream can be retrieved via the stream property of the plan after creation. CUDA builds only.
enable_nccl_backends (bool, optional) – Whether NCCL backends are enabled for
PATIENTeffort (default:True). CUDA builds only.enable_nvshmem_backends (bool, optional) – Whether NVSHMEM backends are enabled for
PATIENTeffort (default:True). CUDA builds only.enable_compressed_backends (bool, optional) – Whether compressed backends are enabled for autotuning. Compression builds only.
compression_config_transpose (CompressionConfig, optional) – Compression configuration for transpose operations. Compression builds only.
compression_config_reshape (CompressionConfig, optional) – Compression configuration for reshape operations. Compression builds only.
- Raises:
AttributeError – If an option is not available in the current build.
Notes
Values are passed to dtFFT via
set_config()right before plan construction when a config is provided to a plan constructor.
- class dtfft.Pencil(starts: list[int] = None, counts: list[int] = None, pencil: Pencil = None)[source]¶
Create a Pencil decomposition object that can be passed to plan constructors.
- Parameters:
starts (list[int], optional) – Starting indices of the local data block in each dimension.
counts (list[int], optional) – Number of elements in the local data block in each dimension.
pencil (_dtfft.Pencil, optional) – An existing _dtfft.Pencil object to wrap. If provided, starts and counts are ignored. This parameter is intended for internal use when a Pencil object is returned by a plan method, and allows wrapping an existing C++ Pencil without copying. For user-created Pencil objects, it is more common to specify starts and counts directly.
- class dtfft.Request(handle: int, kind: str)[source]¶
Python wrapper for internal async request handle (dtfft_request_t).
- class dtfft.CompressionConfig(compression_lib: CompressionLib = CompressionLib.ZFP, compression_mode: CompressionMode = CompressionMode.LOSSLESS, rate: float = 0.0, precision: int = 0, tolerance: float = 0.0)¶
Compression configuration for transpose/reshape paths.
- Parameters:
compression_lib (CompressionLib, optional) – Compression library to use. Default is CompressionLib.ZFP.
compression_mode (CompressionMode, optional) – Compression mode to use. Default is CompressionMode.LOSSLESS.
rate (float, optional) – Target rate for fixed rate mode. Ignored for other modes. Default is 0.0.
precision (int, optional) – Target precision for fixed precision mode. Ignored for other modes. Default is 0.0.
tolerance (float, optional) – Target tolerance for fixed accuracy mode. Ignored for other modes. Default is 0.0.
Plan Classes¶
- class dtfft.Plan(plan: Plan)[source]¶
Python wrapper around a concrete dtFFT plan instance.
This class delegates most of its informational properties to the underlying C++ plan. The following properties are dynamically available via
__getattr__:Properties¶
- z_slab_enabledbool
Return whether Z-slab optimization is enabled for this plan.
- y_slab_enabledbool
Return whether Y-slab optimization is enabled for this plan.
- alloc_sizeint
Return minimum number of elements required for main buffers.
- aux_sizeint
Return auxiliary buffer size (in elements) for
execute.- aux_bytesint
Return auxiliary buffer size (in bytes) for
execute.- aux_size_reshapeint
Return auxiliary buffer size (in elements) for
reshape.- aux_bytes_reshapeint
Return auxiliary buffer size (in bytes) for
reshape.- aux_size_transposeint
Return auxiliary buffer size (in elements) for
transpose.- aux_bytes_transposeint
Return auxiliary buffer size (in bytes) for
transpose.- local_sizestuple[list[int], list[int], list[int], list[int], int]
Return local decomposition:
(in_starts, in_counts, out_starts, out_counts, alloc_size).- dimslist[int]
Return global plan dimensions in natural Fortran order.
- grid_dimslist[int]
Return MPI grid dimensions in natural Fortran order.
- element_sizeint
Return size (in bytes) of one data element for this plan.
- alloc_bytesint
Return minimum bytes required for input/output buffers.
- executorExecutor
Return executor selected for this plan.
- precisionPrecision
Return precision selected for this plan.
- backendBackend
Return communication backend selected for this plan.
- reshape_backendBackend
Return backend selected for reshape operations.
- streamcupy.cuda.Stream | cupy.cuda.ExternalStream
Return CUDA stream associated with this plan.
- platformPlatform
Return execution platform (HOST/CUDA) for this plan.
- execute(input: np.ndarray | cp.ndarray, output: np.ndarray | cp.ndarray, execute_type: Execute, aux: np.ndarray | cp.ndarray = None) None[source]¶
Execute full plan in
FORWARDorBACKWARDdirection.- Parameters:
input (np.ndarray | cp.ndarray) – Input array containing the source data (e.g., numpy.ndarray or cupy.ndarray).
output (np.ndarray | cp.ndarray) – Output array where the result will be written.
execute_type (Execute) – Direction of execution (e.g.,
Execute.FORWARDorExecute.BACKWARD).aux (np.ndarray | cp.ndarray, optional) – Optional auxiliary array for intermediate data.
- transpose(input: np.ndarray | cp.ndarray, output: np.ndarray | cp.ndarray, transpose_type: Transpose, aux: np.ndarray | cp.ndarray = None) None[source]¶
Transpose data in a single dimension (e.g., X->Y, Y->Z).
- Parameters:
input (np.ndarray | cp.ndarray) – Input array containing the source data.
output (np.ndarray | cp.ndarray) – Output array where transposed data will be written. Must be different from
input.transpose_type (Transpose) – Type of transpose operation to perform.
aux (np.ndarray | cp.ndarray, optional) – Optional auxiliary array for intermediate data.
- reshape(input: np.ndarray | cp.ndarray, output: np.ndarray | cp.ndarray, reshape_type: Reshape, aux: np.ndarray | cp.ndarray = None) None[source]¶
Reshape data between brick and pencil layouts and vice versa.
- Parameters:
input (np.ndarray | cp.ndarray) – Input array containing the source data.
output (np.ndarray | cp.ndarray) – Output array where reshaped data will be written. Must be different from
input.reshape_type (Reshape) – Type of reshape operation to perform.
aux (np.ndarray | cp.ndarray, optional) – Optional auxiliary array for intermediate data.
- transpose_start(input: np.ndarray | cp.ndarray, output: np.ndarray | cp.ndarray, transpose_type: Transpose, aux: np.ndarray | cp.ndarray = None) Request[source]¶
Start asynchronous transpose and return request handle.
- Parameters:
input (np.ndarray | cp.ndarray) – Input array containing the source data.
output (np.ndarray | cp.ndarray) – Output array where transposed data will be written. Must be different from
input.transpose_type (Transpose) – Type of transpose operation to perform.
aux (np.ndarray | cp.ndarray, optional) – Optional auxiliary array for intermediate data.
- Returns:
A handle to the asynchronous operation, which must be passed to
transpose_end.- Return type:
- transpose_end(request: Request) None[source]¶
Finalize asynchronous transpose operation.
- Parameters:
request (Request) – The operation handle previously returned by
transpose_start.
- reshape_start(input: np.ndarray | cp.ndarray, output: np.ndarray | cp.ndarray, reshape_type: Reshape, aux: np.ndarray | cp.ndarray = None) Request[source]¶
Start asynchronous reshape and return request handle.
- Parameters:
input (np.ndarray | cp.ndarray) – Input array containing the source data.
output (np.ndarray | cp.ndarray) – Output array where reshaped data will be written. Must be different from
input.reshape_type (Reshape) – Type of reshape operation to perform.
aux (np.ndarray | cp.ndarray, optional) – Optional auxiliary array for intermediate data.
- Returns:
A handle to the asynchronous operation, which must be passed to
reshape_end.- Return type:
- reshape_end(request: Request) None[source]¶
Finalize asynchronous reshape operation.
- Parameters:
request (Request) – The operation handle previously returned by
reshape_start.
- get_ndarray(size: int, shape: int | tuple[int, ...] | None = None, dtype: Any = None, order: str = 'C') np.ndarray | cp.ndarray[source]¶
Allocate an ndarray backed by plan-managed memory.
- Parameters:
size (int) – Number of elements to allocate.
shape (int | tuple[int, ...] | None, optional) – Desired array shape. Note, that product of shape might be smaller then size.
dtype (numpy.dtype | type | None, optional) – Element type. If
None, uses plan-native dtype.order (str, optional) – Memory order passed to NumPy/CuPy ndarray constructor.
- Returns:
Array view that uses dtFFT allocation and is automatically freed when no longer referenced.
- Return type:
numpy.ndarray or cupy.ndarray
- property dtype: dtype¶
- class dtfft.PlanC2C(dims_or_pencil: list[int] | ~dtfft.Pencil, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, precision: ~dtfft._dtfft.Precision = Precision.DOUBLE, effort: ~dtfft._dtfft.Effort = Effort.ESTIMATE, executor: ~dtfft._dtfft.Executor = Executor.NONE, config: ~dtfft.Config | None = None)[source]¶
Bases:
PlanCreate a complex-to-complex dtFFT plan.
- Parameters:
dims_or_pencil (list[int] | Pencil) – Global dimensions (natural Fortran order) or already prepared input
Pencil.comm (mpi4py.MPI.Comm | int, optional) – MPI communicator object or raw handle.
precision (Precision, optional) – Scalar precision used by the plan.
effort (Effort, optional) – Planning effort level.
executor (Executor, optional) – Preferred FFT executor.
config (Config | None, optional) – Optional configuration applied before plan creation.
- class dtfft.PlanR2C(dims_or_pencil: list[int] | ~dtfft.Pencil, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, precision: ~dtfft._dtfft.Precision = Precision.DOUBLE, effort: ~dtfft._dtfft.Effort = Effort.ESTIMATE, executor: ~dtfft._dtfft.Executor = Executor.NONE, config: ~dtfft.Config | None = None)[source]¶
Bases:
PlanCreate a real-to-complex dtFFT plan.
- Parameters:
dims_or_pencil (list[int] | Pencil) – Global dimensions (natural Fortran order) or already prepared input
Pencil.executor (Executor) – FFT executor for local real/complex transforms.
comm (mpi4py.MPI.Comm | int, optional) – MPI communicator object or raw handle.
precision (Precision, optional) – Scalar precision used by the plan.
effort (Effort, optional) – Planning effort level.
config (Config | None, optional) – Optional configuration applied before plan creation.
- class dtfft.PlanR2R(dims_or_pencil: list[int] | ~dtfft.Pencil, kinds: list[~dtfft._dtfft.R2RKind] | None = None, comm: ~mpi4py.MPI.Comm = <mpi4py.MPI.Intracomm object>, precision: ~dtfft._dtfft.Precision = Precision.DOUBLE, effort: ~dtfft._dtfft.Effort = Effort.ESTIMATE, executor: ~dtfft._dtfft.Executor = Executor.NONE, config: ~dtfft.Config | None = None)[source]¶
Bases:
PlanCreate a real-to-real dtFFT plan.
- Parameters:
dims_or_pencil (list[int] | Pencil) – Global dimensions (natural Fortran order) or already prepared input
Pencil.kinds (list[R2RKind] | None, optional) – Transform kinds for each transformed axis.
comm (mpi4py.MPI.Comm | int, optional) – MPI communicator object or raw handle.
precision (Precision, optional) – Scalar precision used by the plan.
effort (Effort, optional) – Planning effort level.
executor (Executor, optional) – Preferred FFT executor.
config (Config | None, optional) – Optional configuration applied before plan creation.