SYCL Kernels API#
Supported C++ Standard Library APIs and Algorithms#
oneDPL defines a subset of the C++ Standard library APIs for use in SYCL kernels. These APIs can be employed in the kernels similarly to how they are employed in code for a typical CPU-based platform.
Random Number Generation#
oneDPL provides a subset of the standard C++ pseudo-random number generation functionality
suitable to use within SYCL kernels. The APIs are defined in the <oneapi/dpl/random> header.
Supported functionality:#
- Engine class templates:
linear_congruential_enginesubtract_with_carry_engine
- Engine adaptor class templates:
discard_block_engine
- Engines and engine adaptors with predefined parameters:
minstd_rand0minstd_randranlux24_baseranlux48_baseranlux24ranlux48
- Distribution class templates:
uniform_int_distributionuniform_real_distribtuonnormal_distributionexponential_distributionbernoulli_distributiongeometric_distributionweibull_distribuionlognormal_distributioncauchy_distributionextreme_value_distribution
Additionally, sycl::vec<> can be used as the result type for engines, engine adaptors, and distributions.
Limitations:#
The following deviations from the C++ Standard may apply:
random_deviceandseed_seqclasses and related APIs in other classes are not required;operator>>(),operator<<(),operator==()are not required;specifying the size of a random number engine’s state is not required;
distributions are only required to operate with floating point types applicable to supported SYCL devices.
Function Objects#
The oneDPL function objects are defined in the <oneapi/dpl/functional> header.
namespace oneapi {
namespace dpl {
struct identity
{
template <typename T>
constexpr T&&
operator()(T&& t) const noexcept;
};
}
}
The oneapi::dpl::identity class implements an identity operation. Its function operator
receives an instance of a type and returns the argument unchanged.