|
HAMR
The Heterogeneous Accelerator Memory Resource
|
4 #include "hamr_config.h"
10 #include <type_traits>
109 transfer sync,
size_t n_elem,
const T &val);
155 transfer sync,
size_t n_elem,
const T *vals);
210 template <
typename delete_func_t>
212 size_t size,
int owner, T *ptr, delete_func_t df);
233 template <
typename delete_func_t>
235 int owner, T *ptr, delete_func_t df)
258 template <
typename delete_func_t>
286 transfer sync,
size_t size,
int owner, T *ptr,
int take = 1);
353 size_t size,
int owner,
const std::shared_ptr<T> &
data);
373 size_t size,
int owner,
const std::shared_ptr<T> &
data)
398 template <
typename U>
413 template <
typename U>
425 template <
typename U>
441 template <
typename U>
443 buffer(alloc, other.m_stream, other.m_sync, other) {}
490 buffer(alloc, other.m_stream, other.m_sync, std::move(other)) {}
508 template <
typename U>
524 int move(allocator alloc);
531 int reserve(
size_t n_elem);
534 int reserve(
size_t n_elem,
const T &val);
542 int resize(
size_t n_elem);
546 int resize(
size_t n_elem,
const T &val);
553 size_t size()
const {
return m_size; }
561 int assign(
const U *src,
size_t src_start,
size_t n_vals);
565 int assign(
const buffer<U> &src,
size_t src_start,
size_t n_vals);
580 template <
typename U>
581 int append(
const U *src,
size_t src_start,
size_t n_vals);
586 template <
typename U>
587 int append(
const buffer<U> &src,
size_t src_start,
size_t n_vals);
591 template <
typename U>
602 template <
typename U>
603 int set(
size_t dest_start,
const U *src,
size_t src_start,
size_t n_vals);
607 template <
typename U>
610 return this->set(0, src, 0, src.
size());
615 template <
typename U>
616 int set(
size_t dest_start,
const buffer<U> &src,
size_t src_start,
size_t n_vals);
626 template <
typename U>
627 int get(
size_t src_start, U *dest,
size_t dest_start,
size_t n_vals)
const;
631 template <
typename U>
632 int get(
size_t src_start,
buffer<U> &dest,
size_t dest_start,
size_t n_vals)
const;
636 template <
typename U>
639 return this->get(0, dest, 0, this->size());
721 int device_accessible()
const;
731 T *
data() {
return m_data.get(); }
734 const T *
data()
const {
return m_data.get(); }
745 std::shared_ptr<T> &
pointer() {
return m_data; }
748 const std::shared_ptr<T> &
pointer()
const {
return m_data; }
802 int reserve_for_append(
size_t n_vals);
805 std::shared_ptr<T> allocate(
size_t n_elem);
808 std::shared_ptr<T> allocate(
size_t n_elem,
const T &val);
811 template <
typename U>
812 std::shared_ptr<T> allocate(
size_t n_elem,
const U *vals);
815 template <
typename U>
816 std::shared_ptr<T> allocate(
const buffer<U> &vals);
826 int set_owner(
const T *ptr);
833 std::shared_ptr<T> m_data;
840 template<
typename U>
friend class buffer;
845 #if !defined(HAMR_SEPARATE_IMPL)
846 #include "hamr_buffer_impl.h"
const T * data() const
return a const pointer to the buffer contents
Definition: hamr_buffer.h:734
std::shared_ptr< T > & pointer()
Definition: hamr_buffer.h:745
@ sync_host
operations moving data from GPU to host memory are synchronous
void set_stream(const stream &strm, transfer sync=transfer::async)
Definition: hamr_buffer.h:768
buffer(allocator alloc)
Definition: hamr_buffer.h:60
buffer(allocator alloc, size_t size, int owner, const std::shared_ptr< T > &data)
Definition: hamr_buffer.h:394
transfer get_transfer_mode() const
Definition: hamr_buffer.h:790
buffer(allocator alloc, const hamr::stream &strm, size_t n_elem)
Definition: hamr_buffer.h:81
buffer(allocator alloc, const hamr::stream &strm, size_t n_elem, const T &val)
Definition: hamr_buffer.h:121
void synchronize(PP &&... args)
Definition: hamr_buffer_util.h:174
buffer(allocator alloc, size_t size, int owner, T *ptr, delete_func_t df)
Definition: hamr_buffer.h:259
buffer(allocator alloc, size_t n_elem)
Definition: hamr_buffer.h:93
buffer(allocator alloc, const hamr::stream &strm, size_t size, int owner, T *ptr, delete_func_t df)
Definition: hamr_buffer.h:234
T * data()
Definition: hamr_buffer.h:731
buffer(allocator alloc, const hamr::stream &strm, size_t size, int owner, T *ptr)
Definition: hamr_buffer.h:308
auto get_host_accessible(const TT &b, PP &&... args)
Definition: hamr_buffer_util.h:29
buffer(allocator alloc, size_t n_elem, const T *vals)
Definition: hamr_buffer.h:187
A wrapper around technology specific streams.
Definition: hamr_stream.h:35
buffer(allocator alloc, buffer< T > &&other)
Definition: hamr_buffer.h:489
buffer(allocator alloc, const hamr::stream &strm, size_t n_elem, const T *vals)
Definition: hamr_buffer.h:170
buffer_transfer
Definition: hamr_buffer_transfer.h:13
int get_owner() const
Definition: hamr_buffer.h:755
size_t size() const
returns the number of elements of storage allocated to the buffer
Definition: hamr_buffer.h:553
const hamr::stream & get_stream() const
Definition: hamr_buffer.h:758
HAMR_EXPORT int openmp_accessible(buffer_allocator alloc)
Definition: hamr_buffer_allocator.h:72
buffer(allocator alloc, const hamr::stream &strm, buffer< T > &&other)
Definition: hamr_buffer.h:474
buffer(allocator alloc, const buffer< U > &other)
Definition: hamr_buffer.h:442
int HAMR_EXPORT get_active_device(int &dev_id)
gets the currently atcive device.
Definition: hamr_device.h:48
void set_transfer_sycnhronous()
Definition: hamr_buffer.h:787
auto get_hip_accessible(const TT &b, PP &&... args)
Definition: hamr_buffer_util.h:81
@ sync
all operations are synchronous
HAMR_EXPORT int host_accessible(buffer_allocator alloc)
Definition: hamr_buffer_allocator.h:35
A technology agnostic buffer that manages memory on the host, GPUs, and other accelerators.
Definition: hamr_buffer.h:30
auto get_cuda_accessible(const TT &b, PP &&... args)
Definition: hamr_buffer_util.h:55
int set(const buffer< U > &src)
Definition: hamr_buffer.h:608
heterogeneous accelerator memory resource
Definition: hamr_buffer.h:13
buffer(allocator alloc, const hamr::stream &strm, size_t size, int owner, const std::shared_ptr< T > &data)
Definition: hamr_buffer.h:372
buffer(allocator alloc, const hamr::stream &strm, const buffer< U > &other)
Definition: hamr_buffer.h:426
HAMR_EXPORT int cuda_accessible(buffer_allocator alloc)
Definition: hamr_buffer_allocator.h:47
HAMR_EXPORT int hip_accessible(buffer_allocator alloc)
Definition: hamr_buffer_allocator.h:60
const std::shared_ptr< T > & pointer() const
Definition: hamr_buffer.h:748
allocator get_allocator() const
Definition: hamr_buffer.h:752
void set_transfer_sycnhronous_host()
Definition: hamr_buffer.h:782
auto get_openmp_accessible(const TT &b, PP &&... args)
Definition: hamr_buffer_util.h:107
buffer(allocator alloc, size_t size, int owner, T *ptr)
Definition: hamr_buffer.h:331
@ async
all operations are asynchronous
void set_transfer_asynchronous()
Definition: hamr_buffer.h:777
buffer_allocator
allocator types that may be used with hamr::buffer
Definition: hamr_buffer_allocator.h:13
buffer(allocator alloc, size_t n_elem, const T &val)
Definition: hamr_buffer.h:136
auto get_device_accessible(const TT &b, PP &&... args)
Definition: hamr_buffer_util.h:133
auto data(PP &&... args)
Definition: hamr_buffer_util.h:148
int get(buffer< U > &dest) const
Definition: hamr_buffer.h:637