cuFFTDx in Tile#
The cuFFTDx Tile C++ API performs complex and real FFTs on rank-one,
rank-two, or rank-three logical signals. Include cufftdx_tile.hpp and link
mathdx_tile::cufftdx.
The equivalent Python interface is documented in FFT cutile-python API.
A complex signal is represented as a real tile with a trailing interleaved
(real, imaginary) axis of extent 2, and transforms are unnormalized in
both directions. Refer to FFT conventions. For the selection
of batches_per_block and the CTA size, refer to
Suggested FFT Configuration.
The optional match parameter controls whether suggestions are mapped
to a tuned architecture or require an exact architecture match. See
Architecture matching.
Quick start#
#include "cufftdx_tile.hpp"
namespace ct = cuda::tiles;
__tile_global__ void fft_kernel(float* input, float* output) {
using signal_shape = ct::shape<256, 2>;
auto source = ct::partition_view { ct::tensor_span { input, signal_shape {} }, signal_shape {} };
auto destination = ct::partition_view { ct::tensor_span { output, signal_shape {} }, signal_shape {} };
auto spectrum = cufftdx::tiles::fft(source.load(0, 0), cufftdx::tiles::axis<0>);
destination.store(spectrum, 0, 0);
}
void launch_fft(float* input, float* output) {
fft_kernel<<<1, 1>>>(input, output);
}
C++ API reference#
-
enum class cufftdx::tiles::transform_t#
The transform a suggested configuration is for:
fftorifft(which share rows),rfftorirfft, named as the frontend’s functions are.Values:
-
enumerator fft#
-
enumerator ifft#
-
enumerator rfft#
-
enumerator irfft#
-
enumerator fft#
-
enum class cufftdx::tiles::arch_match_t#
How
suggested_tile_configmatchessm_archagainst the tuned architectures.Values:
-
enumerator mapped_to_major_arch#
An untuned architecture gets the suggestion for the tuned one of its major.
-
enumerator exact_match#
Only suggestions tuned for exactly
sm_arch.
-
enumerator mapped_to_major_arch#
-
constexpr full_t cufftdx::tiles::full = {}#
full-spectrum layout tag.
-
template<typename TileType, int AXIS>
TileType cufftdx::tiles::fft(
)# Forward DFT of
dataalong the tagged axis, unnormalized.datais a rank-1, rank-2, or rank-3 float or double signal with a trailing interleaved (real, imaginary) extent of 2. Negative values count from the last transform dimension.- Parameters:
data – Complex signal with shape
(D0, ..., D{RANK-1}, 2).transform_axis – Logical transform dimension. Negative values count from the last transform dimension.
- Returns:
Complex spectrum with the same shape and element type as
data.
-
template<typename TileType, int AXIS>
TileType cufftdx::tiles::ifft(
)# Inverse DFT of
dataalong the tagged axis, unnormalized:ifft(fft(x))isN * x. Same operand shapes asfft.- Parameters:
data – Complex spectrum with shape
(D0, ..., D{RANK-1}, 2).transform_axis – Logical transform dimension. Negative values count from the last transform dimension.
- Returns:
Complex signal with the same shape and element type as
data.
-
template<typename TileType, int AXIS>
auto cufftdx::tiles::rfft(
)# Forward real-to-complex DFT along the tagged axis, unnormalized.
The full N-element complex spectrum is returned by appending an interleaved-pair extent of 2. N must be even.
- Parameters:
data – Real signal with shape
(D0, ..., D{RANK-1}), one to three dimensions.transform_axis – Logical transform dimension. Negative values count from the last transform dimension.
layout – Selects full-spectrum complex storage.
- Returns:
Full complex spectrum with shape
(D0, ..., D{RANK-1}, 2).
-
template<typename TileType, int AXIS>
auto cufftdx::tiles::irfft(
)# Inverse complex-to-real DFT along the tagged axis, unnormalized:
irfft(rfft(x))isN * x. The trailing complex-pair extent is removed.- Parameters:
data – Full complex spectrum with shape
(D0, ..., D{RANK-1}, 2).transform_axis – Logical transform dimension. Negative values count from the last transform dimension.
layout – Selects full-spectrum complex storage.
- Returns:
Real signal with shape
(D0, ..., D{RANK-1}).
-
template<typename T>
constexpr tile_config_t cufftdx::tiles::suggested_tile_config( - transform_t transform,
- int rank,
- int axis,
- int size,
- int sm_arch,
- arch_match_t match = arch_match_t::mapped_to_major_arch,
The suggested
batches_per_blockandnum_worker_warps_per_ctafor an FFT offloatordoubleelement typeT.Evaluated at compile time for the architecture being compiled:
constexpr auto cfg = suggested_tile_config<float>( transform_t::fft, 1, 0, N, __CUDA_ARCH__); [[cutile::hint(0, num_worker_warps_per_cta = cfg.num_worker_warps_per_cta)]] __tile_global__ void kernel(...);
- Parameters:
transform – The transform. rfft / irfft entries exist only for the contiguous axis and cover fewer sizes.
rank – Number of logical transform dimensions (1-3).
axis – Logical transform dimension. Negative values count from the last one, as fft()’s axis tag does.
size – Transform extent along
axis.sm_arch – Target SM in
__CUDA_ARCH__’s encoding, 100 * major + 10 * minor: 1000 for sm_100.match – Architecture matching policy. Tables contain measurements for sm_80, sm_90, sm_100, and sm_120. By default, another
sm_archuses the tuned architecture with the same major version. For example, sm_86 and sm_89 use sm_80. sm_121 uses sm_120. A major version without a table uses sm_100. This provides a tuning starting point, not an optimum.exact_matchsuggests configurations only for architectures with their own table.
- Returns:
foundis false for a missing key or an out-of-rangerank/axis. In that case, the other fields contain a one-batch, one-warp fallback.
-
template<int N>
struct axis_t# - #include <cufftdx_tile.hpp>
The logical transform dimension, passed as a tag argument. Negative values count from the last logical dimension, as in NumPy. For rank-1, rank-2, and rank-3 overloads, counting starts before the trailing
2dimension.
-
struct full_t#
- #include <cufftdx_tile.hpp>
The complex storage layout of a real transform, passed as a tag argument. Currently, only the full spectrum is supported. The explicit tag allows future compact layouts without silent changes to function names or result shapes.
-
struct tile_config_t#
- #include <cufftdx_tile_config.hpp>
Suggested tile configuration for an FFT of a given size, axis, rank, precision and transform.