The descriptor class template#
Instances of any oneapi::mkl::dft::descriptor class define DFT(s) to be
computed. The usage of prepended namespace specifiers oneapi::mkl::dft is
omitted below for conciseness.
Description#
Any desired DFT is fully defined by an instance of a specialization of the
descriptor class template, declared in the oneapi::mkl::dft namespace.
The scoped enumeration types precision, domain,
config_param and config_value defined in the same namespace (and the
corresponding ranges of values) are relevant to the definition and
configurations of such objects. Users can set several (resp. query all)
configuration parameters for (resp. from) any descriptor object by using
its set_value (resp. get_value) member functions.
Invoking the commit member function of a descriptor object effectively
commits it to the desired DFT calculations (as it defines it) on the specific
device encapsulated by the sycl::queue object required by that function.
The desired forward (resp. backward) DFT calculations may then be computed by
passing such a committed descriptor object to a compute_forward (resp.
compute_backward) function (defined in the oneapi::mkl::dft namespace as
well), along with the relevant data containers (sycl::buffer object(s) or
pointer(s) to a device-accessible USM allocations) for the desired DFT(s). This
function makes the descriptor object enqueue the operations relevant for the
desired calculations to the sycl::queue object it was given when committing it.
Note
The compute_forward and compute_backward functions may need to be
able to access the internals of the descriptor object to compute the
desired transform(s), this could be done for instance, by labeling them as
friend functions of the descriptor class template.
Syntax
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
class descriptor {
private:
using real_scalar_t = std::conditional_t<prec == precision::DOUBLE, double, float>;
public:
// Constructor for 1-dimensional DFT
descriptor(std::int64_t length); // d = 1;
// Constructor for d-dimensional DFT
descriptor(std::vector<std::int64_t> lengths); // d = lengths.size();
descriptor(const descriptor&);
descriptor(descriptor&&);
descriptor& operator=(const descriptor&);
descriptor& operator=(descriptor&&);
~descriptor();
void set_value(config_param param, config_value value);
void set_value(config_param param, std::int64_t value);
void set_value(config_param param, real_scalar_t value);
[[deprecated("Use set_value(config_param, const std::vector<std::int64_t>&) instead.")]]
void set_value(config_param param, const std::int64_t* value);
void set_value(config_param param, const std::vector<std::int64_t>& value);
template <typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
void set_value(config_param param, T value) {
set_value(param, static_cast<std::int64_t>(value));
}
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
void set_value(config_param param, T value) {
set_value(param, static_cast<real_scalar_t>(value));
}
[[deprecated("This set_value member function is deprecated.")]]
void set_value(config_param param, ...);
void get_value(config_param param, config_value* value_ptr) const;
void get_value(config_param param, domain* value_ptr) const;
void get_value(config_param param, precision* value_ptr) const;
void get_value(config_param param, std::int64_t* value_ptr) const;
void get_value(config_param param, real_scalar_t* value_ptr) const;
void get_value(config_param param, std::vector<std::int64_t>* value_ptr) const;
[[deprecated("This get_value member function is deprecated.")]]
void get_value(config_param param, ...) const;
void set_workspace(sycl::buffer<real_scalar_t, 1> &workspaceBuf);
void set_workspace(real_scalar_t* workspaceUSM);
void commit(sycl::queue &queue);
};
}
Template parameters
precision precSpecifies the floating-point format of the user-provided data, the results, and the precision of the floating-point operations to be enqueued. The possible specialization values are
precision::SINGLEandprecision::DOUBLE, corresponding to single-precision (FP32) and double-precision (FP64) floating-point formats, respectively . Objects of adescriptorclass specialized withprecision::SINGLE(resp.precision::DOUBLE) asprecare referred to as “single-precision descriptors” (resp. “double-precision descriptors”).domain domSpecifies the type of forward domain for the transform. The possible specialization values are
domain::COMPLEXanddomain::REAL, corresponding to complex and real forward domains, respectively. Objects of thedescriptorclass specialized withdomain::COMPLEX(resp.domain::REAL) asdomare referred to as “complex descriptors” (resp. “real descriptors”).
Member functions of the descriptor class template
Routines |
Description |
|---|---|
Create a |
|
Perform a deep copy of or moves the argument. |
|
|
Set a configuration value for a specific configuration parameter. |
|
Query the configuration value associated with a particular configuration parameter. |
|
Equips the |
|
Commits the |
Constructors#
The parameterized constructors for a descriptor object instantiate it with
all the relevant default configuration settings (which may depend on the
specialization values for prec and dom). The constructors do not perform
any significant initialization work as changes in the object’s configuration(s)
may be operated thereafter (via its set_value
member functions) and modify
significantly the nature of that work.
The copy constructor performs a deep copy of descriptor objects.
The move constructor transfers the resources owned by a descriptor object,
without copying them.
Parameterized constructor (one-dimensional transform)
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
descriptor<prec,dom>::descriptor(std::int64_t length);
}
Parameterized constructor (transform of any dimension)
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
descriptor<prec,dom>::descriptor(std::vector<std::int64_t> lengths);
}
Copy constructor
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
descriptor<prec,dom>::descriptor(const descriptor<prec,dom>& other);
}
Move constructor
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
descriptor<prec,dom>::descriptor(descriptor<prec,dom>&& other);
}
Input Parameters
lengthLength \(n_1 > 0\) of the data sequence(s) for one-dimensional transform(s).
lengthsVector of \(d > 0\) lengths \(\lbrace n_1, \ldots, n_d\rbrace\) of the data sequence(s) for \(d\)-dimensional transform(s). The values are to be provided in that order and such that \(n_j > 0,\ \forall j \in \lbrace 1, \ldots, d \rbrace\).
otherAnother
descriptorobject of the same type to copy or move.
Throws
The constructors shall throw the following exceptions if the associated condition is detected. An implementation may throw additional implementation-specific exception(s) in case of error conditions not covered here:
oneapi::mkl::host_bad_alloc()If any memory allocations on host have failed, for instance due to insufficient memory.
oneapi::mkl::unimplemented()If the dimension \(d\), i.e., the size of
lengths, is larger than what is supported by the library implementation.
Descriptor class member table: Member functions of the descriptor class template
Assignment operators#
The copy assignment operator results in a deep copy.
Copy assignment
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
descriptor<prec,dom>& descriptor<prec,dom>::operator=(const descriptor<prec,dom>& other);
}
Move assignment
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
descriptor<prec,dom>& descriptor<prec,dom>::operator=(descriptor<prec,dom>&& other);
}
Input Parameters
otherAnother
descriptorobject to copy or move from.
Throws
The assignment operators shall throw the following exception if the associated condition is detected. An implementation may throw additional implementation-specific exception(s) in case of error conditions not covered here:
oneapi::mkl::host_bad_alloc()If any memory allocations on host have failed, for instance due to insufficient memory.
Descriptor class member table: Member functions of the descriptor class template
set_value member functions#
The set_value member functions of any descriptor object set a
configuration value corresponding to a (read-write) configuration parameter for
the DFT(s) that it defines. These functions are to be used as many times as
required for all the necessary configuration parameters to be set prior to
committing the object (by calling its commit
member function).
All these functions require and expect exactly two arguments: they set the
given configuration value (second argument) for a desired configuration
parameter (first argument), represented by param of type config_param.
The expected type of the associated configuration value (second argument)
depends on param and is specified in the
section dedicated to the config_param
type and its enumerators (unless a deprecated version is used). The expected
type of configuration value determines which of the set_value overloads is
to be used for a specific value of param.
Syntax for integer-valued parameters
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::set_value(config_param param, std::int64_t value);
}
This version of set_value supports the following values of param:
config_param::NUMBER_OF_TRANSFORMS;config_param::FWD_DISTANCE;config_param::BWD_DISTANCE.
Syntax for real-valued parameters
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::set_value(config_param param, real_scalar_t value);
}
This version of set_value supports the following values of param:
config_param::FORWARD_SCALE;config_param::BACKWARD_SCALE.
Syntax for vector-valued parameters
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::set_value(config_param param, const std::vector<std::int64_t>& value);
}
This version of set_value supports the following values of param:
config_param::FWD_STRIDES;config_param::BWD_STRIDES;config_param::INPUT_STRIDES(deprecated);config_param::OUTPUT_STRIDES(deprecated).
value must be a vector of \(\left(d+1\right)\) std::int64_t elements.
More information about setting strides may be found in the page dedicated to
the configuration of data layouts.
Syntax for parameters associated with non-numeric values
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::set_value(config_param param, config_value value);
}
This version of set_value supports the following values of param:
config_param::COMPLEX_STORAGE;config_param::PLACEMENT;config_param::WORKSPACE_PLACEMENT.
Deprecated syntax for vector-valued parameters
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::set_value(config_param param, const std::int64_t* value);
}
This version of set_value supports the following values of param:
config_param::FWD_STRIDES;config_param::BWD_STRIDES;config_param::INPUT_STRIDES(deprecated);config_param::OUTPUT_STRIDES(deprecated);
and behaves as if redirecting to
set_value(param, std::vector<std::int64_t>(value, d + 1)). As a consequence,
value must be a valid pointer to \(\left(d+1\right)\) contiguous
std::int64_t elements.
This version is deprecated and it is recommended to use the alternative version recommended by the compile-time deprecation warning.
Deprecated variadic syntax
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::set_value(config_param param, ...);
}
This version supports all values of param corresponding to a writable
configuration parameter. The variadic argument list must contain a unique
element. When reading the latter (after default argument promotions of variadic
arguments, if applicable), oneMKL assumes that it is
an
std::int64_tvalue ifparamis any ofconfig_param::NUMBER_OF_TRANSFORMS,config_param::FWD_DISTANCE, orconfig_param::BWD_DISTANCE;a
doublevalue ifparamis any ofFORWARD_SCALE,BACKWARD_SCALE;a
config_valuevalue ifparamis any ofconfig_param::COMPLEX_STORAGE,config_param::PLACEMENT, orconfig_param::WORKSPACE_PLACEMENT;an
std::int64_t*value (address of the first of \(\left(d + 1\right)\) contiguousstd::int64_tvalues) ifparamis any ofconfig_param::FWD_STRIDES,config_param::BWD_STRIDES,config_param::INPUT_STRIDES, orconfig_param::OUTPUT_STRIDES.
This variadic function is deprecated; it may emit runtime deprecation warnings to inform about the recommended alternative.
Input Parameters
paramOne of the possible values of type
config_paramrepresenting the (writable) configuration parameter to be set.valueThe value to be set for the targeted configuration parameter. The type of this input argument depends on
paramas specified above....The value to be set for the targeted configuration parameter, passed as a variadic argument list of one element. This usage is deprecated. Note the type assumed by oneMKL when reading that value (specified above).
Throws
The set_value member functions shall throw the following
exceptions if the associated condition is
detected. An implementation may throw additional implementation-specific
exception(s) in case of error conditions not covered here:
oneapi::mkl::invalid_argument()If the provided
paramcorresponds to a read-only configuration parameter;If the overloaded version being used does not support
param;If the provided
paramand/or configuration value are/is not valid.
oneapi::mkl::unimplemented()If the provided
paramand configuration value are valid, but not supported by the library implementation.
Descriptor class member table: Member functions of the descriptor class template
get_value member functions#
The get_value member functions of any descriptor object query the
configuration value corresponding to a configuration parameter for the DFT that
it defines. The get_value member functions do not modify the calling object.
These functions require and expect exactly two arguments: they return the
configuration value (into the element pointed by the second argument)
corresponding to the queried configuration parameter (first argument) param
of type config_param. The second argument is a valid pointer to a
configuration value whose type corresponds to param, as specified in the
section dedicated to the config_param
type and its enumerators (unless a deprecated version is used). The expected
type of configuration value determines which of the get_value overloads is
to be used for a specific value of param.
Note
When querying the value associated with a writable configuration parameter, the returned value corresponds to the latest value that was set, even if it was set after committing the descriptor. If the value was never set explicitly, the corresponding default value is returned.
Syntax for querying the kind of forward domain
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::get_value(config_param param, domain* value_ptr) const;
}
This version of get_value supports only config_param::FORWARD_DOMAIN for
param.
Syntax for querying the considered floating-point format
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::get_value(config_param param, precision* value_ptr) const;
}
This version of get_value supports only config_param::PRECISION for
param.
Syntax for integer-valued parameters
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::get_value(config_param param, std::int64_t* value_ptr) const;
}
This version of get_value supports the following values of param:
config_param::NUMBER_OF_TRANSFORMS;config_param::FWD_DISTANCE;config_param::BWD_DISTANCE;config_param::DIMENSION;config_param::WORKSPACE_EXTERNAL_BYTES(requires the calling object to be committed);config_param::LENGTHS(deprecated usage if \(d > 1\), \(d\) contiguousstd::int64_twritten by oneMKL)config_param::INPUT_STRIDES(deprecated usage, \(\left(d+1\right)\) contiguousstd::int64_twritten by oneMKL);config_param::OUTPUT_STRIDES(deprecated usage, \(\left(d+1\right)\) contiguousstd::int64_twritten by oneMKL);config_param::FWD_STRIDES(deprecated usage, \(\left(d+1\right)\) contiguousstd::int64_twritten by oneMKL);config_param::BWD_STRIDES(deprecated usage, \(\left(d+1\right)\) contiguousstd::int64_twritten by oneMKL);
Using this version for querying configuration values encapsulating more than one
std::int64_t values is deprecated. A runtime deprecation warning may be
emitted to inform about the recommended alternative in such cases.
Syntax for real-valued parameters
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::get_value(config_param param, real_scalar_t* value_ptr) const;
}
This version of get_value supports the following values of param:
config_param::FORWARD_SCALE;config_param::BACKWARD_SCALE.
Note that real_scalar_t is defined as float (resp. double) for
single-precision (resp. double-precision) descriptors.
Syntax for vector-valued parameters
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::get_value(config_param param, std::vector<std::int64_t>* value_ptr) const;
}
This version of get_value supports the following values of param:
config_param::NUMBER_OF_TRANSFORMS(requiresvalue_ptr->size() == 1);config_param::FWD_DISTANCE(requiresvalue_ptr->size() == 1);config_param::BWD_DISTANCE(requiresvalue_ptr->size() == 1);config_param::DIMENSION(requiresvalue_ptr->size() == 1);config_param::WORKSPACE_EXTERNAL_BYTES(requiresvalue_ptr->size() == 1);config_param::LENGTHS(requiresvalue_ptr->size() == d);config_param::INPUT_STRIDES(requiresvalue_ptr->size() == d + 1);config_param::OUTPUT_STRIDES(requiresvalue_ptr->size() == d + 1);config_param::FWD_STRIDES(requiresvalue_ptr->size() == d + 1);config_param::BWD_STRIDES(requiresvalue_ptr->size() == d + 1).
Syntax for other non-numeric parameters
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::get_value(config_param param, config_value* value_ptr) const;
}
This version of get_value supports the following values of param:
config_param::COMMIT_STATUS;config_param::COMPLEX_STORAGE;config_param::PLACEMENT;config_param::WORKSPACE_PLACEMENT.
Deprecated variadic syntax
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::get_value(config_param param, ...) const;
}
This version supports all values of param. The variadic argument list must
contain a unique element. When reading the latter (after default argument
promotions of variadic arguments, if applicable), oneMKL assumes that it is of
type
domain*ifparamisconfig_param::FORWARD_DOMAIN;precision*ifparamisconfig_param::PRECISION;std::int64_t*ifparamis any ofconfig_param::NUMBER_OF_TRANSFORMS,config_param::FWD_DISTANCE,config_param::BWD_DISTANCE,config_param::DIMENSION,config_param::WORKSPACE_EXTERNAL_BYTES,config_param::LENGTHS,config_param::INPUT_STRIDES,config_param::OUTPUT_STRIDES,config_param::FWD_STRIDES, orconfig_param::BWD_STRIDES;float*(resp.double*) ifparamis any ofconfig_param::FORWARD_SCALEorconfig_param::BACKWARD_SCALE, for single-precision (resp. double-precision) descriptors;config_value*ifparamis any ofconfig::param::COMMIT_STATUS,config::param::COMPLEX_STORAGE,config::param::PLACEMENT, orconfig::param::WORKSPACE_PLACEMENT.
This variadic function is deprecated and behaves as if redirecting to the overloaded non-variadic overloaded alternative (possibly deprecated itself) that is consistent with that assumed type. It may emit runtime deprecation warnings to inform about the recommended alternative.
Input Parameters
paramOne of the possible values of type
config_paramrepresenting the configuration parameter being queried.
Output Parameters
value_ptrA valid pointer to a configuration value (or configuration values) in which oneMKL is allowed to write (return) the queried value(s). The type of this input argument depends on
paramas specified above....A valid pointer to a configuration value (or configuration values), passed as a variadic argument list of one element. This usage is deprecated. Note the type assumed by oneMKL when accessing that pointer (specified above)
Throws
The get_value member functions shall throw the following
exceptions if the associated condition is
detected. An implementation may throw additional implementation-specific
exception(s) in case of error conditions not covered here:
oneapi::mkl::invalid_argument()If the overloaded version being used does not support
param;If
value_ptrisnullptr;If
value_ptr->size()is not as expected when querying a vector-valued parameter.
oneapi::mkl::uninitializedIf
paramisconfig_param::WORKSPACE_EXTERNAL_BYTESand the calling object is not committed.oneapi::mkl::unimplemented()If the queried
paramis valid, but not supported by the library implementation.
Descriptor class member table: Member functions of the descriptor class template
set_workspace member function#
The set_workspace member function of any descriptor object sets the
workspace (possible additional memory required by the object for computation
purposes) to use when computing DFTs.
This function may only be called after the descriptor object has been
committed. The size of the provided workspace must be equal to or larger than
the required workspace size, i.e., the configuration value associated with
config_param::WORKSPACE_EXTERNAL_BYTES (queryable via the get_value
member function for integer-valued parameters).
A descriptor object where config_value::WORKSPACE_EXTERNAL is specified
for config_param::WORKSPACE_PLACEMENT is not a valid object for compute
calls until its workspace has been successfully set using this member function.
The type of workspace must match the compute calls for which it is used.
That is, if the workspace is provided as a sycl::buffer, the compute
calls must also use sycl::buffer for their arguments. Likewise, a USM
allocated workspace must only be used with USM compute calls.
Failing to do this will result in an invalid descriptor for compute calls.
If the workspace is a USM allocation, the user must not use it for other purposes
in parallel whilst the DFT compute_forward or compute_backward are in progress.
This function can be called on committed descriptors where the workspace placement
is not config_value::WORKSPACE_EXTERNAL. The provided workspace may or may not
be used in compute calls. However, the aforementioned restrictions will still apply.
Syntax (buffer workspace)
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::set_workspace(sycl::buffer<real_scalar_t, 1> &workspaceBuf);
}
Syntax (USM workspace)
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::set_workspace(real_scalar_t* workspaceUSM);
}
Input Parameters
workspaceBufA workspace buffer where
real_scalar_tis the floating-point type according toprec. This buffer must be sufficiently large or an exception will be thrown. A sub-buffer cannot be used.workspaceUSMA workspace USM allocation where
real_scalar_tis the floating-point type according toprec. This allocation must be accessible on the device on which the descriptor is committed. It is assumed that this USM allocation is sufficiently large. The pointer is expected to be aligned toreal_scalar_t.
Throws
The set_workspace member function shall throw the following
exceptions if the associated condition is
detected. An implementation may throw additional implementation-specific
exception(s) in case of error conditions not covered here:
oneapi::mkl::invalid_argument()If the provided buffer
workspaceBufis not sufficiently large or is a sub-buffer, or if the provided USM allocationworkspaceUSMisnullptrwhen an external workspace of size greater than zero is required, or if the provided USM allocationworkspaceUSMis not accessible by the device.oneapi::mkl::uninitialized()If
set_workspaceis called before the descriptor is committed.
Descriptor class member table: Member functions of the descriptor class template
commit member function#
The commit member function commits a descriptor object to the DFT
calculations it defines consistently with its configuration settings, by
completing all the initialization work (e.g., algorithm selection, algorithm
tuning, choice of factorization, memory allocations, calculation of twiddle
factors, etc.) required by the chosen implementation for the desired DFT(s) on
the targeted device. Objects of any descriptor class must be committed
prior to using them in any call to compute_forward or compute_backward
(which trigger actual DFT calculations).
As specified above, all required
configuration parameters must be set before this function is called. Any change
in configuration operated on a descriptor object via a call to its
set_value member function after it was committed results in an undefined
state not suitable for computation until this commit member function is
called again.
Syntax
namespace oneapi::mkl::dft {
template <precision prec, domain dom>
void descriptor<prec,dom>::commit(sycl::queue& queue);
}
Input Parameters
queueValid
sycl::queueobject to which the operations relevant to the desired DFT(s) are to be enqueued.
Throws
The commit member function shall throw the following
exceptions if the associated condition is
detected. An implementation may throw additional implementation-specific
exception(s) in case of error conditions not covered here (if the
descriptor object’s configuration was found to be inconsistent, for
instance):
oneapi::mkl::invalid_argument()If
queueis found to be invalid in any way.oneapi::mkl::host_bad_alloc()If any host side only memory allocations fail, for instance due to lack of memory.
oneapi::mkl::device_bad_alloc()If any device or shared memory allocation fail.
Descriptor class member table: Member functions of the descriptor class template
Parent topic: Discrete Fourier Transform Functions