Owning, growable array of T in USM shared memory (sycl::malloc_shared).
The storage is allocated in the shared context of Device::default_device(), so it is readable and writable from the host and from that device. Copying deep-copies on the host; moving transfers ownership. Converts implicitly to Span<T>, which is how it is passed to entry points. Growth reallocates, so any Span or pointer taken earlier is invalidated.
| T | element type (trivially copyable: growth uses memcpy) |
Definition at line 22 of file sycl-vector.hh.
#include <batchlas/util/sycl-vector.hh>
| using batchlas::UnifiedVector< T >::value_type = T |
Element type.
Definition at line 24 of file sycl-vector.hh.
| using batchlas::UnifiedVector< T >::pointer = T* |
Pointer to an element.
Definition at line 25 of file sycl-vector.hh.
| using batchlas::UnifiedVector< T >::size_t = std::size_t |
Size and index type.
Definition at line 26 of file sycl-vector.hh.
| batchlas::UnifiedVector< T >::UnifiedVector | ( | size_t | size | ) |
Allocates size uninitialised elements.
| std::bad_alloc | if the allocation fails |
| batchlas::UnifiedVector< T >::UnifiedVector | ( | size_t | size, |
| T | value ) |
Allocates size elements set to value (filled on the host).
| batchlas::UnifiedVector< T >::UnifiedVector | ( | const UnifiedVector< T > & | other | ) |
Deep copy of other's first size() elements into a new allocation.
| batchlas::UnifiedVector< T >::~UnifiedVector | ( | ) |
Frees the allocation; never throws, even if the runtime reports an earlier async error.
|
inline |
An empty vector with no allocation.
Definition at line 59 of file sycl-vector.hh.
|
inline |
Takes other's allocation and leaves other empty.
Definition at line 61 of file sycl-vector.hh.
| UnifiedVector< T > & batchlas::UnifiedVector< T >::operator= | ( | const UnifiedVector< T > & | other | ) |
Deep copy of other's elements; reallocates only when this capacity is smaller.
Trivially copyable T is copied with a device memcpy that is waited on.
| void batchlas::UnifiedVector< T >::resize | ( | size_t | new_size | ) |
Sets the size; reallocates (keeping the contents) only when new_size exceeds the capacity.
| void batchlas::UnifiedVector< T >::resize | ( | size_t | new_size, |
| T | value ) |
Grows to new_size, setting the new elements to value.
new_size exceeds the capacity: it neither shrinks nor grows within the existing capacity (unlike the one-argument resize()). | void batchlas::UnifiedVector< T >::resize | ( | size_t | new_size, |
| size_t | front, | ||
| size_t | back, | ||
| size_t | seg_size ) |
Grows a ring buffer to new_size, unrolling its live segment to the front.
The live data starts at front and ends with the seg_size elements at back, wrapping when back < front. After the call it is contiguous from index 0 and the rest is value-initialised. No-op unless new_size exceeds the capacity.
| void batchlas::UnifiedVector< T >::reserve | ( | size_t | new_capacity | ) |
Ensures a capacity of at least new_capacity, keeping the contents and the size.
|
inline |
Frees this vector's allocation, takes other's and leaves other empty.
Definition at line 67 of file sycl-vector.hh.
|
inlineconstexpr |
A Span over the first size() elements.
Definition at line 80 of file sycl-vector.hh.
|
inlineconstexpr |
A Span over the first size() elements.
Definition at line 82 of file sycl-vector.hh.
|
inlineconstexpr |
A Span over elements [offset, offset + count); not bounds-checked.
Definition at line 84 of file sycl-vector.hh.
|
inlineconstexpr |
A Span over elements [offset, size()).
Definition at line 86 of file sycl-vector.hh.
|
inlineconstexpr |
Sets every element to data, on the host.
Definition at line 88 of file sycl-vector.hh.
|
inlineconstexpr |
Pointer to the first element (null when never allocated).
Definition at line 89 of file sycl-vector.hh.
|
inlineconstexpr |
Number of elements.
Definition at line 90 of file sycl-vector.hh.
|
inlineconstexpr |
Allocated elements.
Definition at line 91 of file sycl-vector.hh.
|
inlineconstexpr |
Sets the size to 0 and keeps the allocation.
Definition at line 95 of file sycl-vector.hh.
|
inlineconstexpr |
Element index; prints and asserts (debug build) when out of range.
Definition at line 98 of file sycl-vector.hh.
|
inlineconstexpr |
Element index (const); same checks as the non-const overload.
Definition at line 100 of file sycl-vector.hh.
|
inlineconstexpr |
Element index.
Definition at line 103 of file sycl-vector.hh.
|
inlineconstexpr |
|
inlineconstexpr |
Element-wise comparison with Span::operator== semantics.
Definition at line 108 of file sycl-vector.hh.
|
inlineconstexpr |
Appends value, doubling the capacity when full (which invalidates earlier Spans).
Definition at line 113 of file sycl-vector.hh.
|
inlineconstexpr |
Appends value by move; growth as for the copying overload.
Definition at line 122 of file sycl-vector.hh.
|
inlineconstexpr |
Removes and returns the last element; keeps the capacity.
Definition at line 132 of file sycl-vector.hh.
|
inlineconstexpr |
Iterator to the first element.
Definition at line 138 of file sycl-vector.hh.
|
inlineconstexpr |
Iterator one past the last element.
Definition at line 139 of file sycl-vector.hh.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Exchanges storage, size and capacity with other; no element is copied.
Definition at line 145 of file sycl-vector.hh.