rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
Loading...
Searching...
No Matches
Public Member Functions | List of all members
rexlib::device_backend Class Referenceabstract

Abstract class that represents a hardware backend. More...

#include <rexlib/core/hardware/device_backend.hpp>

Public Member Functions

 device_backend (const device_backend &other)=delete
 
 device_backend (device_backend &&other)=delete
 
device_backend & operator= (const device_backend &other)=delete
 
device_backend & operator= (device_backend &&other)=delete
 
virtual std::string get_name () const =0
 Get the name of the backend.
 
virtual version get_version () const =0
 Get the version of the backend.
 
virtual void enumerate_devices (std::vector< std::size_t > &ids) const =0
 Enumerate available devices for this backend.
 
virtual bool get_device_properties (std::size_t id, device_properties &desc) const =0
 Query the static properties of a device.
 
virtual std::shared_ptr< device > create_device (std::size_t id) const =0
 Create a device handle for the given device identifier.
 

Detailed Description

Abstract class that represents a hardware backend.

A device_backend is the integration point through which a family of physical or virtual compute devices (e.g. the host CPU, a vendor's GPUs) is exposed to the rest of the framework. Concrete backends are typically shipped as plugins and registered into a device_manager, which dispatches queries to the appropriate backend based on its name.

The interface intentionally remains small: enumerating the devices that the backend can see at runtime, exposing their static characteristics via device_properties, and instantiating a usable device handle on demand. Backends are non-copyable and non-movable; they are meant to live behind a stable pointer owned by the device_manager.

Member Function Documentation

◆ create_device()

virtual std::shared_ptr< device > rexlib::device_backend::create_device ( std::size_t  id) const
pure virtual

Create a device handle for the given device identifier.

Instantiates a ready-to-use device object backed by the physical device referred to by id. Each call returns a fresh handle; backends are free to share underlying driver state between handles but must guarantee that the returned object can be used independently from any previous one.

Parameters
[in]idThe identifier of the device, as returned by enumerate_devices.
Returns
std::shared_ptr<device> A non-null handle to the device. Backends are expected to throw if id is not valid rather than returning a null pointer.

◆ enumerate_devices()

virtual void rexlib::device_backend::enumerate_devices ( std::vector< std::size_t > &  ids) const
pure virtual

Enumerate available devices for this backend.

Populates ids with an identifier for every device that this backend can currently make available. The list is expected to be cleared by the implementation before being filled.

Parameters
[out]idsOutput parameter receiving the device identifiers.
Note
The IDs are opaque to the caller and only guaranteed to be unique within this backend; combine them with the backend name (via device_index) to obtain a globally unique identifier.
The set of IDs and their ordering are implementation defined and may change across runs (e.g. if hardware is hot-plugged or the driver reorders devices), so callers should treat the IDs as transient tokens valid for the lifetime of the backend instance.

◆ get_device_properties()

virtual bool rexlib::device_backend::get_device_properties ( std::size_t  id,
device_properties &  desc 
) const
pure virtual

Query the static properties of a device.

Fills desc with descriptive information about the device that is not expected to change while the backend is alive (name, kind, total memory, etc.). This method does not allocate or initialize any device-side resources; use create_device for that.

Parameters
[in]idIdentifier of the device, as returned by enumerate_devices.
[out]descOutput properties. Only modified when the call succeeds.
Returns
true The device ID exists and desc has been populated.
false The device ID is not known to this backend; desc is left untouched.

◆ get_name()

virtual std::string rexlib::device_backend::get_name ( ) const
pure virtual

Get the name of the backend.

Returns
std::string The name.

◆ get_version()

virtual version rexlib::device_backend::get_version ( ) const
pure virtual

Get the version of the backend.

Returns
version The version.

The documentation for this class was generated from the following file: