24 #ifndef VISIONCPP_INCLUDE_FRAMEWORK_MEMORY_MEMORY_HPP_
25 #define VISIONCPP_INCLUDE_FRAMEWORK_MEMORY_MEMORY_HPP_
34 struct MemoryProperties;
36 template <
bool MapAlloc,
size_t ScalarType,
size_t MemoryType,
typename Sclr,
37 size_t Width,
size_t Height,
typename ElementTp,
size_t elements,
38 size_t Sc,
size_t Level>
51 template <
typename ElementType,
size_t LeafType,
size_t Cols,
size_t Rows,
68 template <
typename T,
typename Scalar>
73 namespace element_category {
93 static inline cl::sycl::range<2>
get_range(
size_t r,
size_t c) {
94 return cl::sycl::range<2>(r, c);
106 static inline cl::sycl::range<1>
get_range(
size_t r,
size_t c) {
107 return cl::sycl::range<1>(r * c);
119 template <
size_t Dim>
120 inline cl::sycl::range<Dim>
get_range(
size_t r,
size_t c) {
133 template <
size_t LeafType,
size_t Sc>
136 template <
size_t LeafType>
138 static constexpr cl::sycl::access::target scope =
139 cl::sycl::access::target::global_buffer;
142 template <
size_t LeafType>
144 static constexpr cl::sycl::access::target scope =
145 cl::sycl::access::target::host_buffer;
148 template <
size_t LeafType>
150 static constexpr cl::sycl::access::target scope =
151 cl::sycl::access::target::local;
154 template <
size_t LeafType>
156 static constexpr cl::sycl::access::target scope =
157 cl::sycl::access::target::constant_buffer;
163 static constexpr cl::sycl::access::target scope =
164 cl::sycl::access::target::image;
170 template <cl::sycl::access::target Sc>
214 template <
size_t LeafType,
size_t Dim, cl::sycl::access::mode AccMd,
215 typename ElementType,
typename Scalar,
size_t scope>
217 using Accessor = cl::sycl::accessor<ElementType, Dim, AccMd,
223 template <
size_t Dim, cl::sycl::access::mode AccMd,
typename ElementType,
224 typename Scalar,
size_t scope>
229 cl::sycl::accessor<
typename Properties::access_type, Dim, AccMd,
236 template <
size_t Dim, cl::sycl::access::mode AccMd,
typename ElementType,
237 typename Scalar,
size_t scope>
253 template <
bool MapAlloc,
size_t LeafType,
size_t Dim,
typename ElementType>
256 template <
size_t LeafType,
size_t Dim,
typename ElementType>
257 struct SyclMem<true, LeafType, Dim, ElementType> {
258 using Type = cl::sycl::buffer<ElementType, Dim>;
263 template <
size_t LeafType,
size_t Dim,
typename ElementType>
264 struct SyclMem<false, LeafType, Dim, ElementType> {
265 using Type = cl::sycl::buffer<ElementType, Dim>;
269 template <
size_t Dim,
typename ElementType>
271 using Type = cl::sycl::image<Dim>;
276 template <
size_t Dim,
typename ElementType>
283 template <
size_t Dim,
typename ElementType>
285 using Type = cl::sycl::image<Dim>;
293 template <
size_t LeafType>
295 static constexpr
size_t Dim = 2;
301 static constexpr
size_t Dim = 1;
307 static constexpr
size_t Dim = 1;
314 static constexpr
size_t Dim = 1;
326 template <
size_t LeafType,
typename ElemType,
typename Scalar,
327 typename VisionMem,
typename RNG>
337 static inline void create_buffer(std::shared_ptr<VisionMem> &ptr, Scalar *dt,
339 ptr = std::make_shared<VisionMem>(
340 VisionMem((
static_cast<ElemType *
>(
static_cast<void *
>(dt))), rng));
350 static inline void create_buffer(std::shared_ptr<VisionMem> &ptr, RNG rng) {
351 ptr = std::make_shared<VisionMem>(VisionMem(rng));
352 ptr.get()->set_final_data(
nullptr);
358 template <
typename ElemType,
typename Scalar,
typename VisionMem,
typename RNG>
367 static inline void create_buffer(std::shared_ptr<VisionMem> &ptr, Scalar *dt,
369 ptr = std::make_shared<VisionMem>(VisionMem(dt, Properties::channel_order,
370 Properties::channel_type, rng));
380 static inline void create_buffer(std::shared_ptr<VisionMem> &ptr, RNG rng) {
381 ptr = std::make_shared<VisionMem>(
382 VisionMem(Properties::channel_order, Properties::channel_type, rng));
383 ptr.get()->set_final_data(
nullptr);
389 template <
typename ElemType,
typename Scalar,
typename VisionMem,
typename RNG>
400 VisionMem dt, RNG rng) {
401 ptr = std::make_shared<VisionMem>(VisionMem(dt));
420 template <
size_t LeafType,
typename ElemType,
typename Scalar,
421 typename VisionMem,
typename RNG>
444 template <
size_t LeafType,
typename ElemType,
typename Scalar,
445 typename VisionMem,
typename RNG>
449 RNG>::create_buffer(ptr, dt, rng);
466 template <
size_t LeafType,
typename ElemType,
typename Scalar,
467 typename VisionMem,
typename RNG>
484 template <
size_t LeafType,
size_t Rows,
size_t Cols,
typename ElemType,
485 typename Scalar,
typename VisionMem>
497 .template get_access<cl::sycl::access::mode::discard_write,
498 cl::sycl::access::target::host_buffer>()
501 memcpy(host_ptr, dt,
sizeof(Scalar) * ElemType::elements * Rows * Cols);
506 template <
size_t Rows,
size_t Cols,
typename ElemType,
typename Scalar,
519 static_assert(
true,
"image is not supported in this version");
525 template <
size_t Rows,
size_t Cols,
typename ElemType,
typename Scalar,
554 template <
size_t LeafType,
size_t Rows,
size_t Cols,
typename ElemType,
555 typename Scalar,
typename VisionMem>
specialisations of SyclMem type when we are passing constant variable to the device.
Series of pixel convert functions.
This file contains the VirtualMemory struct.
this file contains the memory struct used to store {Sycl buffer , Host pointer or Sycl image}.
this file contains a set of forward declarations and include headers required for constructing and ac...
void create_sycl_buffer(std::shared_ptr< VisionMem > &ptr, Scalar *dt, RNG rng)
function create_sycl_buffer
cl::sycl::range< Dim > get_range(size_t r, size_t c)
function get_range
void buffer_update(std::shared_ptr< VisionMem > &ptr, Scalar *dt)
function buffer_update
static constexpr size_t Image
static constexpr size_t Buffer1D
static constexpr size_t Const
static constexpr size_t Host
static constexpr ScopeType Host_Buffer
static constexpr ScopeType Local
static constexpr ScopeType Constant
static constexpr ScopeType Global
static void buffer_update(std::shared_ptr< VisionMem > &ptr, VisionMem dt)
function buffer_update
static void buffer_update(std::shared_ptr< VisionMem > &ptr, Scalar *dt)
This is used to update the Vision Memory with new value update sycl buffer at the moment we use ptr....
static void buffer_update(std::shared_ptr< VisionMem > &ptr, Scalar *dt)
function buffer_update
The definition can be found in ConstMemory.
this struct is used to convert the sycl target to visioncpp target
static void create_buffer(std::shared_ptr< VisionMem > &ptr, VisionMem dt, RNG rng)
function create_buffer
static void create_buffer(std::shared_ptr< VisionMem > &ptr, RNG rng)
function create_buffer
static void create_buffer(std::shared_ptr< VisionMem > &ptr, Scalar *dt, RNG rng)
function create_buffer
This class is used to instantiate the sycl memory based on the memory types.
static void create_buffer(std::shared_ptr< VisionMem > &ptr, Scalar *dt, RNG rng)
function create_buffer
static void create_buffer(std::shared_ptr< VisionMem > &ptr, RNG rng)
function create_buffer
this file is used to create the image properties required to create opencl image for different types ...
this is used to determine the dimension of the memory based on the memory type template parameters:
static constexpr size_t Dim
This file is used to detect the ChannelType ElementCategory {basic or struct}, and the channel size o...
typename ElementTp::data_type ChannelType
OutputMemory is used to deduce the output type of each node in the expression tree by using certain p...
cl::sycl::accessor< typename Properties::access_type, Dim, AccMd, SyclScope< memory_type::Image, scope >::scope > Accessor
typename Properties::access_type access_type
This struct is used to create a sycl accessor type based on access mode; dimension and memory type.
cl::sycl::accessor< ElementType, Dim, AccMd, SyclScope< LeafType, scope >::scope > Accessor
cl::sycl::buffer< ElementType, Dim > Type
cl::sycl::image< Dim > Type
cl::sycl::buffer< ElementType, Dim > Type
cl::sycl::image< Dim > Type
SyclMem is used to create VisionMemory data storage.
static cl::sycl::range< 1 > get_range(size_t r, size_t c)
function get_range
static cl::sycl::range< 2 > get_range(size_t r, size_t c)
function get_range
This is used to determine the range for creating a syclbuffer based on the memory dimension template ...
determines the memory target on the device based on the memory type and suggested target.
Definition of VisionMemory.