1 #ifndef LOADABLE_BUFFER_HPP
2 #define LOADABLE_BUFFER_HPP
11 template<
typename T,
class Device>
27 template<
class V,
class... TRest>
29 return first.size() +
size_sum(args...);
55 void load(V view,
bool do_copy){
56 int size_of_view = view.size();
57 View<T*, CLayout, Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>> offset_buffer(
buffer.data() +
offset, size_of_view);
58 View<T*, CLayout, typename V::device_type, Kokkos::MemoryTraits<Kokkos::Unmanaged>> unmanaged_view(view.data(), size_of_view);
60 if(do_copy) Kokkos::deep_copy(offset_buffer, unmanaged_view);
70 int size_of_view = view.size();
72 View<T*, CLayout, Device, Kokkos::MemoryTraits<Kokkos::Unmanaged>> offset_buffer(
buffer.data() +
offset, size_of_view);
73 View<T*, CLayout, typename V::device_type, Kokkos::MemoryTraits<Kokkos::Unmanaged>> unmanaged_view(view.data(), size_of_view);
75 if(do_copy) Kokkos::deep_copy(unmanaged_view, offset_buffer);
LoadableBuffer(Vs...views)
Definition: loadable_buffer.hpp:45
View< T *, CLayout, Device > buffer
The buffer allocation.
Definition: loadable_buffer.hpp:13
void load(V view, bool do_copy)
Definition: loadable_buffer.hpp:55
int offset
Tracks where the most recently loaded View ended in the buffer.
Definition: loadable_buffer.hpp:14
int size_sum(V first)
Definition: loadable_buffer.hpp:20
Definition: loadable_buffer.hpp:12
void unload(V view, bool do_copy)
Definition: loadable_buffer.hpp:69
T * data()
Definition: loadable_buffer.hpp:86
int size_sum(V first, TRest...args)
Definition: loadable_buffer.hpp:28
int size()
Definition: loadable_buffer.hpp:80
LoadableBuffer(int size)
Definition: loadable_buffer.hpp:36