Discrete Fourier Transform Functions#
oneMKL provides a DPC++ interface to \(d\)-dimensional \(\left(d \in \mathbb{Z}_{>0}\right)\) Discrete Fourier Transforms (DFTs).
Definitions#
Let \(w^{m}_{k_1, k_2, \ldots, k_d}\) be the entry of multi-index \(\left(k_1, k_2, \ldots, k_d\right) \in \mathbb{Z}^d\) in the \(m\)-th sequence of a set \(w\) of \(M\) \(d\)-dimensional periodic discrete sequences of period(s) (or “length(s)”) \(n_1 \times n_2 \times \dots \times n_d\) (\(M \in \mathbb{Z}_{>0}\), \(m \in \lbrace 0, 1, \ldots, M-1\rbrace\) and \(n_{\ell} \in \mathbb{Z}_{>0}, \forall \ell \in \lbrace 1, \ldots, d \rbrace\)).
For every \(m \in \lbrace 0, 1, \ldots, M - 1 \rbrace\), the DFT of sequence \(w^{m}\) is the \(d\)-dimensional \(n_1 \times n_2 \times \dots \times n_d\) periodic discrete sequence \(z^{m}\) whose entries are defined as
where \(\imath^2 = -1\) and \(\sigma\) is a scale factor. In (1), \(\delta\) determines one of the two “directions” of the DFT: \(\delta=-1\) defines the “forward DFT” while \(\delta=+1\) defines the “backward DFT”.
The domain of input (resp. output) discrete sequences for a forward (resp. backward) DFT is referred to as “forward domain”. Conversely, the domain of output (resp. input) discrete sequences for forward (resp. backward) DFT is referred to as “backward domain”.
oneMKL supports single-precision (fp32) and double-precision (fp64) floating-point arithmetic for the calculation of DFTs, using two types of forward domains:
the set of complex \(d\)-dimensional periodic sequences, referred to as “complex forward domain”;
the set of real \(d\)-dimensional periodic sequences, referred to as “real forward domain”.
Similarly, we refer to DFTs of complex (resp. real) forward domain as “complex DFTs” (resp. “real DFTs”). Regardless of the type of forward domain, the backward domain’s data sequences are always complex.
The calculation of the same DFT for several, i.e., \(M > 1\), data sets of the same type of forward domain, using the same precision is referred to as a “batched DFT”.
Finite range of indices#
In general, given the periodicity of the discrete data considered in any DFT, ranges of indices \(\left(k_1, \ldots, k_d\right) \in \mathbb{Z}^{d}\) such that \(0\leq k_{\ell} < n_{\ell}, \forall \ell \in \lbrace 1, \ldots, d \rbrace\) suffice to determine any relevant \(d\)-dimensional sequence unambiguously (for any valid \(m\)). In case of real DFTs, the data sequences in backward domain can be fully determined from a smaller range of indices. Indeed, if all entries of \(w\) are real in (1), then the entries of \(z\) are complex and, for any valid \(m\), \(\left(z^{m}_{k_1, k_2, \dots, k_d}\right)^{*} = z^{m}_{n_1 - k_1, n_2 - k_2, \dots, n_d - k_d}\) \(\forall \left(k_1, k_2, \ldots, k_d\right) \in \mathbb{Z}^{d}\) where \(\lambda^{*}\) represents the conjugate of complex number \(\lambda\). This conjugate symmetry relation makes roughly half the data redundant in backward domain: in case of real DFTs, the data sequences in backward domain can be fully determined even if one of the \(d\) indices \(k_{\ell}\) is limited to the range \(0\leq k_{\ell} \leq \lfloor \frac{n_{\ell}}{2}\rfloor\). In oneMKL, the index \(k_d\), i.e., the last dimension’s index, is restricted as such for capturing an elementary set of non-redundant entries of data sequences belonging to the backward domain of real DFTs.
Elementary range of indices#
In other words, oneMKL expects and produces a set of \(M\) \(d\)-dimensional finite data sequences \(\left(\cdot \right)^{m}_{k_1, k_2,\ldots, k_d}\) with integer indices \(m\) and \(k_{\ell}\ \left(\ell \in \lbrace 1, \ldots, d \rbrace\right)\) in the elementary range
\(0 \leq m < M\);
\(0 \leq k_j < n_j,\ \forall j \in \lbrace1, \ldots, d - 1\rbrace\), if \(d > 1\);
\(0 \leq k_d < n_d\), except for backward domain’s data sequences of real DFTs;
\(0 \leq k_d \leq \lfloor\frac{n_d}{2}\rfloor\), for backward domain’s data sequences of real DFTs.
Additional constraints for data in backward domain of real DFTs#
Finally, note that the conjugate symmetry relation further constrains some of the entries (or pairs thereof) in the backward domain’s data sequences for real DFTs. Specifically, for any of the \(M\) sequences,
the imaginary part must be \(0\) for any entry of multi-index \(\left(k_1, k_2, \ldots, k_d\right)\) such that \(k_{\ell} \equiv \left(n_{\ell} - k_{\ell}\right) \pmod {n_{\ell}}, \forall \ell \in \lbrace{1, \ldots, d\rbrace}\), e.g., entry of multi-index \(\left(0, 0, \ldots, 0\right)\);
pairs of entries of multi-indices \(\left(k_1, k_2, \ldots, k_d\right)\) and \(\left(j_1, j_2, \ldots, j_d\right)\) such that \(k_{\ell} \equiv \left(n_{\ell} - j_{\ell}\right) \pmod {n_{\ell}}, \forall \ell \in \lbrace{1, \ldots, d\rbrace}\) must be complex conjugates of one another, e.g., entries of multi-indices \(\left(1, 0, \ldots, 0\right)\) and \(\left(n_1 - 1, 0, \ldots, 0\right)\) must be complex conjugates (note that this case falls back to the above constraint if \(n_1 = 2\)).
Note
The behavior of oneMKL is undefined for real backward DFT if the input data does not satisfy those constraints. oneMKL considers it the user’s responsibility to guarantee that these constraints are satisfied by the input data for real backward DFTs.
Recommended usage#
The desired (batched) DFT to be computed is entirely defined by an object
desc
of the descriptor class. The desired type
of forward domain and precision are determined at desc
’s construction time
by the specialization values chosen for the self-explanatory template parameters
prec
(of type precision) and dom
(of type
domain), respectively. The transform size
\(n_1 \times n_2 \times \dots \times n_d\) is also set at construction time
as a required argument to the class constructor. Other configuration details for
the (batched) DFT under consideration may be specified by invoking the
set_value member function of desc
for every
relevant configuration setting (e.g., the number \(M\) of sequences to
consider in case of a batched DFT). Once configured as desired, the
commit member function of desc
, requiring a
sycl::queue
object Q
, may be invoked. The successful completion of the
latter makes desc
committed to the desired (batched) DFT as configured, for
the particular device and context encapsulated by Q
. The
compute_forward (resp. compute_backward)
function may then be called and provided with desc
to enqueue operations
relevant to the desired forward (resp. backward) DFT calculations with
user-provided, device-accessible data.
Note
Objects of the descriptor class
must be successfully committed prior to providing them to any compute function;
must be re-committed to account for any change in configuration after it was already successfully committed;
deliver best performance for DFT calculations when created, configured and committed outside applications’ hotpath(s) that use them multiple times for identically-configured (batched) DFTs. compute_forward and/or compute_backward should be the only oneMKL DFT-related routines invoked in programs’ hotpaths.
Summary table#
The table below summarizes the object and functions relevant to computing DFTs
(all defined in the oneapi::mkl::dft
namespace).
Routines and Objects |
Description |
---|---|
A class whose instances define a specific (batched) DFT(s) to be calculated. |
|
A member function of the descriptor class to set (writable) configuration parameters for an instance of that class. |
|
A member function of the descriptor class to query configuration parameters from any instance of that class. |
|
A member function of the descriptor class to commit an instance of that class to the (batched) DFT calculations it defines, on a given queue. |
|
A function requiring a successfully-committed object of the descriptor class to compute a forward (batched) DFT, as defined by that object. |
|
A function requiring a successfully-committed object of the descriptor class to compute a backward (batched) DFT, as defined by that object. |
Parent topic: oneMKL Domains