C++ · Runtime Dispatch

Runtime Dispatch

#include <stringzilla/devices.hpp> 6.0.0-rc.1 · cb8d956a

Ask your coding agent about this page, or add the docs server to it

curl -s 'https://www.unum.cloud/docs/stringzilla/cpp/runtime-dispatch.md' | claude -p "How would this fit my code?"

Every verb that takes a mask, like sz::lookup or sz::argsort, defaults to sz::default_capabilities() from <stringzilla/devices.hpp>, the enabled CPU mask, while sz::device_t::make(kind, ordinal) opens one GPU to ask its capabilities_enabled(), and sz::device_t::cpu().configure_thread(mask) wraps sz_configure_thread_cpu. A monoversioned build keeps only its best capability, so a mask narrowed below it answers sz::status_t::missing_kernel_k. The C guide describes the masks and the capabilities they hold.

API

Classdevice_tOne device StringZilla runs kernels on: the host CPU, or a GPU by its runtime's own ordinal.7
devices.hpp:23 ↗
class device_t
cpuThe host CPU, which every build has.
devices.hpp:31 ↗
device_t cpu() noexcept;
countHow many devices of kind the process sees: one CPU, or missing_gpu_k and zero GPUs.
devices.hpp:34 ↗
expected<std::size_t> count(device_kind_t kind) noexcept;
makeDevice ordinal of kind, or missing_gpu_k past the last one.
devices.hpp:47 ↗
expected<device_t> make(
    device_kind_t kind,
    std::size_t ordinal) noexcept;
capabilities_detectedWhat this device runs, whether or not this binary holds kernels for it; zero on failure.
devices.hpp:57 ↗
expected<sz_capability_t> capabilities_detected() const noexcept;
capabilities_compiledWhat this binary holds kernels for that this device runs; zero on failure.
devices.hpp:70 ↗
expected<sz_capability_t> capabilities_compiled() const noexcept;
capabilities_enabledBoth at once: the mask for this device's dispatch points; zero on failure.
devices.hpp:83 ↗
expected<sz_capability_t> capabilities_enabled() const noexcept;
configure_threadPrepares the calling thread for the CPU kernels of capabilities; GPUs have no such kernels, so they report missing_kernel_k.
devices.hpp:97 ↗
status_t configure_thread(sz_capability_t capabilities) const noexcept;

Functions

default_capabilitiesThe mask every verb dispatches over by default: the CPU's enabled capabilities, as device_t::cpu().capabilities_enabled() reports them.
devices.hpp:106 ↗
sz_capability_t default_capabilities() noexcept;

A monoversioned build keeps only its best capability, so a mask narrowed below it answers missing_kernel_k.