DPC++ Runtime
Runtime libraries for oneAPI DPC++
memory.hpp File Reference
#include <cassert>
#include <cstdint>
#include <cstring>
#include <map>
#include <mutex>
#include <thread>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <sycl/builtins.hpp>
#include <sycl/ext/oneapi/free_function_queries.hpp>
#include <sycl/ext/oneapi/group_local_memory.hpp>
#include <sycl/group.hpp>
#include <sycl/usm.hpp>
#include <syclcompat/device.hpp>
#include <syclcompat/traits.hpp>
Include dependency graph for memory.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  syclcompat::pitched_data
 Pitched 2D/3D memory data. More...
 
struct  syclcompat::experimental::memcpy_parameter
 Memory copy parameters for 2D/3D memory data. More...
 
struct  syclcompat::experimental::memcpy_parameter::data_wrapper
 
class  syclcompat::detail::memory_traits< Memory, T >
 
class  syclcompat::detail::host_buffer
 
class  syclcompat::accessor< T, Memory, 3 >
 
class  syclcompat::accessor< T, Memory, 2 >
 
class  syclcompat::device_memory< T, Memory, Dimension >
 Device variable with address space of shared or global. More...
 
class  syclcompat::device_memory< T, Memory, 0 >
 
class  syclcompat::pointer_attributes
 

Namespaces

 syclcompat
 
 syclcompat::experimental
 
 syclcompat::experimental::detail
 
 syclcompat::detail
 Atomic extension to implement standard APIs in std::atomic.
 

Typedefs

using syclcompat::byte_t = uint8_t
 
template<class T , size_t Dimension>
using syclcompat::global_memory = device_memory< T, memory_region::global, Dimension >
 
template<class T , size_t Dimension>
using syclcompat::constant_memory = device_memory< T, memory_region::constant, Dimension >
 
template<class T , size_t Dimension>
using syclcompat::shared_memory = device_memory< T, memory_region::usm_shared, Dimension >
 

Enumerations

enum  syclcompat::experimental::memcpy_direction {
  syclcompat::experimental::host_to_host , syclcompat::experimental::host_to_device , syclcompat::experimental::device_to_host , syclcompat::experimental::device_to_device ,
  syclcompat::experimental::automatic
}
 
enum class  syclcompat::memory_region { syclcompat::global = 0 , syclcompat::constant , syclcompat::local , syclcompat::usm_shared }
 
enum class  syclcompat::target { syclcompat::device , syclcompat::local }
 
enum class  syclcompat::detail::pointer_access_attribute { syclcompat::detail::host_only = 0 , syclcompat::detail::device_only , syclcompat::detail::host_device , syclcompat::detail::end }
 

Functions

template<typename AllocT >
auto * syclcompat::local_mem ()
 
static pitched_data syclcompat::experimental::detail::to_pitched_data (image_matrix *image)
 
static void * syclcompat::detail::malloc (size_t size, sycl::queue q)
 
static constexpr size_t syclcompat::detail::get_pitch (size_t x)
 Calculate pitch (padded length of major dimension x) by rounding up to multiple of 32. More...
 
static void * syclcompat::detail::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 syclcompat::detail::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 syclcompat::detail::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::eventsyclcompat::detail::memset (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::eventsyclcompat::detail::memset (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 syclcompat::detail::get_pointer_attribute (sycl::queue q, const void *ptr)
 
static experimental::memcpy_direction syclcompat::detail::deduce_memcpy_direction (sycl::queue q, void *to_ptr, const void *from_ptr)
 
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 size_t syclcompat::detail::get_copy_range (sycl::range< 3 > size, size_t slice, size_t pitch)
 
static size_t syclcompat::detail::get_offset (sycl::id< 3 > id, size_t slice, size_t pitch)
 
static std::vector< sycl::eventsyclcompat::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={})
 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::eventsyclcompat::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)
 memcpy 2D/3D matrix specified by pitched_data. More...
 
static std::vector< sycl::eventsyclcompat::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)
 memcpy 2D matrix with pitch. More...
 
static sycl::event syclcompat::detail::combine_events (std::vector< sycl::event > &events, sycl::queue q)
 
