58 case DeviceBackend::CUDA:
76 return DeviceBackend::CUDA;
81 class DeviceStorageBase;
119 [[nodiscard]]
virtual size_t bytes()
const = 0;
126 template <DeviceBackend B>
132 template <DeviceBackend B>
170 case DeviceBackend::CUDA:
Core type aliases, constants, and metaprogramming utilities for the DNDS framework.
Assertion / error-handling macros and supporting helper functions.
#define DNDS_assert_info(expr, info)
Debug-only assertion with an extra std::string info message.
Abstract interface to a byte buffer owned by a specific backend.
virtual DeviceBackend backend() const =0
Which backend the buffer lives on.
virtual void copy_to_device(uint8_t *device_ptr_dst, size_t n_bytes)=0
Device-to-device copy of n_bytes into device_ptr_dst.
virtual uint8_t * raw_ptr()=0
Raw byte pointer to the underlying storage.
virtual size_t bytes() const =0
Buffer size in bytes.
virtual ~DeviceStorageBase()
virtual void copy_device_to_host(uint8_t *host_ptr, size_t n_bytes)=0
Copy n_bytes from this device buffer into host_ptr.
virtual void copy_host_to_device(uint8_t *host_ptr, size_t n_bytes)=0
Copy n_bytes from host_ptr into this device buffer.
Compile-time-specialised storage class; one definition per DeviceBackend.
the host side operators are provided as implemented
void deviceStorageBase_deleter(DeviceStorageBase *p)
Stateless deleter for DeviceStorageBase that works across shared-library boundaries where the vtable ...
t_supDeviceStorageBase device_storage_create(DeviceBackend backend, size_t n_bytes)
Top-level factory: dispatches to the per-backend factory based on backend. Returns a null unique_ptr ...
DeviceBackend
Enumerates the backends a DeviceStorage / Array can live on.
@ Unknown
Unset / sentinel.
@ Custom1
Reserved slot for a project-specific backend.
const char * device_backend_name(DeviceBackend B)
Canonical string name for a DeviceBackend (used in log messages).
DeviceBackend device_backend_name_to_enum(std::string_view s)
Inverse of device_backend_name. Returns Unknown for unrecognised names.
std::unique_ptr< DeviceStorageBase, std::function< void(DeviceStorageBase *)> > t_supDeviceStorageBase
Owning unique pointer to a DeviceStorageBase with cross-DLL-safe deleter.
t_supDeviceStorageBase null_supDeviceStorageBase()
Null-value helper for t_supDeviceStorageBase.
std::shared_ptr< DeviceStorageBase > t_sspDeviceStorageBase
Shared pointer equivalent of t_supDeviceStorageBase.
Factory functions for constructing DeviceStorageBase instances of a specific backend....
static t_supDeviceStorageBase device_storage_create_unique(DeviceBackend backend, size_t n_bytes)
static t_sspDeviceStorageBase device_storage_create_shared(DeviceBackend backend, size_t n_bytes)