DPC++ Runtime
Runtime libraries for oneAPI DPC++
syclcompat::device_memory< T, Memory, Dimension > Class Template Reference

Device variable with address space of shared or global. More...

#include <syclcompat/memory.hpp>

Public Types

using accessor_t = typename detail::memory_traits< Memory, T >::template accessor_t< Dimension >
 
using value_t = typename detail::memory_traits< Memory, T >::value_t
 
using syclcompat_accessor_t = syclcompat::accessor< T, Memory, Dimension >
 

Public Member Functions

 device_memory (sycl::queue q=get_default_queue())
 
 device_memory (const sycl::range< Dimension > &in_range, std::initializer_list< value_t > &&init_list, sycl::queue q=get_default_queue())
 Constructor of 1-D array with initializer list. More...
 
template<size_t Dim = Dimension>
 device_memory (const typename std::enable_if< Dim==2, sycl::range< 2 >>::type &in_range, std::initializer_list< std::initializer_list< value_t >> &&init_list, sycl::queue q=get_default_queue())
 Constructor of 2-D array with initializer list. More...
 
 device_memory (const sycl::range< Dimension > &range_in, sycl::queue q=get_default_queue())
 Constructor with range. More...
 
template<class... Args, size_t Dim = Dimension, typename = std::enable_if_t<sizeof...(Args) == Dim>>
 device_memory (Args... Arguments)
 Constructor with range. More...
 
template<class... Args>
 device_memory (Args... Arguments, sycl::queue q)
 Constructor with range and queue. More...
 
 ~device_memory ()
 
void init ()
 Allocate memory with the queue specified in the constuctor, and init memory if has initial value. More...
 
void init (sycl::queue q)
 Allocate memory with specified queue, and init memory if has initial value. More...
 
void assign (value_t *src, size_t size)
 The variable is assigned to a device pointer. More...
 
value_tget_ptr ()
 
value_tget_ptr (sycl::queue q)
 
size_t get_size ()
 Get the device memory object size in bytes. More...
 
template<size_t Dim = Dimension>
std::enable_if< Dim==1, T >::type & operator[] (size_t index)
 
template<size_t Dim = Dimension>
std::enable_if< Dim !=1, syclcompat_accessor_t >::type get_access (sycl::handler &cgh)
 Get compat_accessor with dimension info for the device memory object when usm is used and dimension is greater than 1. More...
 

Detailed Description

template<class T, memory_region Memory, size_t Dimension>
class syclcompat::device_memory< T, Memory, Dimension >

Device variable with address space of shared or global.

Definition at line 888 of file memory.hpp.

Member Typedef Documentation

◆ accessor_t

template<class T , memory_region Memory, size_t Dimension>
using syclcompat::device_memory< T, Memory, Dimension >::accessor_t = typename detail::memory_traits<Memory, T>::template accessor_t<Dimension>

Definition at line 890 of file memory.hpp.

◆ syclcompat_accessor_t

template<class T , memory_region Memory, size_t Dimension>
using syclcompat::device_memory< T, Memory, Dimension >::syclcompat_accessor_t = syclcompat::accessor<T, Memory, Dimension>

Definition at line 893 of file memory.hpp.

◆ value_t

template<class T , memory_region Memory, size_t Dimension>
using syclcompat::device_memory< T, Memory, Dimension >::value_t = typename detail::memory_traits<Memory, T>::value_t

Definition at line 892 of file memory.hpp.

Constructor & Destructor Documentation

◆ device_memory() [1/6]

template<class T , memory_region Memory, size_t Dimension>
syclcompat::device_memory< T, Memory, Dimension >::device_memory ( sycl::queue  q = get_default_queue())
inline

Definition at line 895 of file memory.hpp.

◆ device_memory() [2/6]

template<class T , memory_region Memory, size_t Dimension>
syclcompat::device_memory< T, Memory, Dimension >::device_memory ( const sycl::range< Dimension > &  in_range,
std::initializer_list< value_t > &&  init_list,
sycl::queue  q = get_default_queue() 
)
inline

Constructor of 1-D array with initializer list.

Definition at line 899 of file memory.hpp.

References syclcompat::malloc(), and sycl::_V1::range< Dimensions >::size().

◆ device_memory() [3/6]

