20class DeviceSynchronizedList
24 : mBuffer(buffer.Raw()), mSize(size.Raw()), mCapacity(buffer.Size())
28 PBAT_DEVICE
bool Append(T
const& value)
30 cuda::atomic_ref<GpuIndex, cuda::thread_scope_device> aSize{*mSize};
34 aSize.store(mCapacity);
41 PBAT_DEVICE T& operator[](
auto i)
48 PBAT_DEVICE T
const& operator[](
auto i)
const
58 std::size_t mCapacity;
65 SynchronizedList(std::size_t capacity) : mBuffer(capacity), mSize{0} {}
67 std::vector<T> Get()
const {
return mBuffer.Get(mSize.Get()); }
68 void Clear() { mSize = 0; }
69 std::size_t Capacity()
const {
return mBuffer.Size(); }
71 Buffer<T> const& Memory()
const {
return mBuffer; }
72 GpuIndex Size()
const {
return mSize.Get(); }
75 if ((size < 0) or (size > mBuffer.Size()))
77 std::string
const what =
"Resize called with size outside of range [0,buffer capacity]";
78 throw std::invalid_argument(what);
82 auto Begin() {
return mBuffer.Data(); }
83 auto End() {
return mBuffer.Data() + mSize.Get(); }