Repository navigation
Core/template compile - #298
Open
jlee-kitware wants to merge 7 commits into
Open
jlee-kitware wants to merge 7 commits into
jlee-kitware wants to merge 7 commits into
Conversation
The callee is resolved on demand when a call binding a template into it is reached before its own turn.
Each inlined call copied the whole template tree's arrays and runtime scalars; a fixpoint over the calls between resolved methods keeps what each needs.
A view's other methods cost nothing, and one that would not resolve is never reached.
NVRTC's --fmad=true fused differently in two kernels inlining the same function, depending on the code around it, so streamlines with and without the locator's previous-cell try differed in the last bit on curved wedges. The generator now chooses: a sum or difference with a product operand is __fmaf_rn/__fma_rn, every other product __fmul_rn/__dmul_rn, and NVRTC runs with --fmad=false.
Collaborator
|
The failing shares (py3.11/3.12/3.13 and Metal 3/4) are one cause: the host C++ preludes this PR extends with static inline float __fmaf_rn(float a, float b, float c) { return fmaf(a, b, c); }
static inline double __fma_rn(double a, double b, double c) { return fma(a, b, c); }call
The other three ( While you're in there: the branch is 17 commits behind main, and main now requires an SPDX header on every source file (#292). This PR adds no new files, so a merge of main is all it needs. |
Three preludes declared __fmaf_rn and __fma_rn without <cmath>, so clang++ refused fmaf and fma.
jlee-kitware
added a commit
to jlee-kitware/tack
that referenced
this pull request
Nov 4, 2026
# Conflicts: # packages/tack-core/tests/test_atomic_contract.py # packages/tack-core/tests/test_float_division.py # packages/tack-core/tests/test_float_literals.py # packages/tack-core/tests/test_float_semantics.py # packages/tack-core/tests/test_gpu_identifiers.py # packages/tack-core/tests/test_reduction_semantics.py
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Template methods: held templates as arguments, fewer copied parameters, methods resolved on demand; explicit CUDA contractions
Problem
self.values.scaled(self.mesh, i)). The callee was not resolved yet, and the rewrite raised aKeyErrorfor its resolved name.--fmad=true, NVRTC fused two inlined copies of one function differently depending on the code around them. Two kernels sharing a computation could differ in the last bit: streamlines with and without the locator's previous-cell try, on curved wedges.Approach
__fmaf_rn/__fma_rn: a+or-with a product operand, the left product when both are. Every other product is__fmul_rn/__dmul_rn, and NVRTC compiles with--fmad=false, so one expression rounds the same wherever it is inlined. This is the part that touches the floating-point contract; the numerical-semantics, language-contract, backend and vendor-workaround docs are updated with the reasoning.Effect
First compile with a cold disk cache on a DGX Spark, contouring an order-2
H1field on a small grid: 6.1 s to 3.5 s on CPU, and 10.5 to 12.1 s down to 3.2 to 4.6 s on CUDA. The IR for a kernel reading an order-2 field drops from 5.5k to 1.9k nodes. Warm-cache launches and the speed of compiled kernels (checked on an LBM solver step) are unchanged.Verified
tack-core and tack-vis on CPU and CUDA, including a new test passing a held template to a held template's method, and the curved-wedge streamline test matching bit for bit.