Skip to content

Cross-platform noise benchmark comparison (issue 31) - #33

Merged
EndrII merged 2 commits into
mainfrom
task_31
Nov 12, 2026
Merged

EndrII merged 2 commits into
mainfrom
task_31

Conversation

@QuasarAppCI

Copy link
Copy Markdown
Member

Summary (issue #31)

Adds one more action that triggers an additional test of all noise functions across all three platforms (Linux, Windows, macOS). It waits for completion of all three platform jobs and then compares the results — they must match perfectly, given the same input parameters.

Changes

  • .github/workflows/cross-platform-compare.yml (new): the new "Cross-Platform Noise Benchmark" action.
    • benchmark job: matrix over ubuntu-latest, windows-latest, macos-latest (same Qt + libpng setup as ci.yml), builds the project and runs the benchmark target, uploads the platform report as an artifact.
    • compare job: needs: benchmark (waits for all three platforms), downloads the three reports and compares them byte-for-byte (cmp) plus FNV-1a/sha256 checksums; any difference fails the pipeline.
  • tests/test_OpenSimplex2F_cross_platform.c (new): evaluates all nine public noise functions (noise2, noise2_XBeforeY, noise3_Classic, noise3_XYBeforeZ, noise3_XZBeforeY, noise4_Classic, noise4_XYBeforeZW, noise4_XZBeforeYW, noise4_XYZBeforeW) with the same seed (77374) and the same fixed input parameters on every platform, and prints the exact IEEE-754 binary64 bit pattern of every result (37107 values in total) plus an FNV-1a checksum. The report is plain ASCII, so it is platform independent and can be compared byte-for-byte.
  • tests/CMakeLists.txt: new OpenSimplex2_cross_platform executable and the OpenSimplex2_cross_platform_benchmark target that runs it (deliberately not part of the QuasarApp test target, so no cqtdeployer deployment is required).
  • CMakeLists.txt: disables FMA (-mno-fma) for GNU/Clang builds of the library and the benchmark — arm64 (Apple Silicon) compilers may contract a*b+c into FMA instructions, which would change the least significant bits of the results; on x86-64 this flag is a no-op.

Verification (local, Linux)

  • Build + run: Result: PASS (37107 values, seed 77374), report written to build/cross_platform/noise_benchmark_results.txt (checksum bb84b67c9c4e1e11).
  • Determinism: re-running produces a byte-identical report; a Debug build with -O0 produces the same bit patterns as the Release build.
  • The compare logic was simulated with three copies of the report (pass) and with a tampered file (correctly fails).
  • The existing PNG test still passes: Result: 3/3 tests passed.

Add a new GitHub Actions workflow (Cross-Platform Noise Benchmark) that
runs an additional benchmark of all OpenSimplex2F noise functions on all
three platforms (Linux, Windows, macOS) with the same seed and the same
input parameters, waits for all three jobs to complete, and then compares
the produced result files byte-for-byte: the noise results must match
perfectly on every platform.

- tests/test_OpenSimplex2F_cross_platform.c: evaluates all nine noise
  functions (2D, 3D, 4D variants) on a fixed coordinate grid with three
  frequency scales (37107 values in total) and prints the exact IEEE-754
  binary64 bit pattern of every result plus an FNV-1a checksum.
- tests/CMakeLists.txt: new OpenSimplex2_cross_platform executable and the
  OpenSimplex2_cross_platform_benchmark target that runs it (no cqtdeployer
  deployment required).
- CMakeLists.txt: disable FMA (-mno-fma) for GNU/Clang builds of the
  library and the benchmark so that arm64 (Apple Silicon) FMA contraction
  cannot change the least significant bits of the results.
- .github/workflows/cross-platform-compare.yml: benchmark matrix job on
  ubuntu-latest, windows-latest and macos-latest (same Qt/libpng setup as
  ci.yml), artifact upload of the platform reports, and a compare job that
  waits for all three jobs (needs) and fails when the reports differ.
@EndrII
EndrII self-requested a review November 12, 2026 08:36
@QuasarAppCI

QuasarAppCI commented Nov 12, 2026 •

Copy link
Copy Markdown
Member Author

Task checklist — PR #33 (issue #31) — DONE

  • Review PR diff + CodeQL comments
  • Diagnose CI run 43130583493: Benchmark windows-latest + macos-latest failed, compare skipped
  • FMA flag: -mno-fma is rejected by Apple Clang (unsupported option for target arm64-apple-darwin) -> portable -ffp-contract=off for GNU + Clang (no-op on x86-64, results unchanged: same checksum)
  • Windows: the shell: bash benchmark step mangled the D:\a\... workspace path (bash backslash escapes) -> normalize $GITHUB_WORKSPACE to forward slashes
  • Report writer: fopen("w") (text mode writes CRLF on Windows, would break the byte-for-byte compare) -> fopen("wb")
  • CodeQL: GITHUB_TOKEN permissions added (benchmark: contents: read + actions: write for checkout/upload-artifact, compare: actions: read for download-artifact)
  • Local verification: build + benchmark PASS (37107 values, checksum bb84b67c9c4e1e11) + PNG tests 3/3 + determinism (re-run byte-identical) + compare simulation (3 identical -> pass, tampered -> fail)
  • Pushed task_31 (579453b) — CI re-run all green

Result (CI, head 579453b)

  • Cross-Platform Noise Benchmark (run 43270496110): Benchmark linux + windows + macos pass, Compare results pass — all three reports are bit-identical: checksum=bb84b67c9c4e1e11, 495853 bytes each, byte-for-byte cmp OK.
  • Build and Test (run 43270495902): ubuntu + windows pass (existing PNG tests unchanged).
  • CodeQL: pass; the two "Workflow does not contain permissions" alerts on cross-platform-compare.yml are resolved. Note: one pre-existing open alert (Improve rust speed #1, since 2026-10-13) remains on ci.yml (the older workflow, outside this PR's diff) — suggested follow-up: add a permissions block there too.

Label waiting-for-review set. PR is ready for review/merge.

The first CI run (43130583493) of the Cross-Platform Noise Benchmark workflow failed on the windows-latest and macos-latest benchmark jobs (compare skipped):

- macos-latest: Apple Clang rejects -mno-fma (unsupported option for target
  arm64-apple-darwin), so the FMA guard broke the build on the only platform
  where it was needed. Use the portable -ffp-contract=off (supported by both
  GCC and Clang, no-op on x86-64) for the library and the benchmark target.
- windows-latest: the 'Run cross-platform benchmark' step runs under bash
  (Git Bash), where the Windows workspace path (D:\a\...) is mangled by
  backslash escaping ('D:/a/.../aOpenSimplex2OpenSimplex2/build is not a
  directory'). Normalize GITHUB_WORKSPACE to forward slashes first (a no-op on
  Linux and macOS).
- The report was written with fopen(path, w) (text mode), which converts
  every newline to CRLF in the Windows C runtime and would have broken the
  byte-for-byte comparison even after the path fix. Write in binary mode
  ("wb") so the report is byte-identical on all three platforms.
- CodeQL ('Workflow does not contain permissions'): limit the GITHUB_TOKEN of
  the benchmark job to contents:read + actions:write (checkout +
  upload-artifact) and the compare job to actions:read (download-artifact).

Verified locally (Linux x86-64, GCC 13, Qt 6.12.0 prefix): build + benchmark
PASS with 37107 values and checksum bb84b67c9c4e1e11 (unchanged by the flag
swap, matching the ubuntu CI job), re-run byte-identical, PNG test target
3/3 passed, and the compare script passes with three identical reports and
fails on a tampered one.
@EndrII
EndrII merged commit 1538888 into main Nov 12, 2026
9 checks passed
@EndrII
EndrII deleted the task_31 branch November 12, 2026 18:16
QuasarAppCI added a commit that referenced this pull request Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants