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/intel/experimental/usm_properties.hpp>
#include <sycl/ext/oneapi/group_local_memory.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...
 
class  syclcompat::detail::memory_traits< Memory, T >
 
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::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::detail::memcpy_direction {
  syclcompat::detail::host_to_host , syclcompat::detail::host_to_device , syclcompat::detail::device_to_host , syclcompat::detail::device_to_device ,
  syclcompat::detail::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 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)
 
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...
 
static std::vector< sycl::eventsyclcompat::detail::memset (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::eventsyclcompat::detail::memset (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 syclcompat::detail::get_pointer_attribute (sycl::queue q, const void *ptr)
 
static 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 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::free (void *ptr, sycl::queue q=get_default_queue())
 free More...
 
sycl::event syclcompat::free_async (const std::vector< void * > &pointers, const std::vector< sycl::event > &events, sycl::queue q=get_default_queue())
 Free the device memory pointed by a batch of pointers in pointers which are related to q after events completed. 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::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 sycl::event syclcompat::memset_async (void *dev_ptr, int value, size_t size, sycl::queue q=get_default_queue())
 Asynchronously sets value to the first size bytes starting from dev_ptr. 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 value to the 2D memory region pointed by ptr in q. 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 value to the 2D memory region pointed by ptr in q. 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...