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
Try it online. Each example has a one-click Compiler Explorer link that pulls the single-header build from GitHub at compile time via Compiler Explorer’s URL-include feature.
Source for each example lives in examples/; regenerate the links with tools/make_godbolt_links.py.
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
poet::inclusive_range<Start, End>is inclusive on both ends.dynamic_foris most useful with the lane-aware callback form for multi-accumulator work.The C++20
make_dynamic_foradaptor is eager.
Next reads
Getting Started
API Reference