10 #include "kalmar_runtime.h" 11 #include "kalmar_serialize.h" 21 _data(
int count) : p_(nullptr) {}
22 _data(
const _data& d) restrict(cpu, amp)
24 _data(
int count,
void* d) restrict(cpu, amp)
25 : p_(static_cast<T*>(d)) {}
27 _data(
const _data<U>& d) restrict(cpu, amp)
28 : p_(reinterpret_cast<T *>(d.get())) {}
29 __attribute__((annotate(
"user_deserialize")))
30 explicit _data(T* t) restrict(cpu, amp) { p_ = t; }
31 T*
get(void)
const restrict(cpu, amp) {
return p_; }
32 T* get_device_pointer() const restrict(cpu, amp) {
return p_; }
33 std::shared_ptr<KalmarQueue> get_av()
const {
return nullptr; }
36 T* map_ptr(
bool modify,
size_t count,
size_t offset)
const {
return nullptr; }
37 void unmap_ptr(
const void* addr,
bool modify,
size_t count,
size_t offset)
const {}
38 void synchronize(
bool modify =
false)
const {}
39 void get_cpu_access(
bool modify =
false)
const {}
40 void copy(_data<T> other,
int,
int,
int)
const {}
41 void write(
const T*,
int ,
int offset = 0,
bool blocking =
false)
const {}
42 void read(T*,
int ,
int offset = 0)
const {}
43 void refresh()
const {}
44 void set_const()
const {}
45 access_type get_access()
const {
return access_type_auto; }
46 std::shared_ptr<KalmarQueue> get_stage()
const {
return nullptr; }
54 mutable std::shared_ptr<rw_info> mm;
56 template <
typename U>
friend class _data_host;
58 _data_host(
size_t count,
const void* src =
nullptr)
59 : mm(
std::make_shared<rw_info>(count*sizeof(T), const_cast<void*>(src))),
62 _data_host(std::shared_ptr<KalmarQueue> av, std::shared_ptr<KalmarQueue> stage,
int count,
64 : mm(
std::make_shared<rw_info>(av, stage, count*sizeof(T), mode)), isArray(true) {}
66 _data_host(std::shared_ptr<KalmarQueue> av, std::shared_ptr<KalmarQueue> stage,
int count,
67 void* device_pointer, access_type mode)
68 : mm(
std::make_shared<rw_info>(av, stage, count*sizeof(T), device_pointer, mode)), isArray(true) {}
70 _data_host(
const _data_host& other) : mm(other.mm), isArray(false) {}
73 _data_host(
const _data_host<U>& other) : mm(other.mm), isArray(false) {}
75 T *
get()
const {
return static_cast<T*
>(mm->data); }
76 T* get_device_pointer()
const {
return static_cast<T*
>(mm->get_device_pointer()); }
77 void synchronize(
bool modify =
false)
const { mm->synchronize(modify); }
78 void discard()
const { mm->disc(); }
79 void refresh()
const {}
80 size_t size()
const {
return mm->count; }
81 void reset()
const { mm.reset(); }
82 void get_cpu_access(
bool modify =
false)
const { mm->get_cpu_access(modify); }
83 std::shared_ptr<KalmarQueue> get_av()
const {
return mm->master; }
84 std::shared_ptr<KalmarQueue> get_stage()
const {
return mm->stage; }
85 access_type get_access()
const {
return mm->mode; }
86 void copy(_data_host<T> other,
int src_offset,
int dst_offset,
int size)
const {
87 mm->copy(other.mm.get(), src_offset *
sizeof(T), dst_offset *
sizeof(T), size *
sizeof(T));
89 void write(
const T* src,
int size,
int offset = 0,
bool blocking =
false)
const {
90 mm->write(src, size *
sizeof(T), offset *
sizeof(T), blocking);
92 void read(T* dst,
int size,
int offset = 0)
const {
93 mm->read(dst, size *
sizeof(T), offset *
sizeof(T));
95 T* map_ptr(
bool modify,
size_t count,
size_t offset)
const {
96 return (T*)mm->map(count *
sizeof(T), offset *
sizeof(T), modify);
98 void unmap_ptr(
const void* addr,
bool modify,
size_t count,
size_t offset)
const {
return mm->unmap(const_cast<void*>(addr), count *
sizeof(T), offset *
sizeof(T), modify); }
99 void sync_to(std::shared_ptr<KalmarQueue> pQueue)
const { mm->sync(pQueue,
false); }
101 __attribute__((annotate(
"serialize")))
102 void __cxxamp_serialize(Serialize& s)
const {
103 s.visit_buffer(mm.get(), !std::is_const<T>::value, isArray);
105 __attribute__((annotate(
"user_deserialize")))
106 explicit _data_host(typename
std::remove_const<T>::type* t) {}
void copy(const array_view< const T, N > &src, const array_view< T, N > &dest)
The contents of "src" are copied into "dest".
Definition: amp.h:4979
namespace for internal classes of Kalmar compiler / runtime
Definition: hc.hpp:42