Operators#
Operators are used to describe the FFT operation to solve, and to configure the execution. They are divided into Description Operators and Execution Operators.
Description Operators#
Operator |
Default value |
Description |
|---|---|---|
Not set. |
Size |
|
Not set. |
Direction of the FFT, either |
|
|
Types of input and output data (C2C, R2C, C2R). |
|
|
Precision |
|
Not set. |
Target CUDA architecure for which the FFT function should be generated. |
|
|
Complex data layout choice and execution mode for R2C/C2R FFT types |
|
|
Code type of the FFT compute device function, either |
Description operators define the FFT operation to be solved. Combined with Execution Operators, they form a complete FFT descriptor that can be executed on a GPU.
Operators are added to construct the FFT descriptor type. For example, for a forward FFT operation consisting of a FFT with 8 double elements per thread:
#include <cufftdx.hpp>
using FFT = decltype( cufftdx::Size<8>() + cufftdx::Type<fft_type::c2c>()
+ cufftdx::Direction<fft_direction::forward>()
+ cufftdx::Precision<double>() + cufftdx::Thread() );
- For an FFT descriptor to be complete, the following is required:
One, and only one, Size Operator.
One, and only one, Direction Operator unless either
cufftdx::Type<fft_type::r2c>()orcufftdx::Type<fft_type::c2r>()are added.One, and only one, SM Operator unless a Thread Operator is added.
Size Operator#
cufftdx::Size<unsigned int S>()
Sets the size S of the FFT operation to compute.
There is no default size.
Restrictions:
* S must be greater than 1.
Direction Operator#
cufftdx::Direction<cufftdx::fft_direction>()
Sets the direction of the FFT, either fft_direction::inverse or fft_direction::forward.
There is no default direction.
If the FFT is constructed with the Type<R2C> operator, direction is assumed to be forward and
a direction operator is not necessary.
If the FFT is constructed with the Type<C2R> operator, direction is assumed to be inverse and
a direction operator is not necessary.
Restrictions:
* fft_direction::forward requires Type<C2C> or Type<R2C>.
* fft_direction::inverse requires Type<C2C> or Type<C2R>.
cuFFTDx performs un-normalized FFTs; that is, performing a forward FFT on an input data set followed by an inverse FFT on the resulting set yields data that is equal to the input, scaled by the size of the FFT. Scaling either transform by the reciprocal of the size of the data set is left for the user to perform as seen fit.
Type Operator#
cufftdx::Type<cufftdx::fft_type>()
Sets the type of the FFT to compute, either fft_type::c2c for complex-to-complex; fft_type::r2c for
real-to-complex; or fft_type::c2r for complex-to-real.
The default type is fft_type::c2c.
Restrictions:
* fft_type::r2c requires fft_direction::forward. If no direction is specified, it is assumed to be fft_direction::forward.
* fft_type::c2r requires fft_direction::inverse. If no direction is specified, it is assumed to be fft_direction::inverse.
* cuFFDx performs unnormalized Fast Fourier Transform calculations.
Precision Operator#
cufftdx::Precision<__half>()
cufftdx::Precision<float>()
cufftdx::Precision<double>()
Sets the floating-point precision used to compute the FFT. This is the type of the values used for input and output, as well as the underlying type of the values used to compute the FFT.
The default precision is float.
SM Operator#
cufftdx::SM<unsigned int CC>()
Sets the target architecture CC for the underlying FFT function to use. Supported architectures are:
Turing:
750(sm_75).Ampere:
800,860and870(sm_80, sm_86, sm_87).Ada:
890(sm_89).Hopper:
900(sm_90).Blackwell:
1000,1030,1100,1200,1210(sm_100, sm_103, sm_110, sm_120, sm_121).Rubin:
1070(sm_107).
Warning
Starting with cuFFTDx 1.7.0, support for CTK 12, SM70, SM72, and SM101 is removed.
Note
When compiling for XYa or XYf compute capability use XY0 in the SM operator (see also CUDA C++ Programming Guide: Feature Availability).
Note
If the created descriptor type (that includes the SM<CC> operator) is passed to a CUDA kernel using a template parameter,
wrapping the body of the CUDA kernel in the compile-time macro CUFFTDX_SKIP_IF_NOT_APPLICABLE_SM_BLOCK(FFT) is recommended.
This practice avoids kernel compilation for unintended device architectures, thereby reducing compilation time and the final binary size.
This is only necessary if the compilation unit is compiled for multiple CUDA architectures.
#include <cufftdx.hpp>
template<typename FFT>
__global__ void user_kernel(...) {
CUFFTDX_SKIP_IF_NOT_APPLICABLE_SM_BLOCK(FFT) {
// rest of the kernel code ...
}
}
The macro expands to an if constexpr statement, so the entire kernel body must be placed inside its braces.
The older CUFFTDX_SKIP_IF_NOT_APPLICABLE_SM(FFT) macro is still available and takes a trailing semicolon instead of a block:
template<typename FFT>
__global__ void user_kernel(...) {
CUFFTDX_SKIP_IF_NOT_APPLICABLE_SM(FFT);
// rest of the kernel code ...
}
It expands to an early return, so it skips code generation but not instantiation: the statements following it are
still instantiated during the device pass of every targeted architecture. A translation unit that instantiates
descriptors for several architectures at once - for example SM<800> and SM<900> - can therefore fail to
compile on the architecture checks of the other architecture’s internals. Prefer the _BLOCK form in that case.
Warning
It is not guaranteed that executions of exactly the same FFTs on GPUs of different CUDA architectures will produce bit-identical results.
RealFFTOptions Operator#
cufftdx::RealFFTOptions<complex_layout, real_mode>()
The first argument defines the input and output data layouts for real-to-complex (fft_type::r2c) and complex-to-real
(fft_type::c2r) FFT types, which is explained in detail in Complex Element Layouts for complex inputs and outputs
and Real Element Layouts for real inputs and outputs.
Possible complex_layout values:
complex_layout::natural(default)complex_layout::packedcomplex_layout::full
The second argument, a real_mode enum value, allows to choose between optimized and non optimized execution kernel. There are two modes: normal (default), and optimized, which is called folded. The optimized execution is an opt-in, as it changes how the data is partitioned between threads in block execution.
Possible real_mode values:
real_mode::normal(default)real_mode::folded
real_mode::folded is available only for real-to-complex and complex-to-real FFTs, and has the following restrictions:
Thread execution: the size must be even.
Block execution: the size must be a power of two and at least 4, and ElementsPerThread cannot exceed the size. The FFT is computed as a complex-to-complex FFT of half the size, so each thread processes
ElementsPerThread / 2complex elements (see FFT::effective_elements_per_thread), and that value must be an available elements per thread for the half-size FFT. As a result,ElementsPerThreadof 1 or 2 is never available withreal_mode::folded, and larger sizes need larger minimum values (for example, a FP32 FFT of size 8192 needsElementsPerThreadof at least 8, while sizes up to 1024 accept 4). WhenElementsPerThreadis not set, cuFFTDx selects a valid value.
An unsupported combination fails to compile with the message “This FFT configuration is not supported”. To find the available values for a given description at runtime, see Runtime Database Query.
All traits necessary for correct I/O are shared by the topmost FFT type. Please refer to examples (e.g. simple_fft_block_r2c
and simple_fft_block_c2r) for a direct showcase of proper idioms.
CodeType Operator#
cufftdx::experimental::CodeType<cufftdx::experimental::code_type>()
Sets the type of code to use for kernel generation. Available options are:
experimental::code_type::ptx(default) - Use inlined-PTX implementation of the FFT compute device functions.experimental::code_type::ltoir- If available, use LTOIR implementation of the FFT compute device functions.
The default code type is experimental::code_type::ptx.
Note
If experimental::code_type::ltoir code type is specified but not available, cuFFTDx will fall back to using inlined-PTX implementation.
On the other hand, if experimental::code_type::ptx code type is specified, cuFFTDx will not use LTOIR implementation even if it is available.
Execution Operators#
Operator |
Default value |
Description |
|---|---|---|
Not set. |
Creates FFT thread execution object. |
|
Not set. |
Creates FFT block execution object. See Block Configuration Operators. |
Execution operators configure how the FFT operation will run on the GPU. Combined with Description Operators, they form a complete FFT descriptor that can be executed on a GPU.
Operators are added to construct the FFT descriptor type. For example, for a forward FFT operation consisting of two FFTs with 128 float elements each, running simultaneously in one CUDA block:
#include <cufftdx.hpp>
using FFT = decltype( cufftdx::Size<128>() + cufftdx::Type<fft_type::c2c>()
+ cufftdx::Direction<fft_direction::forward>()
+ cufftdx::Precision<float>() + cufftdx::Block()
+ cufftdx::ElementsPerThread<8>() + cufftdx::FFTsPerBlock<2>() );
Thread Operator#
cufftdx::Thread()
Sets the FFT operation to run in a thread context. The FFT operation will simultaneously run a single, independent FFT (described using Description Operators) per thread.
Each thread will compute one FFT of the size defined by the Size Operator.
Restrictions:
* Is mutually exclusive with Block operator
* Compilation will fail when used with block-only operators: FFTsPerBlock, ElementsPerThread, BlockDim, and the Transposition operator (including transposition::any).
* Is mutually exclusive with the ThreadLayout operator.
* With Precision<__half> restricts Size to range \([2, 32]\).
* With Precision<float> restricts Size to range \([2, 32]\).
* With Precision<double> restricts Size to range \([2, 16]\).
Block Operator#
cufftdx::Block()
Generates a collective FFT operation to run in a single CUDA block. One or more threads will cooperate to compute the collective FFT operation.
The number of FFTs to compute, as well as the number of threads used to calculate each FFT, can be configured using Block Configuration Operators.
Restrictions:
* Is mutually exclusive with Thread operator
* Unless a BlockDim Operator is used, the collective FFT operation can only be executed
inside a 2D block of sizes:
blockDim.x = size_of<Description>::value/Description::elements_per_thread.
blockDim.y = Description::ffts_per_block/Description::implicit_type_batching.
blockDim.z = 1.This is the default for
thread_layout::regular; see FFT::block_dim for the other thread layouts and forThreadLinearization.
Operator
cufftdx::Precision<__half>()restrictscufftdx::Size<U>()to range \([2, 32768]\).Operator
cufftdx::Precision<float>()restrictscufftdx::Size<U>()to range \([2, 32768]\).Operator
cufftdx::Precision<double>()restrictscufftdx::Size<U>()to range \([2, 16384]\).
Block Configuration Operators#
Operators |
Default value |
Description |
|---|---|---|
1 |
Number |
|
Heuristic. |
Number |
|
|
Required for executing block FFT within block with custom dimensions. |
|
|
Configures the FFT execution to use dynamic batching. |
|
|
Selects the shared-memory layout used internally by the block execution implementation. |
|
|
Selects the thread-to-data mapping used during block execution. |
|
Disabled. |
Maps the thread block to a linear thread index when computing the FFT. |
Block-configuration operators allow the user to tune how the collective FFT operation will run on a single CUDA block. When no block-configuration operators are used, the FFT execution will use the default block dimensions.
Note
Block configuration operators can only be used with Block Operator.
Warning
It is not guaranteed that executions of the same FFTs (size, direction, type, precision) but with different
number of elements per thread (ElementsPerThread),
number of FFTs calculated per CUDA block (FFTsPerBlock), or
block dimension (BlockDim),
will produce bit-identical results.
FFTs Per Block Operator#
cufftdx::FFTsPerBlock<unsigned int>()
Sets the number of FFT to compute in parallel within a single CUDA block. Each FFT is computed concurrently by a separate group of threads.
The default is one FFT per block.
Elements Per Thread Operator#
cufftdx::ElementsPerThread<unsigned int>()
Sets the number of FFT elements to be computed by each thread.
The default is determined heuristically to target performance.
Restrictions:
If
FFT::requires_workspaceisfalse, it must be a divisor of the requested FFT size.If
FFT::requires_workspaceistrue, it must be a power of two smaller than the size of the FFT.Must be in range \([2; 32]\) for
cufftdx::Precision<float>()andcufftdx::Precision<__half>().Must be in range \([2; 16]\) for
cufftdx::Precision<double>().
BlockDim Operator#
struct cufftdx::BlockDim<unsigned int X, unsigned int Y = 1, unsigned int Z = 1>()
Note
BlockDim operator is not officially supported with CUDA Toolkit 13.1.0 (NVCC 13.1.80) and earlier. If you are using cuFFTDx with a previous version of nvcc, and you want to use the BlockDim operator, you can:
Define the
CUFFTDX_IGNORE_BLOCK_DIM_UNSUPPORTEDmacro to ignore these assertions and use the BlockDim operator.Add the -Xptxas -O1 flag to the compilation command and verify correctness of the results every time.
From version 1.6.0 onwards it is possible to set the CUDA block size to (X, Y, Z), to configure the FFT execution.
Y and Z default to 1, so BlockDim<X> and BlockDim<X, Y> are valid shorthand for BlockDim<X, 1, 1> and
BlockDim<X, Y, 1>.
Using this operator, the user can adapt the FFT execution to use custom block dimensions.
The default block dimensions for an FFT are:
blockDim.x = size_of<Description>::value/Description::elements_per_thread.blockDim.y = Description::ffts_per_block/Description::implicit_type_batching.blockDim.z = 1.
These are the dimensions for the default thread_layout::regular; with thread_layout::transposed the x and y dimensions are swapped, and with
ThreadLinearization the default is (stride * bpb, 1, 1). See FFT::block_dim.
The use of this operator does not guarantee that the FFT execute will make use of the full block dimensions but it ensures a correct execution of the FFT when the kernel is launched with the specified block dimensions.
When setting custom block dimensions with BlockDim<X, Y, Z> certain restrictions apply:
X must be larger or equal than
size_of<Description>::value/Description::elements_per_thread.Y must be larger or equal than
Description::ffts_per_block/Description::implicit_type_batching. (These two rules are forthread_layout::regular; withthread_layout::transposedthe roles of X and Y are swapped, and withThreadLinearizationonly the productX * Y * Zmust be at leastFFT::stride * Description::ffts_per_block/Description::implicit_type_batching.)Runtime block dimensions must be equal to those set in the
BlockDimoperator. Launching with other dimensions is not guaranteed to be detected and can result in out-of-bounds shared memory accesses or wrong results.experimental::CodeTypeoperator must be set toexperimental::code_type::ptxor if usingexperimental::code_type::ltoir, the LTO database must be generated with cuFFT version 12.3 or later (from CUDA Toolkit 13.3).
Examples
Size<128>, ElementsPerThread<8>, FFTsPerBlock<1>, BlockDim<64> - OKSize<128>, ElementsPerThread<8>, FFTsPerBlock<1>, BlockDim<8> - INCORRECT, 8 is less than size_of<Description>::value/Description::elements_per_thread (16)Size<128>, ElementsPerThread<8>, FFTsPerBlock<6>, BlockDim<64, 2, 1> - INCORRECT, 2 is less than Description::ffts_per_block (6)Size<128>, ElementsPerThread<8>, FFTsPerBlock<6>, Precision<__half>, BlockDim<64, 3, 1> - OK, due to implicit batching caused by the use of __half precision.If only BlockDim<X, Y, Z> is provided, the FFT execution will be configured to use the best possible elements_per_thread and ffts_per_block that fit the block dimension. For example,
for an FFT Size<128>, Precision<float> and BlockDim<32,4,1>, the FFT execution will be configured to use the best elements per thread that makes 32 >= size_of<Description>::value / elements_per_thread.
For the case of ffts_per_block, the best value will be 4.
These values can be overridden by adding the ElementsPerThread and FFTsPerBlock operators.
Since not all threads will participate equally in the FFT execution, we provide a new trait to properly handle input output for the participating threads. Check the ::Working group<working-group-trait-label> for more information.
See FFT::block_dim.
Dynamic Batching#
cufftdx::experimental::DynamicBatching()
When added to the description, the FFT execution will be configured to use dynamic batching.
When the FFT execution is configured to use dynamic batching, the number of FFTs per block is not fixed and can be set at runtime depending on the y dimension of the runtime block. The DynamicBatching operator is not compatible with the BlockDim Operator operator or the FFTs Per Block Operator operator.
Examples
Size<128>, ElementsPerThread<8>, DynamicBatching, runtime block dimensions (16, 8, 1) - Executed FFTs per block: 8Size<128>, ElementsPerThread<8>, runtime block dimensions (16, 1, 1) - Executed FFTs per block: 1Note
The dynamic batching operator is experimental and may be changed or removed in future releases.
Warning
When using the DynamicBatching operator, the number of FFTs per block is not fixed at compile time. The user must allocate sufficient shared memory based on the actual number of FFTs to be computed.
To compute the required shared memory:
Use the helper function get_shared_memory_size_for_dynamic_batching, or
Manually calculate:
total_shared_memory = FFT::shared_memory_size * ((ffts_per_block + FFT::implicit_type_batching - 1) / FFT::implicit_type_batching)
where ffts_per_block is the runtime number of FFTs you intend to compute per block. The division rounds
up to a whole number of batches, matching the helper function. For example, with half precision
(FFT::implicit_type_batching == 2), three FFTs require two batches of shared memory.
This is the scratch space needed by the register-input overloads #1 and #2 of Block Execute Method.
The shared-memory overloads #3 and #4 additionally need room for all input and output values, so allocate at least
the maximum of this value, ffts_per_block * <FFT_input_size_in_bytes> and ffts_per_block * <FFT_output_size_in_bytes>.
Which of the three is largest depends on the selected Transposition layout.
Warning
Without ThreadLinearization, only the dimension that selects the FFT batch can be dynamic: y for thread_layout::regular and x for thread_layout::transposed. The other runtime block dimensions must coincide with the FFT::block_dim trait dimensions obtained from the execution (in particular, the dimension that selects a thread within an FFT must equal FFT::stride) in order to ensure correct results.
With ThreadLinearization, all dimensions of the runtime block can be dynamic. The product of the runtime block dimensions must be a multiple of FFT::stride in order to ensure correct results.
Thread Linearization#
cufftdx::experimental::ThreadLinearization()
When added to the description, the FFT execution will be configured to use thread linearization.
When the FFT execution is configured to use thread linearization, the thread mapping used to evaluate the FFT is changed. Without thread linearization, computing multiple FFT batches requires thread block dimensions with the following condition enforced:
blockDim.x >= FFT::stride.blockDim.y >= Description::ffts_per_block/Description::implicit_type_batching.
With thread linearization this is no longer the case. Instead, all 3 dimensions of the thread block are mapped to a linear index and the FFT id and batch id are computed from this linear index as follows:
batchid = linear_tid / FFT::stride(index of the FFT being processed among the batched FFTs)fftid = linear_tid % FFT::stride(local work index within that FFT)
where linear_tid = threadIdx.x + blockDim.x * (threadIdx.y + blockDim.y * threadIdx.z). This is the mapping for
thread_layout::regular; with thread_layout::transposed the roles are swapped
(batchid = linear_tid % bpb and fftid = linear_tid / bpb, where bpb is the number of FFTs per block,
Description::ffts_per_block/Description::implicit_type_batching). The resulting values are available through
FFT::working_group.
the only restriction on the BlockDim operator is the following:
blockDim.x * blockDim.y * blockDim.z >= (FFT::stride) * (Description::ffts_per_block/Description::implicit_type_batching)
The kernel must be launched with exactly the dimensions set in the BlockDim operator or, when no BlockDim operator is used, with FFT::block_dim
((FFT::stride * bpb, 1, 1)).
Restrictions:
With
experimental::DynamicBatchingrestricts BlockDim product to be divisible byFFT::stride.Available on both the inlined-PTX and LTO (
experimental::CodeType<experimental::code_type::ltoir>) code paths. On the LTO path, the LTO database must have been generated with cuFFT 12.5 or later (cuFFT Device API 0.6.0 or later); with a database generated by an older cuFFT, compilation fails and asks to regenerate the database, it does not fall back to PTX.
Examples
Size<128>, ElementsPerThread<8>, ThreadLinearization, runtime block dimensions (16, 1, 1) - Executed FFTs per block: default value (see FFTs Per Block Operator)Size<128>, ElementsPerThread<8>, ThreadLinearization, FFTsPerBlock<6>, runtime block dimensions (96, 1, 1) - Executed FFTs per block: 6Size<128>, ElementsPerThread<8>, ThreadLinearization, DynamicBatching, runtime block dimensions (8, 4, 4) - Executed FFTs per block: 8Size<128>, ElementsPerThread<8>, ThreadLinearization, BlockDim<1, 4, 4> - Executed FFTs per block: 1Note
The thread linearization operator is experimental and may be changed or removed in future releases.
Transposition#
cufftdx::experimental::Transposition<cufftdx::experimental::transposition>()
When added to the description, selects the layout of the shared-memory scratch space the block execution
implementation uses internally to redistribute data between registers during the FFT computation. It does not
change the format of the shared_memory/shared_memory_input buffer the caller provides: that stays in the
documented data layout order regardless of the value chosen.
Available values:
transposition::any(default) - let cuFFTDx pick any available layout.transposition::none- no shared-memory transposition.transposition::by_component- real and imaginary components are transposed separately. Needs the least shared memory of the transposing layouts; recommended when shared memory is the limiting resource (for example, to fit more FFTs per block or more blocks per SM).transposition::by_component_padded-by_componentlayout with additional padding to avoid shared-memory bank conflicts. Trades part of the shared-memory saving ofby_componentfor fewer bank conflicts; recommended when additional shared memory is available and bank conflicts limit performance. Available only for the cuFFTDx implementations compiled withptxas; it is not available for LTOIR code from the cuFFT Device API.transposition::by_complex- whole complex elements are transposed. Needs more shared memory thanby_componentbut executes fewer instructions; recommended when shared memory is not a constraint.
In general, by_component minimizes the shared-memory footprint, by_complex minimizes the instruction count, and
by_component_padded minimizes bank conflicts at a modest shared-memory cost. The optimal choice depends on the FFT
size and the target architecture, so it is recommended to benchmark the candidates or to use any (the default).
Each value selects a different compiled implementation with its own FFT::shared_memory_size requirement (none uses no scratch shared memory; by_component uses one
component array; by_component_padded adds bank-conflict padding on top of that; by_complex uses twice as
much). Choosing a value other than any can therefore change the amount of shared memory the kernel needs.
Restrictions:
Available only with
Blockexecution. Using it withThread()is a compile-time error, includingtransposition::anyandtransposition::none.Not every layout is available for every size, precision, architecture and
ElementsPerThread. Requesting an unavailable layout fails to compile with “This FFT configuration is not supported”; cuFFTDx does not fall back to another layout. Usetransposition::anyto let cuFFTDx choose, or query the available layouts at runtime with get_all_implementations and itstrpargument. For example, on SM80:transposition::nonerequiresElementsPerThreadequal toSize(the value used whenElementsPerThreadis not set), so it is available only for small sizes (up to 64 in FP32 and up to 32 in FP64).transposition::by_component_paddedis available only for power-of-two sizes greater than 32 (sizes 32 and 96, for example, are not supported).transposition::by_complexis not available for the largest size of each precision (FP32 size 32768 and FP64 size 16384).transposition::by_componentis not available for some sizes (for example FP32 size 48, while FP64 size 48 is available).
transposition::by_component_paddedis not yet supported on the LTO execution path (the cuFFT Device API does not provide it yet).Requesting a value other than
transposition::anythrough the online cuFFT Device API query helpers requires a cuFFT runtime 12.5 or later (cuFFT Device API 0.6.0). On an older runtime the helpers do not raise an error, but behave differently: query_database andget_all_implementationswithquery_code_type::ltoir_onlinefall back to PTX implementations that use the requested layout (checkcode); get_database_and_ltoir returns an empty database and no LTOIR, with the traits of that PTX implementation; and query_all_cufft_implementations returns an empty vector.With the default PTX code, or with an offline LTO database,
Transpositionhas no cuFFT version requirement.
Note
The transposition operator is experimental and may be changed or removed in future releases.
Thread Layout#
cufftdx::experimental::ThreadLayout<cufftdx::experimental::thread_layout>()
When added to the description, selects the thread-to-data mapping used during block execution:
thread_layout::regular(default) -threadIdx.xselects a thread’s position within an FFT andthreadIdx.yselects the FFT batch, matching the defaultBlockDimmapping.thread_layout::transposed- the mapping is swapped:threadIdx.xselects the FFT batch andthreadIdx.yselects a thread’s position within an FFT.
Without ThreadLinearization, this places the following requirements on the
values of the BlockDim operator (the kernel must then be launched with exactly those dimensions, or with FFT::block_dim
when no BlockDim operator is used), where FFT::stride is the number of threads cooperating on one FFT and bpb is the number of FFTs per block
(Description::ffts_per_block/Description::implicit_type_batching):
thread_layout::regular:blockDim.x >= FFT::strideandblockDim.y >= bpb.thread_layout::transposed:blockDim.x >= bpbandblockDim.y >= FFT::stride.
With ThreadLinearization, the thread index is first linearized as
linear_tid = threadIdx.x + blockDim.x * (threadIdx.y + blockDim.y * threadIdx.z), and then:
thread_layout::regular:batchid = linear_tid / FFT::stride,fftid = linear_tid % FFT::stride.thread_layout::transposed:batchid = linear_tid % bpb,fftid = linear_tid / bpb.
In all cases, the values a thread should use are returned by FFT::working_group.
ThreadLayout only changes thread ownership of data; it does not affect the layout of data in global memory, so
loading/storing code that addresses data in batch-major order is unaffected by the operator. ThreadLayout and
Transposition are independent operators and are commonly combined.
Restrictions:
thread_layout::transposedis not supported with LTO code (the cuFFT Device API does not support it); using it together withexperimental::code_type::ltoiris a compile-time error only when an LTO implementation is selected for the description. When no LTO implementation is available, cuFFTDx uses PTX and the build succeeds, so adding an LTO database later can turn a working build into a compile-time error (check FFT::code). The runtime query helpers report no implementation for it in the LTO query modes. Useexperimental::code_type::ptxinstead.thread_layout::regularworks with both.
Note
The thread layout operator is experimental and may be changed or removed in future releases.