|
rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
|
Centralize multiple device_backend sessions and route device queries to the appropriate one. More...
#include <rexlib/core/hardware/device_manager.hpp>
Public Member Functions | |
| device_manager (const device_manager &other)=delete | |
| device_manager (device_manager &&other) noexcept=delete | |
| device_manager & | operator= (const device_manager &other)=delete |
| device_manager & | operator= (device_manager &&other)=delete |
| void | register_builtin_backends () override |
| Register backends bundled with the core library. | |
| void | enumerate_backends (std::vector< std::string > &names) const |
| Enumerate the names of all registered backends. | |
| device_backend * | get_backend (const std::string &name) const |
| Get a backend contained in this manager by its name. | |
| bool | register_backend (std::unique_ptr< device_backend > backend) |
| Register a new backend. | |
| void | enumerate_devices (std::vector< device_index > &indices) const |
| Enumerate devices across all registered backends. | |
| bool | get_device_properties (const device_index &index, device_properties &properties) const |
| Query the properties of a device. | |
| std::shared_ptr< device_session > | create_device_session (const device_index &index) const |
| Create a device session. | |
Public Member Functions inherited from rexlib::service_manager | |
| service_manager (const service_manager &other)=delete | |
| service_manager (service_manager &&other)=delete | |
| service_manager & | operator= (const service_manager &other)=delete |
| service_manager & | operator= (service_manager &&other)=delete |
Centralize multiple device_backend sessions and route device queries to the appropriate one.
The manager owns the registered backends and exposes a unified view of all devices known to the framework, identified across backends by device_index. Backends are typically contributed by plugins at load time via register_backend, with register_builtin_backends adding those that are statically linked.
| std::shared_ptr< device_session > rexlib::device_manager::create_device_session | ( | const device_index & | index | ) | const |
Create a device session.
Resolves the backend named by index, delegates the actual device instantiation to device_backend::create_device and queries its device_properties, then bundles both into a device_session (which also selects the default allocators for the device).
Instances are not cached: each call returns a freshly created device_session.
| [in] | index | Index identifying the target device. |
| std::invalid_argument | If no backend is registered under the name carried by index, or if the backend does not recognize the device id. The backend may additionally throw if the device id is invalid. |
| void rexlib::device_manager::enumerate_backends | ( | std::vector< std::string > & | names | ) | const |
Enumerate the names of all registered backends.
| [out] | names | Output parameter with the names of the contained backends. Cleared before being populated. |
| void rexlib::device_manager::enumerate_devices | ( | std::vector< device_index > & | indices | ) | const |
Enumerate devices across all registered backends.
Asks every registered backend to enumerate its devices and aggregates the results into indices. The relative order of backends in the output is implementation defined; within a single backend the order matches whatever device_backend::enumerate_devices reports.
| [out] | indices | Output list of device indices. Cleared before being populated, so existing contents are discarded. |
| device_backend * rexlib::device_manager::get_backend | ( | const std::string & | name | ) | const |
Get a backend contained in this manager by its name.
| name | The name of the backend. |
| bool rexlib::device_manager::get_device_properties | ( | const device_index & | index, |
| device_properties & | properties | ||
| ) | const |
Query the properties of a device.
Looks up the backend named by index and forwards the query to device_backend::get_device_properties. Fails if the backend is not registered or if the backend itself does not recognize the device id.
| [in] | index | Index identifying the target device. |
| [out] | properties | Output device properties. Only modified when the call succeeds. |
properties has been written. index does not exist; properties is left untouched. | bool rexlib::device_manager::register_backend | ( | std::unique_ptr< device_backend > | backend | ) |
Register a new backend.
Takes ownership of backend and keeps it alive for the rest of the manager's lifetime, indexed by the name it reports through device_backend::get_name. Registration fails if another backend with the same name is already registered or if backend is null; on failure, ownership of backend remains with the caller (the unique_ptr is not consumed) and the manager state is unchanged.
| [in] | backend | The backend to be registered. Must be non-null for registration to succeed. |
backend was null; the manager is left unchanged.
|
overridevirtual |
Register backends bundled with the core library.
This usually loads fallback implementations that are always available although they may not be the most efficient or performant. The loaded backend(s) depend on the implementation of the specific interface.
Reimplemented from rexlib::service_manager.