3 #ifndef _PINNED_VECTOR_H 4 #define _PINNED_VECTOR_H 24 T* allocate(std::size_t n) {
26 auto p =
static_cast<T*
>(
hc::am_alloc(n*
sizeof(T), acc, amHostPinned));
27 if(p ==
nullptr){
throw std::bad_alloc(); }
31 void deallocate(T* p, std::size_t) {
39 template <
class T,
class U>
42 template <
class T,
class U>
48 using pinned_vector = std::vector<T, am_allocator<T>>;
52 #endif // _PINNED_VECTOR_H Heterogeneous C++ (HC) API.
auto_voidp am_alloc(std::size_t size, hc::accelerator &acc, unsigned flags)
Allocate a block of size bytes of memory on the specified acc.
Definition: pinned_vector.hpp:17
am_status_t am_free(void *ptr)
Free a block of memory previously allocated with am_alloc.
Heterogeneous C++ (HC) namespace.
Definition: grid_launch.h:10
Represents a physical accelerated computing device.
Definition: hc.hpp:700