DPC++ Runtime
Runtime libraries for oneAPI DPC++
syclcompat::detail Namespace Reference

Atomic extension to implement standard APIs in std::atomic. More...

Classes

struct  IsValidAtomicType
 
class  dev_mgr
 device manager More...
 
class  vectorized_binary
 
struct  shift_left
 
struct  shift_right
 
struct  average
 
class  accessor
 
class  memory_traits
 
class  host_buffer
 
class  generic_error_type
 
struct  DataType
 
struct  DataType< sycl::vec< T, 2 > >
 

Typedefs

template<typename ValueT >
using complex_type = detail::complex_namespace::complex< ValueT >
 

Enumerations

enum class  pointer_access_attribute { host_only = 0 , device_only , host_device , end }
 

Functions

static void parse_version_string (const std::string &ver, int &major, int &minor)
 
static void get_version (const sycl::device &dev, int &major, int &minor)
 
static unsigned int get_tid ()
 
static fs::path write_data_to_file (char const *const data, size_t size)
 Write data to temporary file and return absolute path to temporary file. More...
 
static uint16_t extract16 (unsigned char const *const ptr)
 
static uint32_t extract32 (unsigned char const *const ptr)
 
static uint64_t extract64 (unsigned char const *const ptr)
 
static uint64_t get_lib_size (char const *const blob)
 
static kernel_library load_dl_from_data (char const *const data, size_t size)
 
template<typename R , typename... Types>
constexpr size_t getArgumentCount (R(*f)(Types...))
 
template<int Dim>
sycl::nd_range< 3 > transform_nd_range (const sycl::nd_range< Dim > &range)
 
template<auto F, typename... Args>
std::enable_if_t< std::is_invocable_v< decltype(F), Args... >, sycl::eventlaunch (const sycl::nd_range< 3 > &range, sycl::queue q, Args... args)
 
template<auto F, typename... Args>
sycl::event launch (const sycl::nd_range< 3 > &range, size_t mem_size, sycl::queue q, Args... args)
 
template<typename ValueT >
ValueT clamp (ValueT val, ValueT min_val, ValueT max_val)
 
template<typename ValueT >
auto zero_or_signed_extend (ValueT val, unsigned bit)
 Extend the 'val' to 'bit' size, zero extend for unsigned int and signed extend for signed int. More...
 
template<typename RetT , bool needSat, typename AT , typename BT , typename BinaryOperation >
constexpr RetT extend_binary (AT a, BT b, BinaryOperation binary_op)
 
template<typename RetT , bool needSat, typename AT , typename BT , typename CT , typename BinaryOperation1 , typename BinaryOperation2 >
constexpr RetT extend_binary (AT a, BT b, CT c, BinaryOperation1 binary_op, BinaryOperation2 second_op)
 
template<typename T >
sycl::vec< int32_t, 2 > extract_and_extend2 (T a)
 
template<typename T >
sycl::vec< int16_t, 4 > extract_and_extend4 (T a)
 
template<typename RetT , bool NeedSat, bool NeedAdd, typename AT , typename BT , typename BinaryOperation >
constexpr RetT extend_vbinary2 (AT a, BT b, RetT c, BinaryOperation binary_op)
 
template<typename RetT , bool NeedSat, bool NeedAdd, typename AT , typename BT , typename BinaryOperation >
constexpr RetT extend_vbinary4 (AT a, BT b, RetT c, BinaryOperation binary_op)
 
template<typename ValueT >
bool isnan (const ValueT a)
 
template<typename T >
bfe (const T source, const uint32_t bit_start, const uint32_t num_bits)
 Bitfield-extract. More...
 
template<typename T >
bfi (const T x, const T y, const uint32_t bit_start, const uint32_t num_bits)
 Bitfield-insert. More...
 
template<typename T >
sycl::vec< T, 4 > extract_and_sign_or_zero_extend4 (T val)
 
template<typename T >
sycl::vec< T, 2 > extract_and_sign_or_zero_extend2 (T val)
 
static void * malloc (size_t size, sycl::queue q)
 
static constexpr size_t get_pitch (size_t x)
 Calculate pitch (padded length of major dimension x) by rounding up to multiple of 32. More...
 
static void * malloc (size_t &pitch, size_t x, size_t y, size_t z, sycl::queue q)
 Malloc pitched 3D data. More...
 
template<class T >
static sycl::event fill (sycl::queue q, void *dev_ptr, const T &pattern, size_t count)
 Set pattern to the first count elements of type T starting from dev_ptr. More...
 
static sycl::event memset (sycl::queue q, void *dev_ptr, int value, size_t size)
 Set value to the first size bytes starting from dev_ptr in q. More...
 
template<typename T >
static std::vector< sycl::eventmemset (sycl::queue q, pitched_data data, const T &value, sycl::range< 3 > size)
 Sets value to the 3D memory region pointed by data in q. More...
 
template<typename T >
static std::vector< sycl::eventmemset (sycl::queue q, void *ptr, size_t pitch, const T &value, size_t x, size_t y)
 Sets val to the pitched 2D memory region pointed by ptr in q. More...
 
static pointer_access_attribute get_pointer_attribute (sycl::queue q, const void *ptr)
 
static experimental::memcpy_direction deduce_memcpy_direction (sycl::queue q, void *to_ptr, const void *from_ptr)
 
static sycl::event memcpy (sycl::queue q, void *to_ptr, const void *from_ptr, size_t size, const std::vector< sycl::event > &dep_events={})
 
static size_t get_copy_range (sycl::range< 3 > size, size_t slice, size_t pitch)
 
static size_t get_offset (sycl::id< 3 > id, size_t slice, size_t pitch)
 
static std::vector< sycl::eventmemcpy (sycl::queue q, void *to_ptr, const void *from_ptr, sycl::range< 3 > to_range, sycl::range< 3 > from_range, sycl::id< 3 > to_id, sycl::id< 3 > from_id, sycl::range< 3 > size, const std::vector< sycl::event > &dep_events={})
 copy 3D matrix specified by size from 3D matrix specified by from_ptr and from_range to another specified by to_ptr and to_range. More...
 
static std::vector< sycl::eventmemcpy (sycl::queue q, pitched_data to, sycl::id< 3 > to_id, pitched_data from, sycl::id< 3 > from_id, sycl::range< 3 > size)
 memcpy 2D/3D matrix specified by pitched_data. More...
 
static std::vector< sycl::eventmemcpy (sycl::queue q, void *to_ptr, const void *from_ptr, size_t to_pitch, size_t from_pitch, size_t x, size_t y)
 memcpy 2D matrix with pitch. More...
 
static sycl::event combine_events (std::vector< sycl::event > &events, sycl::queue q)
 
void matrix_mem_copy (void *to_ptr, const void *from_ptr, int to_ld, int from_ld, int rows, int cols, int elem_size, sycl::queue queue=syclcompat::get_default_queue(), bool async=false)
 
template<typename T >
void matrix_mem_copy (T *to_ptr, const T *from_ptr, int to_ld, int from_ld, int rows, int cols, sycl::queue queue=get_default_queue(), bool async=false)
 Copy matrix data. More...
 

Variables

auto exception_handler
 SYCL default exception handler. More...
 
template<typename T >
constexpr bool is_int32_type
 

Detailed Description

Atomic extension to implement standard APIs in std::atomic.

Typedef Documentation

◆ complex_type

template<typename ValueT >
using syclcompat::detail::complex_type = typedef detail::complex_namespace::complex<ValueT>

Definition at line 47 of file math.hpp.

Enumeration Type Documentation

◆ pointer_access_attribute

Enumerator
host_only 
device_only 
host_device 
end 

Definition at line 281 of file memory.hpp.

Function Documentation

◆ bfe()

template<typename T >
T syclcompat::detail::bfe ( const T  source,
const uint32_t  bit_start,
const uint32_t  num_bits 
)
inline

Bitfield-extract.

Template Parameters
TThe type of
Parameters
sourcevalue, must be an integer.
sourceThe source value to extracting.
bit_startThe position to start extracting.
num_bitsThe number of bits to extracting.

Definition at line 238 of file math.hpp.

Referenced by syclcompat::bfe_safe().

◆ bfi()

template<typename T >
T syclcompat::detail::bfi ( const T  x,
const T  y,
const uint32_t  bit_start,
const uint32_t  num_bits 
)
inline

Bitfield-insert.

Template Parameters
TThe type of
Parameters
xand
y,mustbe an unsigned integer.
xThe source of the bitfield.
yThe source where bitfield is inserted.
bit_startThe position to start insertion.
num_bitsThe number of bits to insertion.

Definition at line 330 of file math.hpp.

Referenced by syclcompat::bfi_safe().

◆ clamp()

template<typename ValueT >
ValueT syclcompat::detail::clamp ( ValueT  val,
ValueT  min_val,
ValueT  max_val 
)
inline

Definition at line 50 of file math.hpp.

Referenced by syclcompat::clamp(), extend_vbinary2(), and extend_vbinary4().

◆ combine_events()

static sycl::event syclcompat::detail::combine_events ( std::vector< sycl::event > &  events,
sycl::queue  q 
)
static

◆ deduce_memcpy_direction()

static experimental::memcpy_direction syclcompat::detail::deduce_memcpy_direction ( sycl::queue  q,
void *  to_ptr,
const void *  from_ptr 
)
static

◆ extend_binary() [1/2]

template<typename RetT , bool needSat, typename AT , typename BT , typename BinaryOperation >
constexpr RetT syclcompat::detail::extend_binary ( AT  a,
BT  b,
BinaryOperation  binary_op 
)
inlineconstexpr

Definition at line 120 of file math.hpp.

References syclcompat::max(), syclcompat::min(), and zero_or_signed_extend().

◆ extend_binary() [2/2]

template<typename RetT , bool needSat, typename AT , typename BT , typename CT , typename BinaryOperation1 , typename BinaryOperation2 >
constexpr RetT syclcompat::detail::extend_binary ( AT  a,
BT  b,
CT  c,
BinaryOperation1  binary_op,
BinaryOperation2  second_op 
)
inlineconstexpr

Definition at line 132 of file math.hpp.

References syclcompat::max(), syclcompat::min(), and zero_or_signed_extend().

◆ extend_vbinary2()

template<typename RetT , bool NeedSat, bool NeedAdd, typename AT , typename BT , typename BinaryOperation >
constexpr RetT syclcompat::detail::extend_vbinary2 ( AT  a,
BT  b,
RetT  c,
BinaryOperation  binary_op 
)
inlineconstexpr

Definition at line 171 of file math.hpp.

References clamp(), extract_and_extend2(), syclcompat::max(), and syclcompat::min().

◆ extend_vbinary4()

template<typename RetT , bool NeedSat, bool NeedAdd, typename AT , typename BT , typename BinaryOperation >
constexpr RetT syclcompat::detail::extend_vbinary4 ( AT  a,
BT  b,
RetT  c,
BinaryOperation  binary_op 
)
inlineconstexpr

Definition at line 195 of file math.hpp.

References clamp(), extract_and_extend4(), syclcompat::max(), and syclcompat::min().

◆ extract16()

static uint16_t syclcompat::detail::extract16 ( unsigned char const *const  ptr)
inlinestatic

Definition at line 191 of file kernel.hpp.

Referenced by get_lib_size().

◆ extract32()

static uint32_t syclcompat::detail::extract32 ( unsigned char const *const  ptr)
inlinestatic

Definition at line 200 of file kernel.hpp.

Referenced by get_lib_size().

◆ extract64()

static uint64_t syclcompat::detail::extract64 ( unsigned char const *const  ptr)
inlinestatic

Definition at line 211 of file kernel.hpp.

Referenced by get_lib_size().

◆ extract_and_extend2()

template<typename T >
sycl::vec<int32_t, 2> syclcompat::detail::extract_and_extend2 ( a)

Definition at line 147 of file math.hpp.

References zero_or_signed_extend().

Referenced by extend_vbinary2().

◆ extract_and_extend4()

template<typename T >
sycl::vec<int16_t, 4> syclcompat::detail::extract_and_extend4 ( a)

Definition at line 157 of file math.hpp.

References zero_or_signed_extend().

Referenced by extend_vbinary4().

◆ extract_and_sign_or_zero_extend2()

template<typename T >
sycl::vec<T, 2> syclcompat::detail::extract_and_sign_or_zero_extend2 ( val)

Definition at line 1009 of file math.hpp.

Referenced by syclcompat::dp2a_hi(), and syclcompat::dp2a_lo().

◆ extract_and_sign_or_zero_extend4()

template<typename T >
sycl::vec<T, 4> syclcompat::detail::extract_and_sign_or_zero_extend4 ( val)

Definition at line 1002 of file math.hpp.

Referenced by syclcompat::dp2a_hi(), syclcompat::dp2a_lo(), and syclcompat::dp4a().

◆ fill()

template<class T >
static sycl::event syclcompat::detail::fill ( sycl::queue  q,
void *  dev_ptr,
const T &  pattern,
size_t  count 
)
inlinestatic

Set pattern to the first count elements of type T starting from dev_ptr.

Template Parameters
TDatatype of the pattern to be set.
Parameters
qThe queue in which the operation is done.
dev_ptrPointer to the device memory address.
patternPattern of type T to be set.
countNumber of elements to be set to the patten.
Returns
An event representing the fill operation.

Definition at line 222 of file memory.hpp.

References sycl::_V1::queue::fill().

Referenced by syclcompat::fill(), and syclcompat::fill_async().

◆ get_copy_range()

static size_t syclcompat::detail::get_copy_range ( sycl::range< 3 >  size,
size_t  slice,
size_t  pitch 
)
inlinestatic

Definition at line 324 of file memory.hpp.

References sycl::_V1::detail::array< dimensions >::get().

◆ get_lib_size()

static uint64_t syclcompat::detail::get_lib_size ( char const *const  blob)
inlinestatic

Definition at line 226 of file kernel.hpp.

References extract16(), extract32(), and extract64().

Referenced by syclcompat::load_kernel_library_mem().

◆ get_offset()

static size_t syclcompat::detail::get_offset ( sycl::id< 3 >  id,
size_t  slice,
size_t  pitch 
)
inlinestatic

Definition at line 329 of file memory.hpp.

◆ get_pitch()

static constexpr size_t syclcompat::detail::get_pitch ( size_t  x)
inlinestaticconstexpr

Calculate pitch (padded length of major dimension x) by rounding up to multiple of 32.

Parameters
xThe dimension to be padded (in bytes)
Returns
size_t representing pitched length of dimension x (in bytes).

Definition at line 195 of file memory.hpp.

Referenced by sycl::_V1::image< Dimensions, AllocatorT >::get_pitch(), and malloc().

◆ get_pointer_attribute()

static pointer_access_attribute syclcompat::detail::get_pointer_attribute ( sycl::queue  q,
const void *  ptr 
)
static

Definition at line 288 of file memory.hpp.

References device_only, sycl::_V1::queue::get_context(), host_device, and host_only.

Referenced by deduce_memcpy_direction().

◆ get_tid()

static unsigned int syclcompat::detail::get_tid ( )
inlinestatic

◆ get_version()

static void syclcompat::detail::get_version ( const sycl::device dev,
int &  major,
int &  minor 
)
static

◆ getArgumentCount()

template<typename R , typename... Types>
constexpr size_t syclcompat::detail::getArgumentCount ( R(*)(Types...)  f)
constexpr

Definition at line 40 of file launch.hpp.

Referenced by launch().

◆ isnan()

template<typename ValueT >
bool syclcompat::detail::isnan ( const ValueT  a)
inline

◆ launch() [1/2]

template<auto F, typename... Args>
sycl::event syclcompat::detail::launch ( const sycl::nd_range< 3 > &  range,
size_t  mem_size,
sycl::queue  q,
Args...  args 
)

◆ launch() [2/2]

template<auto F, typename... Args>
std::enable_if_t<std::is_invocable_v<decltype(F), Args...>, sycl::event> syclcompat::detail::launch ( const sycl::nd_range< 3 > &  range,
sycl::queue  q,
Args...  args 
)

Definition at line 59 of file launch.hpp.

References getArgumentCount(), and sycl::_V1::queue::parallel_for().

◆ load_dl_from_data()

static kernel_library syclcompat::detail::load_dl_from_data ( char const *const  data,
size_t  size 
)
inlinestatic

◆ malloc() [1/2]

static void* syclcompat::detail::malloc ( size_t &  pitch,
size_t  x,
size_t  y,
size_t  z,
sycl::queue  q 
)
inlinestatic

Malloc pitched 3D data.

Parameters
[out]pitchreturns the calculated pitch (in bytes)
[in]xwidth of the allocation (in bytes)
[in]yheight of the allocation
[in]zdepth of the allocation
[in]qThe queue in which the operation is done.
Returns
A pointer to the allocated memory

Definition at line 206 of file memory.hpp.

References get_pitch(), and malloc().

◆ malloc() [2/2]

static void* syclcompat::detail::malloc ( size_t  size,
sycl::queue  q 
)
inlinestatic

Definition at line 187 of file memory.hpp.

References sycl::_V1::queue::get_context(), and sycl::_V1::queue::get_device().

Referenced by malloc(), and syclcompat::malloc().

◆ matrix_mem_copy() [1/2]

template<typename T >
void syclcompat::detail::matrix_mem_copy ( T *  to_ptr,
const T *  from_ptr,
int  to_ld,
int  from_ld,
int  rows,
int  cols,
sycl::queue  queue = get_default_queue(),
bool  async = false 
)
inline

Copy matrix data.

The default leading dimension is column.

Parameters
[out]to_ptrA pointer points to the destination location.
[in]from_ptrA pointer points to the source location.
[in]to_ldThe leading dimension the destination matrix.
[in]from_ldThe leading dimension the source matrix.
[in]rowsThe number of rows of the source matrix.
[in]colsThe number of columns of the source matrix.
[in]queueThe queue where the routine should be executed.
[in]asyncIf this argument is true, the return of the function does NOT guarantee the copy is completed.

Definition at line 123 of file util.hpp.

References matrix_mem_copy().

◆ matrix_mem_copy() [2/2]

void syclcompat::detail::matrix_mem_copy ( void *  to_ptr,
const void *  from_ptr,
int  to_ld,
int  from_ld,
int  rows,
int  cols,
int  elem_size,
sycl::queue  queue = syclcompat::get_default_queue(),
bool  async = false 
)
inline

◆ memcpy() [1/4]

static std::vector<sycl::event> syclcompat::detail::memcpy ( sycl::queue  q,
pitched_data  to,
sycl::id< 3 >  to_id,
pitched_data  from,
sycl::id< 3 >  from_id,
sycl::range< 3 >  size 
)
inlinestatic

◆ memcpy() [2/4]

static sycl::event syclcompat::detail::memcpy ( sycl::queue  q,
void *  to_ptr,
const void *  from_ptr,
size_t  size,
const std::vector< sycl::event > &  dep_events = {} 
)
static

◆ memcpy() [3/4]

static std::vector<sycl::event> syclcompat::detail::memcpy ( sycl::queue  q,
void *  to_ptr,
const void *  from_ptr,
size_t  to_pitch,
size_t  from_pitch,
size_t  x,
size_t  y 
)
inlinestatic

memcpy 2D matrix with pitch.

Definition at line 464 of file memory.hpp.

References memcpy().

◆ memcpy() [4/4]

static std::vector<sycl::event> syclcompat::detail::memcpy ( sycl::queue  q,
void *  to_ptr,
const void *  from_ptr,
sycl::range< 3 >  to_range,
sycl::range< 3 >  from_range,
sycl::id< 3 >  to_id,
sycl::id< 3 >  from_id,
sycl::range< 3 >  size,
const std::vector< sycl::event > &  dep_events = {} 
)
inlinestatic

copy 3D matrix specified by size from 3D matrix specified by from_ptr and from_range to another specified by to_ptr and to_range.

Definition at line 358 of file memory.hpp.

◆ memset() [1/3]

template<typename T >
static std::vector<sycl::event> syclcompat::detail::memset ( sycl::queue  q,
pitched_data  data,
const T &  value,
sycl::range< 3 >  size 
)
inlinestatic

Sets value to the 3D memory region pointed by data in q.

Template Parameters
TThe type of the element to be set.
Parameters
[in]qThe queue in which the operation is done.
[in]dataPointer to the pitched device memory region.
[in]valueThe value to be set.
[in]size3D memory region by number of elements.
Returns
An event list representing the memset operations.

