C++ Templates · Executors

Executors

bd07c64c

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

curl -s 'https://www.unum.cloud/docs/uform/templates/executors.md' | claude -p "How would this fit my code?"

§ Per-GPU Tables

stack_array keeps up to a compile-time count of elements inline, never relocating one once constructed, which is how every composition root owns one object per GPU:

#include <cstddef> // `std::size_t`

#include "uform/utilities/array.hpp" // `stack_array`

namespace util = unum::uform::utilities;

/** One record per device, constructed in place and never moved while the table lives. */
struct device_entry_t {
    int ordinal = -1;
    std::size_t free_bytes = 0;
};

int main() {
    util::stack_array<device_entry_t, 8> entries;
    for (int ordinal = 0; ordinal != 3; ++ordinal)
        if (entries.push_back({ordinal, 0}).failed()) return 1; // past 8 elements, `out_of_memory_k`
    return entries.size() == 3 && entries.capacity() == 8 ? 0 : 1;
}