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: fft or ifft (which share rows), rfft or irfft, named as the frontend’s functions are.

Values:

enumerator fft#
enumerator ifft#
enumerator rfft#
enumerator irfft#
enum class cufftdx::tiles::arch_match_t#

How suggested_tile_config matches sm_arch against 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.

template<int N>
constexpr axis_t<N> cufftdx::tiles::axis = {}#

transform-axis tag.

constexpr full_t cufftdx::tiles::full = {}#

full-spectrum layout tag.

template<typename TileType, int AXIS>
TileType cufftdx::tiles::fft(
TileType data,
[[maybe_unused]] axis_t<AXIS> transform_axis,
)#

Forward DFT of data along the tagged axis, unnormalized.

data is 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(
TileType data,
[[maybe_unused]] axis_t<AXIS> transform_axis,
)#

Inverse DFT of data along the tagged axis, unnormalized: ifft(fft(x)) is N * x. Same operand shapes as fft.

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(
TileType data,
[[maybe_unused]] axis_t<AXIS> transform_axis,
[[maybe_unused]] full_t layout,
)#

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(
TileType data,
[[maybe_unused]] axis_t<AXIS> transform_axis,
[[maybe_unused]] full_t layout,
)#

Inverse complex-to-real DFT along the tagged axis, unnormalized: irfft(rfft(x)) is N * 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_block and num_worker_warps_per_cta for an FFT of float or double element type T.

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_arch uses 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_match suggests configurations only for architectures with their own table.

Returns:

found is false for a missing key or an out-of-range rank/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 2 dimension.

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.

Public Members

const bool found#

False when the key has no suggested entry.

const int batches_per_block#

Transforms per block: the tile’s batch extent.

const int num_worker_warps_per_cta#

The value for [[cutile::hint(0, num_worker_warps_per_cta = ...)]].