POET
POET is a header-only C++ library for compile-time unrolling and runtime-to-compile-time specialization.
Project links
Core primitives
static_for: compile-time unrolled loops over integer rangesdynamic_for: runtime loops emitted as compile-time unrolled blocksdispatch/dispatch_set: runtime choice mapped to compile-time specializationsCPU detection: ISA, vector-width, and cache-line helpers (
poet::available_registers(),poet::cache_line())
Quick start
Note
Each example runs online on Compiler Explorer. The link pulls the single-header build from GitHub at compile time via Compiler Explorer’s URL-include feature.
Source for each example lives in examples/.
Include the umbrella header:
#include <poet/poet.hpp>
Minimal examples:
poet::static_for<0, 4>([](auto I) {
use_index(I);
});
poet::dynamic_for<4>(0u, n, [](std::size_t i) {
out[i] = f(i);
});
auto y = poet::dispatch(
Kernel{},
poet::dispatch_param<poet::inclusive_range<0, 4>>{choice},
x);
Notes
dynamic_forhelps with the lane-aware callback form for multi-accumulator work.The C++20
make_dynamic_foradaptor is eager and needs a random-access range.
Getting Started
API Reference