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\) be a set of \(M\) finite \(d\)-dimensional discrete sequences \(w^{m}\) of length(s) \(n_1 \times n_2 \times \dots \times n_d\) (\(d \in \mathbb{Z}_{>0}\), \(M \in \mathbb{Z}_{>0}\), \(n_{\ell} \in \mathbb{Z}_{>0}\ \forall \ell \in \lbrace 1, 2, \ldots, d \rbrace\), and \(m \in \lbrace 0, 1, \ldots, M-1\rbrace\)). 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 \(w^{m}\) wherein integer indices \(k_{\ell}\) are such that \(0 \leq k_{\ell} < n_{\ell},\ \forall \ell \in \lbrace 1, 2, \ldots, d \rbrace\).
For every \(m \in \lbrace 0, 1, \ldots, M - 1 \rbrace\), the DFT of sequence \(w^{m}\) is the \(d\)-dimensional discrete sequence \(z^{m}\) of length(s) \(n_1 \times n_2 \times \dots \times n_d\) whose entries are defined as
where \(\imath^2 = -1\). 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”. \(\sigma_{\delta}\) is a (real) scaling factor associated with either operation.
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 kinds of forward domains:
the set of complex \(d\)-dimensional discrete sequences, referred to as “complex forward domain”;
the set of real \(d\)-dimensional discrete 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 kind 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 kind of forward domain, using the same precision is referred to as a “batched DFT”.
Elementary range of indices#
In general, all entries of multi-indices \(\left(k_1, \ldots, k_d\right)\) such that \(0\leq k_{\ell} < n_{\ell}, \forall \ell \in \lbrace 1, \ldots, d \rbrace\) unambiguously 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}_{j_{1}, j_{2}, \dots, j_{d}}\) where \(j_{\ell} = \left(n_{\ell} - k_{\ell}\right) \pmod {n_{\ell}}, \ \forall \ell \in \lbrace 1, \ldots, d \rbrace\) and \(\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 to capture an elementary set of non-redundant entries for data sequences belonging to the backward domain of real DFTs.
In other words, oneMKL expects and produces a set of \(M\) \(d\)-dimensional 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 DFT to be computed is entirely defined by an object desc
of a
specialization of the oneapi::mkl::dft::descriptor
class template.
The desired floating-point format and kind of forward domain are determined by
desc
’s particular class, i.e., by the specialization values of the
template parameters prec
and dom
of the descriptor
class template, respectively. Once desc
is
created, the length(s) \(\lbrace n_1, n_2, \ldots, n_d\rbrace\) (and the
dimension \(d\)) cannot be changed, as they are read-only parameters. Other
configuration details for the DFT under consideration may be specified by
invoking the appropriate
configuration-setting member function(s)
of desc
for every relevant configuration parameter (e.g., the number
\(M\) of sequences to consider in case of a batched DFT). Once configured
as desired, desc
must be initialized for computation by using its
committing member function, which requires
a sycl::queue
object. The successful completion of that operation makes
desc
ready to compute the desired DFT as configured, for the particular
device and context encapsulated by the latter. desc
may then be used with
user-provided, device-accessible data, in a
oneapi::mkl::dft::compute_forward
(resp.
oneapi::mkl::dft::compute_backward
) function to enqueue operations relevant
to the desired forward (resp. backward) DFT calculations.
Note
Objects of any oneapi::mkl::dft::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 operated after they were 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 DFTs.
oneapi::mkl::dft::compute_forward
and/oroneapi::mkl::dft::compute_backward
should be the only oneMKL DFT-related routines invoked in programs’ hotpaths.
Summary table#
The table below summarizes the identifiers of the oneapi::mkl::dft
namespace
relevant to computing DFTs.
Identifier in |
Description |
---|---|
|
A template for classes whose instances define a specific DFT to be calculated and its configuration. Template parameters are omitted in this table for conciseness (more details are available in the page dedicated to the descriptor class template). |
|
Scoped enumerations pertaining to the
definition of any configuration parameter or its associated
value, for any instance of a |
|
Member functions to
set (writable) configuration parameters
for any instance of a |
|
Member functions to
query configuration parameters
from any instance of a |
|
A member function to
commit any instance
of a |
|
A member function to equip any instance of a |
|
Function templates for computing a forward DFT, as defined by
a (successfully-committed) instance of a |
|
Function templates for computing a backward DFT, as defined by
a (successfully-committed) instance of a |
Parent topic: oneMKL Domains