Skip to content

Add OneMATH support as an alternative to oneMKL - #323

Open
thomasRoglin wants to merge 9 commits into
ORNL:masterfrom
SiPearl:upstream/tr/enable_onemath
Open

Add OneMATH support as an alternative to oneMKL#323
thomasRoglin wants to merge 9 commits into
ORNL:masterfrom
SiPearl:upstream/tr/enable_onemath

Conversation

@thomasRoglin

Copy link
Copy Markdown
Contributor

Summary

This PR adds OneMath API support to multiple benchmarks and improves verification.

  • OneMath API Integration: Added OneMath support via USE_ONEMATH macro as an alternative to OneMKL
  • AdaptiveCpp Compatibility: Enhanced support for non-DPCPP compilers by skipping unsupported data types (And supporting Onemath API)
  • Verification Improvements: Add missing verification and change some verification threshold

Detail by benchmarks :

gemmStridedBatched & gemmBatched

  • OneMath API support via USE_ONEMATH macro
  • Clarify verification output with explicit PASS/FAIL messages

gemm

  • OneMath API support via USE_ONEMATH macro
  • Replace mkl_malloc with standard SYCL allocation
  • Add tolerance-based verification for improved accuracy

gemmEx

  • OneMath API support via USE_ONEMATH macro
  • Add AdaptiveCpp support by skipping bf16 and int8 tests for non-DPCPP compilers
  • Enhanced verification for SYCL variant

dot

  • OneMath and AdaptiveCpp support
  • Skip FP16/BF16 compilation for non-DPCPP compilers
  • set verification threshold to 1% of sum (instead of 1e-1) for fp32

norm2

  • Standard oneMKL linking in Makefile
  • OneMath API support via USE_ONEMATH macro
  • Set verification threshold to 1%

dropout

  • OneMath API support via USE_ONEMATH macro

rayleighBenardConvection

  • OneMath API support via USE_ONEMATH macro

@zjin-lcf
zjin-lcf requested review from Geekdude and zjin-lcf August 21, 2026 09:57
@Geekdude
Geekdude requested a balanced review from Copilot August 21, 2026 18:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds a OneMath-based build/runtime path (behind USE_ONEMATH) across several SYCL benchmarks, updating BLAS/RNG calls and Makefiles to support selecting OneMath vs oneMKL.

Changes:

  • Introduces USE_ONEMATH compile-time switch and math_ns alias to route calls to OneMath or oneMKL.
  • Updates Makefiles to link against OneMath libraries (including CUDA/HIP backends) when enabled.
  • Adjusts/extends verification logic and output (PASS/FAIL) in several benchmarks.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/rayleighBenardConvection-sycl/main.cpp Routes BLAS calls through math_ns to support OneMath/oneMKL.
src/rayleighBenardConvection-sycl/Makefile Adds OneMath build/link options and USE_ONEMATH define.
src/norm2-sycl/main.cpp Switches to math_ns for nrm2 and updates verification threshold.
src/norm2-sycl/Makefile Adds OneMath knobs and adjusts includes/linking logic accordingly.
src/dropout-sycl/main.cpp Adds OneMath RNG headers and routes device RNG calls through math_ns.
src/dropout-sycl/Makefile Adds OneMath knobs and USE_ONEMATH compile path.
src/blas-gemmStridedBatched-sycl/main.cpp Routes batched GEMM calls through math_ns and improves verification output.
src/blas-gemmStridedBatched-sycl/Makefile Adds OneMath build/link options and USE_ONEMATH define.
src/blas-gemmEx-sycl/main.cpp Adds OneMath support, AdaptiveCpp guards, and new reference/verification helpers.
src/blas-gemmEx-sycl/Makefile Adds OneMath build/link options and USE_ONEMATH define.
src/blas-gemmBatched-sycl/main.cpp Routes batched GEMM calls through math_ns and improves verification output.
src/blas-gemmBatched-sycl/Makefile Adds OneMath build/link options and USE_ONEMATH define.
src/blas-gemm-sycl/main.cpp Adds OneMath support and replaces MKL allocation + updates verification logic.
src/blas-gemm-sycl/Makefile Adds OneMath build/link options and USE_ONEMATH define.
src/blas-dot-sycl/main.cpp Routes dot to math_ns, adds OneMath timing label, and adjusts thresholds/AdaptiveCpp guards.
src/blas-dot-sycl/Makefile Adds OneMath knobs and linking, plus USE_ONEMATH compile path.
Suppressed comments (2)

src/blas-gemm-sycl/main.cpp:14

  • sycl::malloc_host<T> expects an element count, but A_size/B_size/C_size are byte sizes, which leads to incorrect allocations and will also make the later comparison loop incorrect because it iterates i < C_size (bytes) while indexing c[i]/r[i] as elements. Allocate with element counts (m*k, k*n, m*n) and iterate over m*n elements. Also, the code uses column_major::gemm for the correctness check but row_major::gemm for the timed loop with the same pointers/leading dimensions—this is a behavioral change that can make timing run a different computation/layout than what was validated; use a consistent layout for both paths. Lastly, the output string has a typo: 'missmatch' should be 'mismatch'.
    src/blas-gemmEx-sycl/main.cpp:85
  • mode is accepted (and callers pass bf16/tf32 modes), but it is not used when dispatching to gemm, so the requested compute mode has no effect. Either (mandatory) call the API variant that accepts/implements compute mode for the backend(s) that support it, or (optional) remove the parameter/feature flag and corresponding test prints to avoid reporting modes that aren’t actually applied.
    status = math_ns::blas::column_major::gemm(
      q,
      transA, transB,
      m, n, k,
      alpha, A, lda,
      B, ldb, beta,
      C, ldc);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/blas-gemm-sycl/main.cpp Outdated
Comment thread src/blas-gemm-sycl/main.cpp
Comment thread src/norm2-sycl/main.cpp Outdated
Comment thread src/blas-gemmEx-sycl/main.cpp
Comment thread src/blas-dot-sycl/main.cpp Outdated
Comment thread src/blas-dot-sycl/Makefile Outdated
ONEMKL_PATH ?= /path/to/oneMKL

# path to the install of the oneMath library
ONEMATH_PATH = /path/to/oneMath

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is done for every benchmark

@zjin-lcf

Copy link
Copy Markdown
Collaborator

@thomasRoglin Thank you for the pull requests. Are Copilot's reviews helpful ?

- Use OneMath instead of OneMKL if the USE_ONEMATH macro is define
- Support AdaptiveCpp by skipping compilation of FP16 and BF16 if
  compiler is not dpcpp
- Change verification threshold from 1e-1 to 1% of the sum, otherwise
  fp32 would fail
    - Use standard way to link to onemkl in Makefile
    - Use OneMath instead of OneMKL if the USE_ONEMATH macro is define
    - Change verification threshold from 1e-1 to 1% of the sum, otherwise
      verification fail
 - Use OneMath instead of OneMKL if the USE_ONEMATH macro is define
 - Support AdaptiveCpp by skipping bf16 and int8 tests if compiler is
   not DPCPP
 - Use OneMath instead of OneMKL if the USE_ONEMATH macro is define
     - Use OneMath instead of OneMKL if the USE_ONEMATH macro is define
     - Use OneMath instead of OneMKL if the USE_ONEMATH macro is define
     - Replace mkl_malloc by standard sycl alloc
     - Improve verification to add tolerance
    - Use OneMath instead of OneMKL if the USE_ONEMATH macro is define
    - Clarify verification by printing PASS or FAIL
        - Use OneMath instead of OneMKL if the USE_ONEMATH macro is define
        - Clarify verification by printing PASS or FAIL
@thomasRoglin
thomasRoglin force-pushed the upstream/tr/enable_onemath branch from e7c8b5f to 9c90f6f Compare August 24, 2026 10:42
@thomasRoglin

thomasRoglin commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Hello, Copilot reviews were relevant and are now implemented.. Let me know if there is anything else to modify

@zjin-lcf

Copy link
Copy Markdown
Collaborator

@thomasRoglin Thank you for the updates! I have some comments about oneMath itself if that is right:

• oneMath lacks dot<half> and dot<bfloat16>
• The bfloat16 GEMM requests bfloat16 A/B and bfloat16 C. oneMath support float C.
• Its int8 GEMM requests ordinary int8 A/B → int32 C, which oneMath does not expose.

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.

3 participants