Definition at line 248 of file memory.hpp.

References sycl::_V1::detail::array< dimensions >::get(), syclcompat::pitched_data::get_data_ptr(), syclcompat::pitched_data::get_pitch(), and syclcompat::pitched_data::get_y().

◆ memset() [2/3]

static sycl::event syclcompat::detail::memset ( sycl::queue  q,
void *  dev_ptr,
int  value,
size_t  size 
)
inlinestatic

Set value to the first size bytes starting from dev_ptr in q.

Parameters
qThe queue in which the operation is done.
dev_ptrPointer to the device memory address.
valueValue to be set.
sizeNumber of bytes to be set to the value.
Returns
An event representing the memset operation.

Definition at line 234 of file memory.hpp.

References sycl::_V1::queue::memset().

Referenced by memset(), syclcompat::memset(), syclcompat::memset_async(), syclcompat::memset_d16(), syclcompat::memset_d16_async(), syclcompat::memset_d32(), and syclcompat::memset_d32_async().

◆ memset() [3/3]

template<typename T >
static std::vector<sycl::event> syclcompat::detail::memset ( sycl::queue  q,
void *  ptr,
size_t  pitch,
const T &  value,
size_t  x,
size_t  y 
)
inlinestatic

Sets val to the pitched 2D memory region pointed by ptr in q.

Template Parameters
TThe type of the element to be set.
Parameters
[in]qThe queue in which the operation is done.
[in]ptrPointer to the virtual device memory.
[in]pitchThe pitch size by number of elements, including padding.
[in]valueThe value to be set.
[in]xThe width of memory region by number of elements.
[in]yThe height of memory region by number of elements.
Returns
An event list representing the memset operations.

Definition at line 274 of file memory.hpp.

References memset().

◆ parse_version_string()

static void syclcompat::detail::parse_version_string ( const std::string &  ver,
int &  major,
int &  minor 
)
static

Definition at line 62 of file device.hpp.

Referenced by get_version().

◆ transform_nd_range()

template<int Dim>
sycl::nd_range<3> syclcompat::detail::transform_nd_range ( const sycl::nd_range< Dim > &  range)

◆ write_data_to_file()

static fs::path syclcompat::detail::write_data_to_file ( char const *const  data,
size_t  size 
)
inlinestatic

Write data to temporary file and return absolute path to temporary file.

Temporary file is created in a temporary directory both of which have random names with only the user having access permissions. Only one temporary file will be created in the temporary directory.

Definition at line 96 of file kernel.hpp.

Referenced by load_dl_from_data().

◆ zero_or_signed_extend()

template<typename ValueT >
auto syclcompat::detail::zero_or_signed_extend ( ValueT  val,
unsigned  bit 
)
inline

Extend the 'val' to 'bit' size, zero extend for unsigned int and signed extend for signed int.

Returns a signed integer type.

Definition at line 88 of file math.hpp.

Referenced by extend_binary(), extract_and_extend2(), and extract_and_extend4().

Variable Documentation

◆ exception_handler

auto syclcompat::detail::exception_handler
inline
Initial value:
= [](sycl::exception_list exceptions) {
for (std::exception_ptr const &e : exceptions) {
try {
std::rethrow_exception(e);
} catch (sycl::exception const &e) {
std::cerr << "[SYCLcompat] Caught asynchronous SYCL exception:"
<< std::endl
<< e.what() << std::endl
<< "Exception caught at file:" << __FILE__
<< ", line:" << __LINE__ << std::endl;
}
}
}
A list of asynchronous exceptions.
const char * what() const noexcept final
Definition: exception.cpp:49
__SYCL_EXTERN_STREAM_ATTRS ostream cerr
Linked to standard error (unbuffered)

SYCL default exception handler.

Definition at line 96 of file device.hpp.

◆ is_int32_type

template<typename T >
constexpr bool syclcompat::detail::is_int32_type
constexpr
Initial value:
= std::is_same_v<std::decay_t<T>, int32_t> ||
std::is_same_v<std::decay_t<T>, uint32_t>

Definition at line 55 of file math.hpp.