Skip to content

Gate engine template instantiations by PGen compatibility#4

Merged
haykh merged 4 commits intodev/emissionfrom
codex/restrict-engine-metric-combinations-in-pgen
Jan 25, 2026
Merged

Gate engine template instantiations by PGen compatibility#4
haykh merged 4 commits intodev/emissionfrom
codex/restrict-engine-metric-combinations-in-pgen

Conversation

@haykh
Copy link
Owner

@haykh haykh commented Jan 25, 2026

Motivation

  • The build was instantiating Engine templates for every entry in NTT_FOREACH_SPECIALIZATION, which triggered template constraint failures for engine/metric/dimension combinations that are incompatible with the selected problem generator (PGen).
  • The intent is to avoid hard instantiation of invalid combinations at compile time and only force instantiation for combinations allowed by the problem generator compatibility traits.

Description

  • Replaced direct explicit instantiations with compatibility-gated instantiator helpers in src/engines/engine_init.cpp, src/engines/engine_run.cpp, and src/engines/engine_printer.cpp by adding EngineInitInstantiator, EngineRunInstantiator, and EnginePrinterInstantiator respectively.
  • Each instantiator uses if constexpr (IsCompatibleWithEngine<S, M<D>>) and takes the address of the corresponding member function (for example (void)&Engine<S, M<D>>::init) so the compiler only instantiates members for compatible combinations instead of all specializations.
  • The NTT_FOREACH_SPECIALIZATION expansion now emits unique static instantiator variables using __COUNTER__ and small NTT_CONCAT macros to avoid global template instantiations for incompatible combos, and related cleanup of macros was added.
  • This change gates init, run, and print_report instantiations by PGen compatibility, preventing the earlier compile-time constraint failures.

Testing

  • No automated tests or builds were run for this change.

Codex Task

@haykh haykh merged commit 4da54f2 into dev/emission Jan 25, 2026
5 checks passed
@haykh haykh deleted the codex/restrict-engine-metric-combinations-in-pgen branch January 25, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant