rexlib is a device-agnostic array computing library with a pluggable backend architecture. It provides ND-arrays, operation dispatch and execution services, and backend loading for hardware-specific implementations.
The C++ API reference is generated from the public headers under include/rexlib/.
Highlights
- Device-agnostic execution model. Operations are dispatched through services and execution contexts instead of being tied to one device API.
- Pluggable backends. A backend plugin is a shared object exporting
rexlib_get_plugin, loaded by the core plugin system.
- Public headers as contract. The public interface is the headers in
include/rexlib/, documented directly in the C++ reference.
- C++14 public surface. Public headers are consumable from C++14.
Components
core: operation model, dispatch, hardware abstraction, plugin loading, layouts and numerical infrastructure.
ops: operation declarations.
functional: user-facing functions that reach operation declarations.
em: CryoEM and CryoET operations and functions in rexlib::em.
backends/cpu: the CPU backend implementation.
Image I/O is out of scope for rexlib and lives in vitrio.
Using it from CMake
find_package(rexlib REQUIRED)
target_link_libraries(my_program PRIVATE rexlib::rexlib)
Minimal C++ example
#include <rexlib/core/dispatch/dispatcher.hpp>
#include <rexlib/core/dispatch/execution_context.hpp>
#include <rexlib/core/dispatch/program_manager.hpp>
#include <rexlib/core/hardware/buffer.hpp>
#include <rexlib/core/hardware/device_context.hpp>
#include <rexlib/core/hardware/device_index.hpp>
#include <rexlib/core/hardware/device_manager.hpp>
#include <rexlib/core/hardware/memory_resource_affinity.hpp>
#include <rexlib/core/library_version.hpp>
#include <rexlib/core/numerical/numerical_type.hpp>
#include <rexlib/core/service_catalog.hpp>
#include <rexlib/functional/creation.hpp>
#include <cstdint>
#include <iostream>
int main()
{
const auto devices =
const auto programs =
),
)
5,
rexlib::numerical_type::int32,
context
)
const auto *values = static_cast<const std::int32_t*>(
result.get_storage()->get_host_ptr()
)
for (std::int32_t i = 0
i < 5
++i)
{
if (values[i] != i)
{
return 1
}
}
return 0
}
Scoped, configurable view over a device_session.
Definition device_context.hpp:49
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
Pairs the hardware resources and the dispatch strategy used to run operations.
Definition execution_context.hpp:43
Centralizes all known instances of operation program builders.
Definition program_manager.hpp:32
Stores a single instance of each type service_manager.
Definition service_catalog.hpp:23
std::shared_ptr< T > get_service_manager()
Retrieve the unique instance of a concrete service_manager.
@ host
The memory resource can be optimally accessed by the host.
std::shared_ptr< dispatcher > make_eager_dispatcher(std::shared_ptr< const program_manager > program_manager)
Create a dispatcher that submits operations eagerly.
array arange(const scalar_value &start, const scalar_value &stop, const scalar_value &step, numerical_type data_type, memory_resource_affinity affinity, const execution_context &context, array *out=nullptr)
Create a one dimensional array holding an arithmetic progression.
version get_library_version() noexcept
Get the version of the rexlib installation.
Building from source
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build -j
ctest --test-dir build
With CMake 3.21 or newer, presets provide the same flow:
cmake --preset debug
cmake --build --preset debug
ctest --preset debug
To generate the C++ API reference:
cmake -S . -B build -DREXLIB_BUILD_DOCS=ON -DBUILD_TESTING=OFF
cmake --build build --target rexlib-docs