static std::vector< sycl::eventsyclcompat::experimental::detail::memcpy (sycl::queue q, const experimental::memcpy_parameter &param)
 
static void * syclcompat::malloc (size_t num_bytes, sycl::queue q=get_default_queue())
 Allocate memory block on the device. More...
 
static void * syclcompat::malloc_host (size_t num_bytes, sycl::queue q=get_default_queue())
 Allocate memory block on the host. More...
 
static void * syclcompat::malloc_shared (size_t num_bytes, sycl::queue q=get_default_queue())
 Allocate memory block of usm_shared memory. More...
 
static pitched_data syclcompat::malloc (sycl::range< 3 > size, sycl::queue q=get_default_queue())
 Allocate memory block for 3D array on the device. More...
 
static void * syclcompat::malloc (size_t &pitch, size_t x, size_t y, sycl::queue q=get_default_queue())
 Allocate memory block for 2D array on the device. More...
 
static void syclcompat::wait_and_free (void *ptr, sycl::queue q=get_default_queue())
 Wait on the queue q and free the memory ptr. More...
 
static void syclcompat::free (void *ptr, sycl::queue q=get_default_queue())
 Free the memory ptr on the default queue without synchronizing. More...
 
sycl::event syclcompat::enqueue_free (const std::vector< void * > &pointers, const std::vector< sycl::event > &events, sycl::queue q=get_default_queue())
 Enqueues the release of all pointers in /p pointers on the /p q. More...
 
static void syclcompat::memcpy (void *to_ptr, const void *from_ptr, size_t size, sycl::queue q=get_default_queue())
 Synchronously copies size bytes from the address specified by from_ptr to the address specified by to_ptr. More...
 
static sycl::event syclcompat::memcpy_async (void *to_ptr, const void *from_ptr, size_t size, sycl::queue q=get_default_queue())
 Asynchronously copies size bytes from the address specified by from_ptr to the address specified by to_ptr. More...
 
template<typename T >
static sycl::event syclcompat::memcpy_async (type_identity_t< T > *to_ptr, const type_identity_t< T > *from_ptr, size_t count, sycl::queue q=get_default_queue())
 Asynchronously copies count T's from the address specified by from_ptr to the address specified by to_ptr. More...
 
template<typename T >
static void syclcompat::memcpy (type_identity_t< T > *to_ptr, const type_identity_t< T > *from_ptr, size_t count, sycl::queue q=get_default_queue())
 Synchronously copies count T's from the address specified by from_ptr to the address specified by to_ptr. More...
 
static void syclcompat::memcpy (void *to_ptr, size_t to_pitch, const void *from_ptr, size_t from_pitch, size_t x, size_t y, sycl::queue q=get_default_queue())
 Synchronously copies 2D matrix specified by x and y from the address specified by from_ptr to the address specified by to_ptr, while from_pitch and to_pitch are the range of dim x in bytes of the matrix specified by from_ptr and to_ptr. More...
 
static sycl::event syclcompat::memcpy_async (void *to_ptr, size_t to_pitch, const void *from_ptr, size_t from_pitch, size_t x, size_t y, sycl::queue q=get_default_queue())
 Asynchronously copies 2D matrix specified by x and y from the address specified by from_ptr to the address specified by to_ptr, while from_pitch and to_pitch are the range of dim x in bytes of the matrix specified by from_ptr and to_ptr. More...
 
static void syclcompat::memcpy (pitched_data to, sycl::id< 3 > to_pos, pitched_data from, sycl::id< 3 > from_pos, sycl::range< 3 > size, sycl::queue q=get_default_queue())
 Synchronously copies a subset of a 3D matrix specified by to to another 3D matrix specified by from. More...
 
static sycl::event syclcompat::memcpy_async (pitched_data to, sycl::id< 3 > to_pos, pitched_data from, sycl::id< 3 > from_pos, sycl::range< 3 > size, sycl::queue q=get_default_queue())
 Asynchronously copies a subset of a 3D matrix specified by to to another 3D matrix specified by from. More...
 
