[llvm] [Offload][Conformance] Add tests for single-precision math functions (PR #152013)
Leandro Lacerda via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 4 11:56:56 PDT 2025
https://github.com/leandrolcampos created https://github.com/llvm/llvm-project/pull/152013
This patch adds a new set of conformance tests for single-precision math functions provided by the LLVM libm for GPUs.
The functions included in this set were selected based on the following criteria:
- An implementation exists in `libc/src/math/generic` (i.e., it is not just a wrapper around a compiler built-in).
- The corresponding LLVM CPU libm implementation is correctly rounded.
- The function is listed in Table 65 of the OpenCL C Specification v3.0.19.
>From e8fb8bff1bbd179703d5268862821c0db2fc7785 Mon Sep 17 00:00:00 2001
From: Leandro Augusto Lacerda Campos <leandrolcampos at yahoo.com.br>
Date: Mon, 4 Aug 2025 15:53:40 -0300
Subject: [PATCH] Add tests for single-precision math functions
---
.../Conformance/device_code/CMakeLists.txt | 2 +-
.../Conformance/device_code/Common.hpp | 38 ++++
.../Conformance/device_code/LLVMLibm.cpp | 168 ++++++++++++++++--
.../unittests/Conformance/tests/AcosfTest.cpp | 53 ++++++
.../Conformance/tests/AcoshfTest.cpp | 57 ++++++
.../unittests/Conformance/tests/AsinfTest.cpp | 53 ++++++
.../Conformance/tests/AsinhfTest.cpp | 54 ++++++
.../unittests/Conformance/tests/AtanfTest.cpp | 53 ++++++
.../Conformance/tests/AtanhfTest.cpp | 56 ++++++
.../Conformance/tests/CMakeLists.txt | 25 +++
.../unittests/Conformance/tests/CbrtfTest.cpp | 53 ++++++
.../unittests/Conformance/tests/CosfTest.cpp | 53 ++++++
.../unittests/Conformance/tests/CoshfTest.cpp | 53 ++++++
.../Conformance/tests/CospifTest.cpp | 56 ++++++
.../unittests/Conformance/tests/ErffTest.cpp | 53 ++++++
.../Conformance/tests/Exp10fTest.cpp | 54 ++++++
.../unittests/Conformance/tests/Exp2fTest.cpp | 53 ++++++
.../unittests/Conformance/tests/ExpfTest.cpp | 53 ++++++
.../Conformance/tests/Expm1fTest.cpp | 54 ++++++
.../Conformance/tests/Hypotf16Test.cpp | 5 +-
.../Conformance/tests/Log10fTest.cpp | 57 ++++++
.../Conformance/tests/Log1pfTest.cpp | 57 ++++++
.../unittests/Conformance/tests/Log2fTest.cpp | 56 ++++++
.../Conformance/tests/SincosfTest.cpp | 77 ++++++++
.../unittests/Conformance/tests/SinfTest.cpp | 53 ++++++
.../unittests/Conformance/tests/SinhfTest.cpp | 53 ++++++
.../Conformance/tests/SinpifTest.cpp | 56 ++++++
.../unittests/Conformance/tests/TanfTest.cpp | 53 ++++++
.../unittests/Conformance/tests/TanhfTest.cpp | 53 ++++++
.../Conformance/tests/TanpifTest.cpp | 56 ++++++
30 files changed, 1600 insertions(+), 17 deletions(-)
create mode 100644 offload/unittests/Conformance/device_code/Common.hpp
create mode 100644 offload/unittests/Conformance/tests/AcosfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/AcoshfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/AsinfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/AsinhfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/AtanfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/AtanhfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/CbrtfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/CosfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/CoshfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/CospifTest.cpp
create mode 100644 offload/unittests/Conformance/tests/ErffTest.cpp
create mode 100644 offload/unittests/Conformance/tests/Exp10fTest.cpp
create mode 100644 offload/unittests/Conformance/tests/Exp2fTest.cpp
create mode 100644 offload/unittests/Conformance/tests/ExpfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/Expm1fTest.cpp
create mode 100644 offload/unittests/Conformance/tests/Log10fTest.cpp
create mode 100644 offload/unittests/Conformance/tests/Log1pfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/Log2fTest.cpp
create mode 100644 offload/unittests/Conformance/tests/SincosfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/SinfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/SinhfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/SinpifTest.cpp
create mode 100644 offload/unittests/Conformance/tests/TanfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/TanhfTest.cpp
create mode 100644 offload/unittests/Conformance/tests/TanpifTest.cpp
diff --git a/offload/unittests/Conformance/device_code/CMakeLists.txt b/offload/unittests/Conformance/device_code/CMakeLists.txt
index 9cbd11096292c..a7f504dbadc9b 100644
--- a/offload/unittests/Conformance/device_code/CMakeLists.txt
+++ b/offload/unittests/Conformance/device_code/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_offload_test_device_code(LLVMLibm.cpp llvm-libm -stdlib -fno-builtin)
+add_offload_test_device_code(LLVMLibm.cpp llvm-libm -O3 -stdlib -fno-builtin -I.)
add_custom_target(conformance_device_binaries DEPENDS llvm-libm.bin)
set(OFFLOAD_CONFORMANCE_DEVICE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
diff --git a/offload/unittests/Conformance/device_code/Common.hpp b/offload/unittests/Conformance/device_code/Common.hpp
new file mode 100644
index 0000000000000..5f9c3bf673559
--- /dev/null
+++ b/offload/unittests/Conformance/device_code/Common.hpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains common utilities for defining device kernel wrappers to
+/// math functions.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef COMMON_HPP
+#define COMMON_HPP
+
+#include <gpuintrin.h>
+#include <stddef.h>
+#include <stdint.h>
+
+namespace common {
+
+typedef _Float16 float16;
+
+template <auto Func, typename OutType, typename... InTypes>
+__attribute__((always_inline)) void
+runKernelBody(size_t NumElements, OutType *Out, const InTypes *...Ins) {
+ uint32_t Index =
+ __gpu_num_threads_x() * __gpu_block_id_x() + __gpu_thread_id_x();
+
+ if (Index < NumElements) {
+ Out[Index] = Func(Ins[Index]...);
+ }
+}
+} // namespace common
+
+#endif // COMMON_HPP
diff --git a/offload/unittests/Conformance/device_code/LLVMLibm.cpp b/offload/unittests/Conformance/device_code/LLVMLibm.cpp
index 2c3d9bc5bf5cf..8d9412ee73c44 100644
--- a/offload/unittests/Conformance/device_code/LLVMLibm.cpp
+++ b/offload/unittests/Conformance/device_code/LLVMLibm.cpp
@@ -12,29 +12,173 @@
///
//===----------------------------------------------------------------------===//
+#include "Common.hpp"
+
#include <gpuintrin.h>
#include <math.h>
#include <stddef.h>
-#include <stdint.h>
-typedef _Float16 float16;
+using namespace common;
+
+//===----------------------------------------------------------------------===//
+// Helpers
+//===----------------------------------------------------------------------===//
+
+static inline float sincosfSin(float X) {
+ float SinX, CosX;
+ sincosf(X, &SinX, &CosX);
+ return SinX;
+}
+
+static inline float sincosfCos(float X) {
+ float SinX, CosX;
+ sincosf(X, &SinX, &CosX);
+ return CosX;
+}
+
+//===----------------------------------------------------------------------===//
+// Kernels
+//===----------------------------------------------------------------------===//
extern "C" {
+__gpu_kernel void acosfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<acosf>(NumElements, Out, X);
+}
+
+__gpu_kernel void acoshfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<acoshf>(NumElements, Out, X);
+}
+
+__gpu_kernel void asinfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<asinf>(NumElements, Out, X);
+}
+
+__gpu_kernel void asinhfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<asinhf>(NumElements, Out, X);
+}
+
+__gpu_kernel void atanfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<atanf>(NumElements, Out, X);
+}
+
+__gpu_kernel void atanhfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<atanhf>(NumElements, Out, X);
+}
+
+__gpu_kernel void cbrtfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<cbrtf>(NumElements, Out, X);
+}
+
+__gpu_kernel void cosfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<cosf>(NumElements, Out, X);
+}
+
+__gpu_kernel void coshfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<coshf>(NumElements, Out, X);
+}
+
+__gpu_kernel void cospifKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<cospif>(NumElements, Out, X);
+}
+
+__gpu_kernel void erffKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<erff>(NumElements, Out, X);
+}
+
+__gpu_kernel void expfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<expf>(NumElements, Out, X);
+}
+
+__gpu_kernel void exp10fKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<exp10f>(NumElements, Out, X);
+}
+
+__gpu_kernel void exp2fKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<exp2f>(NumElements, Out, X);
+}
+
+__gpu_kernel void expm1fKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<expm1f>(NumElements, Out, X);
+}
+
__gpu_kernel void hypotf16Kernel(const float16 *X, float16 *Y, float16 *Out,
- size_t NumElements) {
- uint32_t Index =
- __gpu_num_threads_x() * __gpu_block_id_x() + __gpu_thread_id_x();
+ size_t NumElements) noexcept {
+ runKernelBody<hypotf16>(NumElements, Out, X, Y);
+}
+
+__gpu_kernel void logfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<logf>(NumElements, Out, X);
+}
+
+__gpu_kernel void log10fKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<log10f>(NumElements, Out, X);
+}
- if (Index < NumElements)
- Out[Index] = hypotf16(X[Index], Y[Index]);
+__gpu_kernel void log1pfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<log1pf>(NumElements, Out, X);
}
-__gpu_kernel void logfKernel(const float *X, float *Out, size_t NumElements) {
- uint32_t Index =
- __gpu_num_threads_x() * __gpu_block_id_x() + __gpu_thread_id_x();
+__gpu_kernel void log2fKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<log2f>(NumElements, Out, X);
+}
+
+__gpu_kernel void sinfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<sinf>(NumElements, Out, X);
+}
+
+__gpu_kernel void sincosfSinKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<sincosfSin>(NumElements, Out, X);
+}
+
+__gpu_kernel void sincosfCosKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<sincosfCos>(NumElements, Out, X);
+}
+
+__gpu_kernel void sinhfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<sinhf>(NumElements, Out, X);
+}
+
+__gpu_kernel void sinpifKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<sinpif>(NumElements, Out, X);
+}
+
+__gpu_kernel void tanfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<tanf>(NumElements, Out, X);
+}
+
+__gpu_kernel void tanhfKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<tanhf>(NumElements, Out, X);
+}
- if (Index < NumElements)
- Out[Index] = logf(X[Index]);
+__gpu_kernel void tanpifKernel(const float *X, float *Out,
+ size_t NumElements) noexcept {
+ runKernelBody<tanpif>(NumElements, Out, X);
}
} // extern "C"
diff --git a/offload/unittests/Conformance/tests/AcosfTest.cpp b/offload/unittests/Conformance/tests/AcosfTest.cpp
new file mode 100644
index 0000000000000..e69ee3b7d1fd7
--- /dev/null
+++ b/offload/unittests/Conformance/tests/AcosfTest.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the acosf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<acosf> {
+ static constexpr llvm::StringRef Name = "acosf";
+ static constexpr llvm::StringRef KernelName = "acosfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 4;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the acosf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed = runTests<acosf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/AcoshfTest.cpp b/offload/unittests/Conformance/tests/AcoshfTest.cpp
new file mode 100644
index 0000000000000..4d43a661c3535
--- /dev/null
+++ b/offload/unittests/Conformance/tests/AcoshfTest.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the acoshf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <limits>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<acoshf> {
+ static constexpr llvm::StringRef Name = "acoshf";
+ static constexpr llvm::StringRef KernelName = "acoshfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 4;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the acoshf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range(/*Begin=*/1.0f,
+ /*End=*/std::numeric_limits<float>::infinity(),
+ /*Inclusive=*/true);
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed =
+ runTests<acoshf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/AsinfTest.cpp b/offload/unittests/Conformance/tests/AsinfTest.cpp
new file mode 100644
index 0000000000000..991f79b111efe
--- /dev/null
+++ b/offload/unittests/Conformance/tests/AsinfTest.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the asinf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<asinf> {
+ static constexpr llvm::StringRef Name = "asinf";
+ static constexpr llvm::StringRef KernelName = "asinfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 4;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the asinf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed = runTests<asinf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/AsinhfTest.cpp b/offload/unittests/Conformance/tests/AsinhfTest.cpp
new file mode 100644
index 0000000000000..9439383772314
--- /dev/null
+++ b/offload/unittests/Conformance/tests/AsinhfTest.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the asinhf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<asinhf> {
+ static constexpr llvm::StringRef Name = "asinhf";
+ static constexpr llvm::StringRef KernelName = "asinhfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 4;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the asinhf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed =
+ runTests<asinhf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/AtanfTest.cpp b/offload/unittests/Conformance/tests/AtanfTest.cpp
new file mode 100644
index 0000000000000..64068ef6bff0c
--- /dev/null
+++ b/offload/unittests/Conformance/tests/AtanfTest.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the atanf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<atanf> {
+ static constexpr llvm::StringRef Name = "atanf";
+ static constexpr llvm::StringRef KernelName = "atanfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 5;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the atanf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed = runTests<atanf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/AtanhfTest.cpp b/offload/unittests/Conformance/tests/AtanhfTest.cpp
new file mode 100644
index 0000000000000..66b934c2f925e
--- /dev/null
+++ b/offload/unittests/Conformance/tests/AtanhfTest.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the atanhf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<atanhf> {
+ static constexpr llvm::StringRef Name = "atanhf";
+ static constexpr llvm::StringRef KernelName = "atanhfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 5;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the atanhf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range(/*Begin=*/-1.0f,
+ /*End=*/1.0f,
+ /*Inclusive=*/true);
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed =
+ runTests<atanhf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/CMakeLists.txt b/offload/unittests/Conformance/tests/CMakeLists.txt
index b1aa22b44bb5c..5c0c3ba55c062 100644
--- a/offload/unittests/Conformance/tests/CMakeLists.txt
+++ b/offload/unittests/Conformance/tests/CMakeLists.txt
@@ -1,2 +1,27 @@
+add_conformance_test(acosf AcosfTest.cpp)
+add_conformance_test(acoshf AcoshfTest.cpp)
+add_conformance_test(asinf AsinfTest.cpp)
+add_conformance_test(asinhf AsinhfTest.cpp)
+add_conformance_test(atanf AtanfTest.cpp)
+add_conformance_test(atanhf AtanhfTest.cpp)
+add_conformance_test(cbrtf CbrtfTest.cpp)
+add_conformance_test(cosf CosfTest.cpp)
+add_conformance_test(coshf CoshfTest.cpp)
+add_conformance_test(cospif CospifTest.cpp)
+add_conformance_test(erff ErffTest.cpp)
+add_conformance_test(expf ExpfTest.cpp)
+add_conformance_test(exp10f Exp10fTest.cpp)
+add_conformance_test(exp2f Exp2fTest.cpp)
+add_conformance_test(expm1f Expm1fTest.cpp)
add_conformance_test(hypotf16 Hypotf16Test.cpp)
add_conformance_test(logf LogfTest.cpp)
+add_conformance_test(log10f Log10fTest.cpp)
+add_conformance_test(log1pf Log1pfTest.cpp)
+add_conformance_test(log2f Log2fTest.cpp)
+add_conformance_test(sinf SinfTest.cpp)
+add_conformance_test(sincosf SincosfTest.cpp)
+add_conformance_test(sinhf SinhfTest.cpp)
+add_conformance_test(sinpif SinpifTest.cpp)
+add_conformance_test(tanf TanfTest.cpp)
+add_conformance_test(tanhf TanhfTest.cpp)
+add_conformance_test(tanpif TanpifTest.cpp)
diff --git a/offload/unittests/Conformance/tests/CbrtfTest.cpp b/offload/unittests/Conformance/tests/CbrtfTest.cpp
new file mode 100644
index 0000000000000..81c1beab13919
--- /dev/null
+++ b/offload/unittests/Conformance/tests/CbrtfTest.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the cbrtf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<cbrtf> {
+ static constexpr llvm::StringRef Name = "cbrtf";
+ static constexpr llvm::StringRef KernelName = "cbrtfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 2;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the cbrtf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed = runTests<cbrtf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/CosfTest.cpp b/offload/unittests/Conformance/tests/CosfTest.cpp
new file mode 100644
index 0000000000000..3fa76926a568e
--- /dev/null
+++ b/offload/unittests/Conformance/tests/CosfTest.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the cosf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<cosf> {
+ static constexpr llvm::StringRef Name = "cosf";
+ static constexpr llvm::StringRef KernelName = "cosfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 4;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the cosf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed = runTests<cosf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/CoshfTest.cpp b/offload/unittests/Conformance/tests/CoshfTest.cpp
new file mode 100644
index 0000000000000..33ad515dcaddf
--- /dev/null
+++ b/offload/unittests/Conformance/tests/CoshfTest.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the coshf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<coshf> {
+ static constexpr llvm::StringRef Name = "coshf";
+ static constexpr llvm::StringRef KernelName = "coshfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 4;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the coshf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed = runTests<coshf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/CospifTest.cpp b/offload/unittests/Conformance/tests/CospifTest.cpp
new file mode 100644
index 0000000000000..8fe0ae184b050
--- /dev/null
+++ b/offload/unittests/Conformance/tests/CospifTest.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the cospif function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+extern "C" float cospif(float);
+
+namespace mathtest {
+
+template <> struct FunctionConfig<cospif> {
+ static constexpr llvm::StringRef Name = "cospif";
+ static constexpr llvm::StringRef KernelName = "cospifKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 4;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the cospif function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed =
+ runTests<cospif>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/ErffTest.cpp b/offload/unittests/Conformance/tests/ErffTest.cpp
new file mode 100644
index 0000000000000..20629509d7503
--- /dev/null
+++ b/offload/unittests/Conformance/tests/ErffTest.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the erff function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<erff> {
+ static constexpr llvm::StringRef Name = "erff";
+ static constexpr llvm::StringRef KernelName = "erffKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 16;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the erff function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed = runTests<erff>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/Exp10fTest.cpp b/offload/unittests/Conformance/tests/Exp10fTest.cpp
new file mode 100644
index 0000000000000..c4c88769250f3
--- /dev/null
+++ b/offload/unittests/Conformance/tests/Exp10fTest.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the exp10f function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<exp10f> {
+ static constexpr llvm::StringRef Name = "exp10f";
+ static constexpr llvm::StringRef KernelName = "exp10fKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 3;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the exp10f function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed =
+ runTests<exp10f>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/Exp2fTest.cpp b/offload/unittests/Conformance/tests/Exp2fTest.cpp
new file mode 100644
index 0000000000000..9d65ca059d008
--- /dev/null
+++ b/offload/unittests/Conformance/tests/Exp2fTest.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the exp2f function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<exp2f> {
+ static constexpr llvm::StringRef Name = "exp2f";
+ static constexpr llvm::StringRef KernelName = "exp2fKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 3;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the exp2f function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed = runTests<exp2f>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/ExpfTest.cpp b/offload/unittests/Conformance/tests/ExpfTest.cpp
new file mode 100644
index 0000000000000..996ad39f04738
--- /dev/null
+++ b/offload/unittests/Conformance/tests/ExpfTest.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the expf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<expf> {
+ static constexpr llvm::StringRef Name = "expf";
+ static constexpr llvm::StringRef KernelName = "expfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 3;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the expf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed = runTests<expf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/Expm1fTest.cpp b/offload/unittests/Conformance/tests/Expm1fTest.cpp
new file mode 100644
index 0000000000000..cfdf48aefe5c3
--- /dev/null
+++ b/offload/unittests/Conformance/tests/Expm1fTest.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the expm1f function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<expm1f> {
+ static constexpr llvm::StringRef Name = "expm1f";
+ static constexpr llvm::StringRef KernelName = "expm1fKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 3;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the expm1f function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed =
+ runTests<expm1f>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/Hypotf16Test.cpp b/offload/unittests/Conformance/tests/Hypotf16Test.cpp
index fbc001a9fb683..39094f4c24749 100644
--- a/offload/unittests/Conformance/tests/Hypotf16Test.cpp
+++ b/offload/unittests/Conformance/tests/Hypotf16Test.cpp
@@ -25,10 +25,7 @@
using namespace mathtest;
-extern "C" {
-
-float16 hypotf16(float16, float16);
-}
+extern "C" float16 hypotf16(float16, float16);
namespace mathtest {
diff --git a/offload/unittests/Conformance/tests/Log10fTest.cpp b/offload/unittests/Conformance/tests/Log10fTest.cpp
new file mode 100644
index 0000000000000..fc7cbab568659
--- /dev/null
+++ b/offload/unittests/Conformance/tests/Log10fTest.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the log10f function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <limits>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<log10f> {
+ static constexpr llvm::StringRef Name = "log10f";
+ static constexpr llvm::StringRef KernelName = "log10fKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 3;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the log10f function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range(/*Begin=*/0.0f,
+ /*End=*/std::numeric_limits<float>::infinity(),
+ /*Inclusive=*/true);
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed =
+ runTests<log10f>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/Log1pfTest.cpp b/offload/unittests/Conformance/tests/Log1pfTest.cpp
new file mode 100644
index 0000000000000..4388cf4ea1a95
--- /dev/null
+++ b/offload/unittests/Conformance/tests/Log1pfTest.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the log1pf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <limits>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<log1pf> {
+ static constexpr llvm::StringRef Name = "log1pf";
+ static constexpr llvm::StringRef KernelName = "log1pfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 2;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the log1pf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range(/*Begin=*/-1.0f,
+ /*End=*/std::numeric_limits<float>::infinity(),
+ /*Inclusive=*/true);
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed =
+ runTests<log1pf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/Log2fTest.cpp b/offload/unittests/Conformance/tests/Log2fTest.cpp
new file mode 100644
index 0000000000000..8c6fff177bb8b
--- /dev/null
+++ b/offload/unittests/Conformance/tests/Log2fTest.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the log2f function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <limits>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<log2f> {
+ static constexpr llvm::StringRef Name = "log2f";
+ static constexpr llvm::StringRef KernelName = "log2fKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 3;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the log2f function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range(/*Begin=*/0.0f,
+ /*End=*/std::numeric_limits<float>::infinity(),
+ /*Inclusive=*/true);
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed = runTests<log2f>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/SincosfTest.cpp b/offload/unittests/Conformance/tests/SincosfTest.cpp
new file mode 100644
index 0000000000000..2a70b51e4b057
--- /dev/null
+++ b/offload/unittests/Conformance/tests/SincosfTest.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the sincosf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+static inline float sincosfSin(float X) {
+ float SinX, CosX;
+ sincosf(X, &SinX, &CosX);
+ return SinX;
+}
+
+static inline float sincosfCos(float X) {
+ float SinX, CosX;
+ sincosf(X, &SinX, &CosX);
+ return CosX;
+}
+
+namespace mathtest {
+
+template <> struct FunctionConfig<sincosfSin> {
+ static constexpr llvm::StringRef Name = "sincosf (sin part)";
+ static constexpr llvm::StringRef KernelName = "sincosfSinKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 4;
+};
+
+template <> struct FunctionConfig<sincosfCos> {
+ static constexpr llvm::StringRef Name = "sincosf (cos part)";
+ static constexpr llvm::StringRef KernelName = "sincosfCosKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 4;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the sincosf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool SinPartPassed =
+ runTests<sincosfSin>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+ bool CosPartPassed =
+ runTests<sincosfCos>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return (SinPartPassed && CosPartPassed) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/SinfTest.cpp b/offload/unittests/Conformance/tests/SinfTest.cpp
new file mode 100644
index 0000000000000..b5f2b34ff57ac
--- /dev/null
+++ b/offload/unittests/Conformance/tests/SinfTest.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the sinf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<sinf> {
+ static constexpr llvm::StringRef Name = "sinf";
+ static constexpr llvm::StringRef KernelName = "sinfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 4;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the sinf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed = runTests<sinf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/SinhfTest.cpp b/offload/unittests/Conformance/tests/SinhfTest.cpp
new file mode 100644
index 0000000000000..d0510687f51e6
--- /dev/null
+++ b/offload/unittests/Conformance/tests/SinhfTest.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the sinhf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<sinhf> {
+ static constexpr llvm::StringRef Name = "sinhf";
+ static constexpr llvm::StringRef KernelName = "sinhfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 4;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the sinhf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed = runTests<sinhf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/SinpifTest.cpp b/offload/unittests/Conformance/tests/SinpifTest.cpp
new file mode 100644
index 0000000000000..745af111f99a2
--- /dev/null
+++ b/offload/unittests/Conformance/tests/SinpifTest.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the sinpif function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+extern "C" float sinpif(float);
+
+namespace mathtest {
+
+template <> struct FunctionConfig<sinpif> {
+ static constexpr llvm::StringRef Name = "sinpif";
+ static constexpr llvm::StringRef KernelName = "sinpifKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 4;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the sinpif function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed =
+ runTests<sinpif>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/TanfTest.cpp b/offload/unittests/Conformance/tests/TanfTest.cpp
new file mode 100644
index 0000000000000..0fe7d9651cece
--- /dev/null
+++ b/offload/unittests/Conformance/tests/TanfTest.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the tanf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<tanf> {
+ static constexpr llvm::StringRef Name = "tanf";
+ static constexpr llvm::StringRef KernelName = "tanfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 5;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the tanf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed = runTests<tanf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/TanhfTest.cpp b/offload/unittests/Conformance/tests/TanhfTest.cpp
new file mode 100644
index 0000000000000..6de4c146544d8
--- /dev/null
+++ b/offload/unittests/Conformance/tests/TanhfTest.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the tanhf function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+namespace mathtest {
+
+template <> struct FunctionConfig<tanhf> {
+ static constexpr llvm::StringRef Name = "tanhf";
+ static constexpr llvm::StringRef KernelName = "tanhfKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 5;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the tanhf function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed = runTests<tanhf>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/offload/unittests/Conformance/tests/TanpifTest.cpp b/offload/unittests/Conformance/tests/TanpifTest.cpp
new file mode 100644
index 0000000000000..dabfdd865cb02
--- /dev/null
+++ b/offload/unittests/Conformance/tests/TanpifTest.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the conformance test of the tanpif function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "mathtest/CommandLineExtras.hpp"
+#include "mathtest/ExhaustiveGenerator.hpp"
+#include "mathtest/IndexedRange.hpp"
+#include "mathtest/TestConfig.hpp"
+#include "mathtest/TestRunner.hpp"
+
+#include "llvm/ADT/StringRef.h"
+
+#include <cstdlib>
+#include <math.h>
+
+extern "C" float tanpif(float);
+
+namespace mathtest {
+
+template <> struct FunctionConfig<tanpif> {
+ static constexpr llvm::StringRef Name = "tanpif";
+ static constexpr llvm::StringRef KernelName = "tanpifKernel";
+
+ // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4,
+ // Table 65, Khronos Registry [July 10, 2025].
+ static constexpr uint64_t UlpTolerance = 6;
+};
+} // namespace mathtest
+
+int main(int argc, const char **argv) {
+ llvm::cl::ParseCommandLineOptions(argc, argv,
+ "Conformance test of the tanpif function");
+
+ using namespace mathtest;
+
+ IndexedRange<float> Range;
+ ExhaustiveGenerator<float> Generator(Range);
+
+ const auto Configs = cl::getTestConfigs();
+ const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR;
+ const bool IsVerbose = cl::IsVerbose;
+
+ bool Passed =
+ runTests<tanpif>(Generator, Configs, DeviceBinaryDir, IsVerbose);
+
+ return Passed ? EXIT_SUCCESS : EXIT_FAILURE;
+}
More information about the llvm-commits
mailing list