Skip to content

Add intrinsics support, Add nanobench + documentation + example#49

Open
mcdubhghlas wants to merge 5 commits into
Redot-Engine:masterfrom
mcdubhghlas:master
Open

Add intrinsics support, Add nanobench + documentation + example#49
mcdubhghlas wants to merge 5 commits into
Redot-Engine:masterfrom
mcdubhghlas:master

Conversation

@mcdubhghlas

@mcdubhghlas mcdubhghlas commented Jul 7, 2026

Copy link
Copy Markdown
Member

Title.

Summary by CodeRabbit

  • New Features

    • Added optional benchmark builds and run targets, making it easier to compile and execute performance tests from the build system.
    • Benchmark files are now built as separate executables, alongside support for SIMD-based math benchmarking.
  • Documentation

    • Added benchmarking guidance with setup steps, example usage, and common tuning options.

@mcdubhghlas

Copy link
Copy Markdown
Member Author

This is the output for the benchmark test I added:

# compiler : clang 22.1.4
# fast-math: off
# sizeof(Vector4) = 16
# alignof(Vector4) = 16
Warning, results might be unstable:
* CPU frequency scaling enabled: CPU 0 between 3,012.5 and 5,883.2 MHz

Recommendations
* Use 'pyperf system tune' before benchmarking. See https://github.com/psf/pyperf

| relative |              ns/dot |               dot/s |    err% |         ins/dot |         cyc/dot |    IPC |        bra/dot |   miss% |     total | dot throughput
|---------:|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:---------------
|   100.0% |                0.55 |    1,831,818,654.25 |    0.5% |           11.77 |            2.45 |  4.796 |           0.25 |    0.4% |      0.11 | `scalar`
|   120.4% |                0.45 |    2,204,644,868.10 |    0.3% |            8.02 |            2.04 |  3.933 |           0.25 |    0.4% |      0.09 | `simd`

| relative |              ns/dot |               dot/s |    err% |         ins/dot |         cyc/dot |    IPC |        bra/dot |   miss% |     total | dot latency chain
|---------:|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:------------------
|   100.0% |                3.08 |      324,636,802.67 |    0.1% |            8.51 |           13.85 |  0.614 |           0.50 |    0.2% |      0.63 | `scalar`
|   124.5% |                2.47 |      404,160,867.71 |    0.0% |            8.51 |           11.12 |  0.765 |           0.50 |    0.2% |      0.51 | `simd`

| relative |              ns/dot |               dot/s |    err% |         ins/dot |         cyc/dot |    IPC |        bra/dot |   miss% |     total | dot compare/count
|---------:|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:------------------
|   100.0% |                0.58 |    1,712,182,462.47 |    0.2% |           10.76 |            2.63 |  4.100 |           0.13 |    0.0% |      0.12 | `scalar`
|   115.4% |                0.51 |    1,976,615,709.62 |    0.2% |           11.51 |            2.27 |  5.059 |           0.50 |    0.2% |      0.10 | `simd`

My computer:

$ sh /home/mcdubh/display.sh                                                                  
    .-----.      mcdubh@ryzen-desktop
  .`    _  `.    OS:        Gentoo Linux
  `.   (_ )   `. KERNEL:    Linux 7.0.1-gentoo
    `.        /  WM:        dwm
   .`       .`   PACKAGES:  1215
  /       .`     SHELL:     mksh
  \____.-`       CPU:       AMD Ryzen 9 7950X 16-Core Processor
                 RAM:       56746MiB/63396MiB
                 GPU:       Navi 31 Radeon RX 7900 XT
$ 

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 77aa3534-a743-41ff-896a-be70408d69d5

📥 Commits

Reviewing files that changed from the base of the PR and between 5b19441 and 2d43b73.

📒 Files selected for processing (2)
  • Docs/Benchmarking.md
  • cmake/Modules.cmake
✅ Files skipped from review due to trivial changes (1)
  • Docs/Benchmarking.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • cmake/Modules.cmake

📝 Walkthrough

Walkthrough

Introduces optional benchmark support: a BUILD_BENCHMARKS CMake option with benchmarks/run-benchmarks aggregation targets, Modules.cmake discovery/build of *.bench.cpp files linked to module libraries, a new Runtime/Platform/intrinsics.h header, a Vector4 dot-product nanobench, and accompanying documentation.

Changes

Benchmark infrastructure and Vector4 benchmark

Layer / File(s) Summary
CMake benchmark option and aggregation targets
CMakeLists.txt
Adds BUILD_BENCHMARKS option and defines benchmarks/run-benchmarks targets from the DRACO_BENCH_TARGETS global property.
Modules.cmake benchmark discovery and build wiring
cmake/Modules.cmake
Sets NANOBENCH_INCLUDE_DIR, globs *.bench.cpp files, excludes them from module sources, and builds/links benchmark executables while registering targets in DRACO_BENCH_TARGETS.
Platform intrinsics header and Vector4 module include
Engine/cpp/Runtime/Platform/intrinsics.h, Engine/cpp/Runtime/Core/Math/Vector4.cppm
Adds a header conditionally including immintrin.h/arm_neon.h and includes it from the Vector4 module.
Vector4 dot-product benchmark implementation
Engine/cpp/Runtime/Core/Math/Vector4.bench.cpp
Implements scalar/SIMD dot callables, metadata printing, a throughput helper, and three nanobench benchmark groups (throughput, latency, compare/count) run from main().
Benchmarking documentation
Docs/Benchmarking.md
Documents how to add *.bench.cpp files, sample nanobench usage, build/run commands, and optional configuration knobs.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: OldDev78, JoltedJon

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main changes: intrinsics support plus nanobench benchmarking, documentation, and an example benchmark.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmake/Modules.cmake`:
- Around line 90-107: The benchmark executables created in the BUILD_BENCHMARKS
block are currently part of the default ALL build, which bypasses the intended
benchmarks/run-benchmarks workflow. Update the add_executable call for each
BENCH_TARGET in Modules.cmake to exclude these targets from ALL, while keeping
the existing target registration and linkage intact. Use the BENCH_TARGET
creation path in the BUILD_BENCHMARKS foreach loop to locate the change and
preserve the aggregated DRACO_BENCH_TARGETS behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e4e63d88-10ac-4805-bc36-a1bbcaf007b2

📥 Commits

Reviewing files that changed from the base of the PR and between b642f33 and 5b19441.

📒 Files selected for processing (7)
  • CMakeLists.txt
  • Docs/benchmarking.md
  • Engine/cpp/Runtime/Core/Math/Vector4.bench.cpp
  • Engine/cpp/Runtime/Core/Math/Vector4.cppm
  • Engine/cpp/Runtime/Platform/intrinsics.h
  • Engine/cpp/ThirdParty/nanobench/nanobench.h
  • cmake/Modules.cmake

Comment thread cmake/Modules.cmake
Comment thread Docs/Benchmarking.md Outdated
Co-authored-by: Jon <14169426+JoltedJon@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants