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
 
class  accessor
 
class  memory_traits
 
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  memcpy_direction {
  host_to_host , host_to_device , device_to_host , device_to_device ,
  automatic
}
 
enum class  pointer_access_attribute { host_only = 0 , device_only , host_device , end }
 

Functions

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 >
int64_t zero_or_signed_extent (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 ValueT >
bool isnan (const ValueT a)
 
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 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...
 

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

◆ memcpy_direction

Enumerator
host_to_host 
host_to_device 
device_to_host 
device_to_device 
automatic 

Definition at line 81 of file memory.hpp.

◆ pointer_access_attribute

Enumerator
host_only 
device_only 
host_device 
end 

Definition at line 246 of file memory.hpp.

Function Documentation

◆ 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().

◆ combine_events()

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

◆ deduce_memcpy_direction()

static 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 93 of file math.hpp.

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

◆ 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 105 of file math.hpp.

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

◆ 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().

◆ 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 187 of file memory.hpp.

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

◆ 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 294 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 299 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 160 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 253 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

◆ 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 171 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 152 of file memory.hpp.

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

Referenced by 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

Definition at line 285 of file memory.hpp.

Referenced by matrix_mem_copy().

◆ 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 432 of file memory.hpp.

References syclcompat::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 306 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 213 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 199 of file memory.hpp.

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

Referenced by memset().

◆ 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 239 of file memory.hpp.

References memset().

◆ 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_extent()

template<typename ValueT >
int64_t syclcompat::detail::zero_or_signed_extent ( ValueT  val,
unsigned  bit 
)
inline

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

Definition at line 84 of file math.hpp.

Referenced by extend_binary().

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:75
__SYCL_EXTERN_STREAM_ATTRS ostream cerr
Linked to standard error (unbuffered)

SYCL default exception handler.

Definition at line 64 of file device.hpp.