rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
Loading...
Searching...
No Matches
device_manager.hpp
1// SPDX-License-Identifier: GPL-3.0-only
2
3#pragma once
4
5#include "device_index.hpp"
6#include "device_properties.hpp"
7#include "device_backend.hpp"
8#include "../service_manager.hpp"
9#include "../platform/dynamic_shared_object.h"
10
11#include <string>
12
13#include <memory>
14#include <vector>
15
16namespace rexlib
17{
18
19class device;
20class device_session;
21
32class REXLIB_API device_manager final
33 : public service_manager
34{
35public:
37 device_manager(const device_manager &other) = delete;
38 device_manager(device_manager &&other) noexcept = delete;
39 ~device_manager() override;
40
41 device_manager& operator=(const device_manager &other) = delete;
42 device_manager& operator=(device_manager &&other) = delete;
43
45
52 void enumerate_backends(std::vector<std::string> &names) const;
53
61 device_backend* get_backend(const std::string &name) const;
62
80 bool register_backend(std::unique_ptr<device_backend> backend);
81
94 void enumerate_devices(std::vector<device_index> &indices) const;
95
112 const device_index &index,
113 device_properties &properties
114 ) const;
115
134 std::shared_ptr<device_session>
136
137private:
138 class implementation;
139 REXLIB_STD_MEMBER_INTERFACE
140 std::unique_ptr<implementation> m_implementation;
141
142 void create_implementation_if_null();
143};
144
145} // namespace rexlib
Abstract class that represents a hardware backend.
Definition device_backend.hpp:34
Location of a device as a (backend, id) tuple.
Definition device_index.hpp:25
Centralize multiple device_backend sessions and route device queries to the appropriate one.
Definition device_manager.hpp:34
void register_builtin_backends() override
Register backends bundled with the core library.
bool get_device_properties(const device_index &index, device_properties &properties) const
Query the properties of a device.
device_backend * get_backend(const std::string &name) const
Get a backend contained in this manager by its name.
std::shared_ptr< device_session > create_device_session(const device_index &index) const
Create a device session.
bool register_backend(std::unique_ptr< device_backend > backend)
Register a new backend.
void enumerate_backends(std::vector< std::string > &names) const
Enumerate the names of all registered backends.
void enumerate_devices(std::vector< device_index > &indices) const
Enumerate devices across all registered backends.
Description of the static characteristics of a physical device visible from the host.
Definition device_properties.hpp:27
Abstract class defining the interface of a service manager.
Definition service_manager.hpp:23
Arrays, the operations on them and the devices that run those operations.
Definition cpu_device.hpp:10
@ device
The memory resource can be optimally accessed by the device.