Repository navigation
Fix simplex noise gradient lookups and permutation indices - #2124
Open
sbryngelson wants to merge 1 commit into
Open
sbryngelson wants to merge 1 commit into
sbryngelson wants to merge 1 commit into
Conversation
f_simplex2d indexed grad2(g + 1, :) with g already in 1..10, reading past the end of the table (gfortran: "Index '11' of dimension 1 of array 'grad2' above upper bound of 10"). f_simplex3d added + 1 to every permutation lookup although p_vec is declared 0:511, which shifted the hash and could index p_vec(512). Both gradient tables were also listed row by row but reshaped in column-major order, so grad3 held duplicate and missing directions instead of the 12 cube-edge vectors. Index the tables directly, drop the extra offsets so the lookups match Gustavson's reference (perm[ii + perm[jj + perm[kk]]] % 12), reshape with order=[2, 1], and replace real(i + j, 8) with real(i + j, wp). Verified against a Python port of the reference algorithm at 20000 random points (max difference 4e-16 in 2D, 1e-16 in 3D) with -fcheck=all clean, and with 2D and 3D pre_process runs using simplex density and velocity perturbation. No test or example in the suite uses simplex perturbation (3D_IGR_33jet is skipped), so no goldens change.
|
Claude Code Review Head SHA: 5225f68 Files changed:
Findings: |
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.
What
f_simplex2d indexed grad2(g + 1, :) with g already in 1..10, reading
past the end of the table (gfortran: "Index '11' of dimension 1 of
array 'grad2' above upper bound of 10"). f_simplex3d added + 1 to every
permutation lookup although p_vec is declared 0:511, which shifted the
hash and could index p_vec(512). Both gradient tables were also listed
row by row but reshaped in column-major order, so grad3 held duplicate
and missing directions instead of the 12 cube-edge vectors.
Index the tables directly, drop the extra offsets so the lookups match
Gustavson's reference (perm[ii + perm[jj + perm[kk]]] % 12), reshape
with order=[2, 1], and replace real(i + j, 8) with real(i + j, wp).
Verified against a Python port of the reference algorithm at 20000
random points (max difference 4e-16 in 2D, 1e-16 in 3D) with
-fcheck=all clean, and with 2D and 3D pre_process runs using simplex
density and velocity perturbation. No test or example in the suite
uses simplex perturbation (3D_IGR_33jet is skipped), so no goldens
change.
Verification
Testing. Built with GPU offload (OpenMP, AMD) and ran the full test suite with this fix and seven other independent fixes applied together: 729 tests in 4 shards, 0 failures (two shards on MI300A, two on MI250X).
Prepared with Claude Code (AI-assisted); I reviewed the change and ran the tests.