[all-commits] [llvm/llvm-project] 8d7b50: [Offload][Conformance] Add `RandomGenerator` for l...

Leandro Lacerda via All-commits all-commits at lists.llvm.org
Wed Aug 20 11:37:22 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8d7b50e5725efa89d2ff7c4e3d6d011ed28c5d9b
      https://github.com/llvm/llvm-project/commit/8d7b50e5725efa89d2ff7c4e3d6d011ed28c5d9b
  Author: Leandro Lacerda <leandrolcampos at yahoo.com.br>
  Date:   2025-08-20 (Wed, 20 Aug 2025)

  Changed paths:
    M offload/unittests/Conformance/device_code/CUDAMath.cpp
    M offload/unittests/Conformance/device_code/DeviceAPIs.hpp
    M offload/unittests/Conformance/device_code/HIPMath.cpp
    M offload/unittests/Conformance/device_code/LLVMLibm.cpp
    M offload/unittests/Conformance/include/mathtest/ExhaustiveGenerator.hpp
    A offload/unittests/Conformance/include/mathtest/RandomGenerator.hpp
    A offload/unittests/Conformance/include/mathtest/RandomState.hpp
    A offload/unittests/Conformance/include/mathtest/RangeBasedGenerator.hpp
    M offload/unittests/Conformance/tests/CMakeLists.txt
    A offload/unittests/Conformance/tests/LogTest.cpp

  Log Message:
  -----------
  [Offload][Conformance] Add `RandomGenerator` for large input spaces (#154252)

This patch implements the `RandomGenerator`, a new input generator that
enables conformance testing for functions with large input spaces (e.g.,
double-precision math functions).

**Architectural Refactoring**

To support different generation strategies in a clean and extensible
way, the existing `ExhaustiveGenerator` was refactored into a new class
hierarchy:
* A new abstract base class, `RangeBasedGenerator`, was introduced using
the Curiously Recurring Template Pattern (CRTP). It contains the common
logic for generators that operate on a sequence of ranges.
* `ExhaustiveGenerator` now inherits from this base class, simplifying
its implementation.

**New Components**
* The new `RandomGenerator` class also inherits from
`RangeBasedGenerator`. It implements a strategy that randomly samples a
specified number of points from the total input space.
* Random number generation is handled by a new, self-contained
`RandomState` class (a `xorshift64*` PRNG seeded with `splitmix64`) to
ensure deterministic and reproducible random streams for testing.

**Example Usage**

As a first use case and demonstration of this new capability, this patch
also adds the first double-precision conformance test for the `log`
function. This test uses the new `RandomGenerator` to validate the
implementations from the `llvm-libm`, `cuda-math`, and `hip-math`
providers.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list