template<class T >
static void syclcompat::fill (void *dev_ptr, const T &pattern, size_t count, sycl::queue q=get_default_queue())
 Synchronously sets pattern to the first count elements starting from dev_ptr. More...
 
template<class T >
static sycl::event syclcompat::fill_async (void *dev_ptr, const T &pattern, size_t count, sycl::queue q=get_default_queue())
 Asynchronously sets pattern to the first count elements starting from dev_ptr. More...
 
static void syclcompat::experimental::memcpy (const memcpy_parameter &param, sycl::queue q=get_default_queue())
 [UNSUPPORTED] Synchronously copies 2D/3D memory data specified by param . More...
 
static void syclcompat::experimental::memcpy_async (const memcpy_parameter &param, sycl::queue q=get_default_queue())
 [UNSUPPORTED] Asynchronously copies 2D/3D memory data specified by param More...
 
static void syclcompat::memset (void *dev_ptr, int value, size_t size, sycl::queue q=get_default_queue())
 Synchronously sets value to the first size bytes starting from dev_ptr. More...
 
static void syclcompat::memset_d16 (void *dev_ptr, unsigned short value, size_t size, sycl::queue q=get_default_queue())
 Sets 2 bytes data value to the first size elements starting from dev_ptr in q synchronously. More...
 
static void syclcompat::memset_d32 (void *dev_ptr, unsigned int value, size_t size, sycl::queue q=get_default_queue())
 Sets 4 bytes data value to the first size elements starting from dev_ptr in q synchronously. More...
 
static sycl::event syclcompat::memset_async (void *dev_ptr, int value, size_t size, sycl::queue q=get_default_queue())
 Sets 1 byte data value to the first size elements starting from dev_ptr in q asynchronously. More...
 
static sycl::event syclcompat::memset_d16_async (void *dev_ptr, unsigned short value, size_t size, sycl::queue q=get_default_queue())
 Sets 2 bytes data value to the first size elements starting from dev_ptr in q asynchronously. More...
 
static sycl::event syclcompat::memset_d32_async (void *dev_ptr, unsigned int value, size_t size, sycl::queue q=get_default_queue())
 Sets 4 bytes data value to the first size elements starting from dev_ptr in q asynchronously. More...
 
static void syclcompat::memset (void *ptr, size_t pitch, int val, size_t x, size_t y, sycl::queue q=get_default_queue())
 Sets 1 byte data val to the pitched 2D memory region pointed by ptr in q synchronously. More...
 
static void syclcompat::memset_d16 (void *ptr, size_t pitch, unsigned short val, size_t x, size_t y, sycl::queue q=get_default_queue())
 Sets 2 bytes data val to the pitched 2D memory region pointed by ptr in q synchronously. More...
 
static void syclcompat::memset_d32 (void *ptr, size_t pitch, unsigned int val, size_t x, size_t y, sycl::queue q=get_default_queue())
 Sets 4 bytes data val to the pitched 2D memory region pointed by ptr in q synchronously. More...
 
static sycl::event syclcompat::memset_async (void *ptr, size_t pitch, int val, size_t x, size_t y, sycl::queue q=get_default_queue())
 Sets 1 byte data val to the pitched 2D memory region pointed by ptr in q asynchronously. More...
 
static sycl::event syclcompat::memset_d16_async (void *ptr, size_t pitch, unsigned short val, size_t x, size_t y, sycl::queue q=get_default_queue())
 Sets 2 bytes data val to the pitched 2D memory region pointed by ptr in q asynchronously. More...
 
static sycl::event syclcompat::memset_d32_async (void *ptr, size_t pitch, unsigned int val, size_t x, size_t y, sycl::queue q=get_default_queue())
 Sets 4 bytes data val to the pitched 2D memory region pointed by ptr in q asynchronously. More...
 
static void syclcompat::memset (pitched_data pitch, int val, sycl::range< 3 > size, sycl::queue q=get_default_queue())
 Sets value to the 3D memory region specified by pitch in q. More...
 
static sycl::event syclcompat::memset_async (pitched_data pitch, int val, sycl::range< 3 > size, sycl::queue q=get_default_queue())
 Sets value to the 3D memory region specified by pitch in q. More...