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  accessor
 
class  memory_traits
 
struct  DataType
 
struct  DataType< sycl::vec< T, 2 > >
 

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 ()
 
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)
 
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)
 
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...
 
static std::vector< sycl::eventmemset (sycl::queue q, pitched_data data, int value, sycl::range< 3 > size)
 Set value to the 3D memory region pointed by data in q. More...
 
static std::vector< sycl::eventmemset (sycl::queue q, void *ptr, size_t pitch, int val, size_t x, size_t y)
 memset 2D matrix with pitch. 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=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.

Enumeration Type Documentation

◆ memcpy_direction

Enumerator
host_to_host 
host_to_device 
device_to_host 
device_to_device 
automatic 

Definition at line 72 of file memory.hpp.

◆ pointer_access_attribute

Enumerator
host_only 
device_only 
host_device 
end 

Definition at line 220 of file memory.hpp.

Function Documentation

◆ 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

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

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

Referenced by sycl::_V1::detail::MemoryManager::fill(), sycl::_V1::detail::array_fill_helper< Kind, Idx, T, Args... >::fill(), sycl::_V1::detail::context_impl::memcpyFromHostOnlyDeviceGlobal(), and sycl::_V1::detail::packCallArguments().

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

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

◆ get_offset()

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

Definition at line 273 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
Returns
size_t representing pitched length of dimension x.

Definition at line 152 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 227 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().

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

◆ malloc() [1/2]

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

Definition at line 156 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 144 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 90 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 = 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 259 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 407 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 280 of file memory.hpp.

◆ memset() [1/3]

static std::vector<sycl::event> syclcompat::detail::memset ( sycl::queue  q,
pitched_data  data,
int  value,
sycl::range< 3 >  size 
)
inlinestatic

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

size specifies the 3D memory size to set.

Parameters
qThe queue in which the operation is done.
dataPointer to the device memory region.
valueValue to be set.
sizeMemory region size.
Returns
An event list representing the memset operations.

Definition at line 197 of file memory.hpp.

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

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

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

Referenced by memset().

◆ memset() [3/3]

static std::vector<sycl::event> syclcompat::detail::memset ( sycl::queue  q,
void *  ptr,
size_t  pitch,
int  val,
size_t  x,
size_t  y 
)
inlinestatic

memset 2D matrix with pitch.

Definition at line 215 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)

Variable Documentation

◆ exception_handler

auto syclcompat::detail::exception_handler
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:89
__SYCL_EXTERN_STREAM_ATTRS ostream cerr
Linked to standard error (unbuffered)

SYCL default exception handler.

Definition at line 63 of file device.hpp.

Referenced by syclcompat::device_ext::create_queue(), syclcompat::device_ext::device_ext(), and syclcompat::device_ext::reset().