template<class T , memory_region Memory, size_t Dimension>
template<size_t Dim = Dimension>
syclcompat::device_memory< T, Memory, Dimension >::device_memory ( const typename std::enable_if< Dim==2, sycl::range< 2 >>::type &  in_range,
std::initializer_list< std::initializer_list< value_t >> &&  init_list,
sycl::queue  q = get_default_queue() 
)
inline

Constructor of 2-D array with initializer list.

Definition at line 911 of file memory.hpp.

References syclcompat::malloc().

◆ device_memory() [4/6]

template<class T , memory_region Memory, size_t Dimension>
syclcompat::device_memory< T, Memory, Dimension >::device_memory ( const sycl::range< Dimension > &  range_in,
sycl::queue  q = get_default_queue() 
)
inline

Constructor with range.

Definition at line 928 of file memory.hpp.

◆ device_memory() [5/6]

template<class T , memory_region Memory, size_t Dimension>
template<class... Args, size_t Dim = Dimension, typename = std::enable_if_t<sizeof...(Args) == Dim>>
syclcompat::device_memory< T, Memory, Dimension >::device_memory ( Args...  Arguments)
inline

Constructor with range.

Definition at line 945 of file memory.hpp.

◆ device_memory() [6/6]

template<class T , memory_region Memory, size_t Dimension>
template<class... Args>
syclcompat::device_memory< T, Memory, Dimension >::device_memory ( Args...  Arguments,
sycl::queue  q 
)
inline

Constructor with range and queue.

Definition at line 951 of file memory.hpp.

◆ ~device_memory()

template<class T , memory_region Memory, size_t Dimension>
syclcompat::device_memory< T, Memory, Dimension >::~device_memory ( )
inline

Definition at line 954 of file memory.hpp.

References syclcompat::free().

Member Function Documentation

◆ assign()

template<class T , memory_region Memory, size_t Dimension>
void syclcompat::device_memory< T, Memory, Dimension >::assign ( value_t src,
size_t  size 
)
inline

The variable is assigned to a device pointer.

Definition at line 977 of file memory.hpp.

◆ get_access()

template<class T , memory_region Memory, size_t Dimension>
template<size_t Dim = Dimension>
std::enable_if<Dim != 1, syclcompat_accessor_t>::type syclcompat::device_memory< T, Memory, Dimension >::get_access ( sycl::handler cgh)
inline

Get compat_accessor with dimension info for the device memory object when usm is used and dimension is greater than 1.

Definition at line 1004 of file memory.hpp.

◆ get_ptr() [1/2]

template<class T , memory_region Memory, size_t Dimension>
value_t* syclcompat::device_memory< T, Memory, Dimension >::get_ptr ( )
inline

◆ get_ptr() [2/2]

template<class T , memory_region Memory, size_t Dimension>
value_t* syclcompat::device_memory< T, Memory, Dimension >::get_ptr ( sycl::queue  q)
inline

Definition at line 986 of file memory.hpp.

◆ get_size()

template<class T , memory_region Memory, size_t Dimension>
size_t syclcompat::device_memory< T, Memory, Dimension >::get_size ( )
inline

Get the device memory object size in bytes.

Definition at line 992 of file memory.hpp.

◆ init() [1/2]

template<class T , memory_region Memory, size_t Dimension>
void syclcompat::device_memory< T, Memory, Dimension >::init ( )
inline

Allocate memory with the queue specified in the constuctor, and init memory if has initial value.

Definition at line 963 of file memory.hpp.

References syclcompat::device_memory< T, Memory, Dimension >::init().

Referenced by syclcompat::device_memory< T, Memory, Dimension >::init().

◆ init() [2/2]

template<class T , memory_region Memory, size_t Dimension>
void syclcompat::device_memory< T, Memory, Dimension >::init ( sycl::queue  q)
inline

Allocate memory with specified queue, and init memory if has initial value.

Definition at line 966 of file memory.hpp.

References syclcompat::memcpy().

◆ operator[]()

template<class T , memory_region Memory, size_t Dimension>
template<size_t Dim = Dimension>
std::enable_if<Dim == 1, T>::type& syclcompat::device_memory< T, Memory, Dimension >::operator[] ( size_t  index)
inline

Definition at line 995 of file memory.hpp.


The documentation for this class was generated from the following file: