|
Orrery
A GPU-accelerated N-body gravitational simulator
|
An owning, movable, cache-line-aligned shared USM allocation. More...
#include <orrery/backend/sycl_usm.hpp>
Public Member Functions | |
| UsmArray () noexcept=default | |
| An empty array, owning nothing. | |
| UsmArray (sycl::queue &queue, std::size_t count) | |
| count default-initialised elements of shared USM from queue's device. | |
| UsmArray (const UsmArray &)=delete | |
| UsmArray & | operator= (const UsmArray &)=delete |
| UsmArray (UsmArray &&other) noexcept | |
| UsmArray & | operator= (UsmArray &&other) noexcept |
| T * | data () const noexcept |
| The pointer, valid in host code and in device code alike. | |
| std::size_t | size () const noexcept |
| bool | empty () const noexcept |
| std::span< T > | span () const noexcept |
An owning, movable, cache-line-aligned shared USM allocation.
The project forbids owning raw pointers (section 4), and sycl::malloc_shared hands back exactly that, paired with a sycl::free that needs the same queue the allocation was made against. This is the RAII wrapper that makes the pair impossible to separate.
Aligned to a cache line for the reason core/aligned_allocator.hpp gives for the host arrays: the kernel reads these as contiguous component arrays, and an allocation that starts mid-line makes every vector load of the first elements straddle two lines. ADR-0005 sets out the argument, which does not stop being true because the reader is a GPU.
|
inline |
count default-initialised elements of shared USM from queue's device.
Throws std::bad_alloc when the runtime cannot satisfy the request, which is a setup-boundary failure of the kind section 4 permits exceptions at. No kernel is on the stack at this point.
|
inlinenodiscardnoexcept |
The pointer, valid in host code and in device code alike.
This is the property the whole file is about. The value returned here is what a kernel captures, and it is the same number the host dereferences.