Template Function sequant::eval::combine_forest_roots

Function Documentation

template<Trace EvalTrace, meta::can_evaluate node_t, typename N, bool FHC>
ResultPtr sequant::eval::combine_forest_roots(container::svector<node_t const*> const &roots, container::svector<ResultPtr> &pre_results, auto const &layout, CacheManager<N, FHC> &cache)

The shared per-root combine step every whole-forest executor ends with: permute each root’s own (already-built) result to layout, then sum across roots &#8212; the identical Term Begin/End boundary, Permute EvalStat, and cross-root add_inplace + SumInplace EvalStat trace/hwmark bookkeeping sequant::evaluate(Nodes const&, layout, ...) (eval.hpp) emits.

Factored into its own header so every whole-forest executor entry &#8212; evaluate_ordered_schedule and evaluate_ordered_multiroot (ordered_executor.hpp) &#8212; reuses the identical bookkeeping rather than hand-syncing a second copy that would silently drift as later work extends either entry point.

Parameters:
  • roots – pointers to the forest’s own top-level trees, in forest order &#8212; pointers, not nodes, because FullBinaryNode's copy constructor deep-copies the whole subtree, and a caller assembling a node vector here would clone the entire forest (thousands of nodes for a residual) once per call just to name its roots. The pointees are the caller’s forest, which outlives this call.

  • pre_results – Each root’s own unpermuted, already-built result, aligned index-for-index with roots. Moved out of on use (each entry is consumed), so the caller’s own copy is left empty after this call returns.

  • layout – The layout each root’s result is permuted to before being summed; same meaning as

    sequant::evaluate(Node const&, layout,

    ...)'s

    layout.

  • cache – The cache consulted for the trace/hwmark bookkeeping only (byte counts, chain residency) &#8212; no value is built or stored by this function.

Returns:

The summed, per-root-permuted result.