From b9cec8d8653cda3199514b7e9f42e03c1bd347df Mon Sep 17 00:00:00 2001 From: Leandro Augusto Lacerda Campos Date: Fri, 22 Aug 2025 22:49:48 -0300 Subject: [PATCH 1/2] Add exhaustive tests for half-precision math functions --- .../Conformance/device_code/DeviceAPIs.hpp | 19 +++ .../Conformance/device_code/HIPMath.cpp | 95 +++++++++++++++ .../Conformance/device_code/LLVMLibm.cpp | 115 ++++++++++++++++++ .../Conformance/tests/Acosf16Test.cpp | 61 ++++++++++ .../Conformance/tests/Acoshf16Test.cpp | 62 ++++++++++ .../Conformance/tests/Acospif16Test.cpp | 61 ++++++++++ .../Conformance/tests/Asinf16Test.cpp | 61 ++++++++++ .../Conformance/tests/Asinhf16Test.cpp | 59 +++++++++ .../Conformance/tests/Atanf16Test.cpp | 59 +++++++++ .../Conformance/tests/Atanhf16Test.cpp | 61 ++++++++++ .../Conformance/tests/CMakeLists.txt | 23 ++++ .../Conformance/tests/Cosf16Test.cpp | 59 +++++++++ .../Conformance/tests/Coshf16Test.cpp | 59 +++++++++ .../Conformance/tests/Cospif16Test.cpp | 59 +++++++++ .../Conformance/tests/Exp10f16Test.cpp | 59 +++++++++ .../Conformance/tests/Exp2f16Test.cpp | 59 +++++++++ .../Conformance/tests/Expf16Test.cpp | 59 +++++++++ .../Conformance/tests/Expm1f16Test.cpp | 59 +++++++++ .../Conformance/tests/Log10f16Test.cpp | 62 ++++++++++ .../Conformance/tests/Log2f16Test.cpp | 62 ++++++++++ .../Conformance/tests/Logf16Test.cpp | 62 ++++++++++ .../Conformance/tests/Sinf16Test.cpp | 59 +++++++++ .../Conformance/tests/Sinhf16Test.cpp | 59 +++++++++ .../Conformance/tests/Sinpif16Test.cpp | 59 +++++++++ .../Conformance/tests/Tanf16Test.cpp | 61 ++++++++++ .../Conformance/tests/Tanhf16Test.cpp | 59 +++++++++ .../Conformance/tests/Tanpif16Test.cpp | 59 +++++++++ 27 files changed, 1631 insertions(+) create mode 100644 offload/unittests/Conformance/tests/Acosf16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Acoshf16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Acospif16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Asinf16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Asinhf16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Atanf16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Atanhf16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Cosf16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Coshf16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Cospif16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Exp10f16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Exp2f16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Expf16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Expm1f16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Log10f16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Log2f16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Logf16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Sinf16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Sinhf16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Sinpif16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Tanf16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Tanhf16Test.cpp create mode 100644 offload/unittests/Conformance/tests/Tanpif16Test.cpp diff --git a/offload/unittests/Conformance/device_code/DeviceAPIs.hpp b/offload/unittests/Conformance/device_code/DeviceAPIs.hpp index 32f21991d9ec3..894652a8e1af1 100644 --- a/offload/unittests/Conformance/device_code/DeviceAPIs.hpp +++ b/offload/unittests/Conformance/device_code/DeviceAPIs.hpp @@ -103,49 +103,68 @@ extern "C" { double __ocml_acos_f64(double); float __ocml_acos_f32(float); +float16 __ocml_acos_f16(float16); float __ocml_acosh_f32(float); +float16 __ocml_acosh_f16(float16); double __ocml_asin_f64(double); float __ocml_asin_f32(float); +float16 __ocml_asin_f16(float16); float __ocml_asinh_f32(float); +float16 __ocml_asinh_f16(float16); float __ocml_atan_f32(float); +float16 __ocml_atan_f16(float16); float __ocml_atan2_f32(float, float); float __ocml_atanh_f32(float); +float16 __ocml_atanh_f16(float16); double __ocml_cbrt_f64(double); float __ocml_cbrt_f32(float); double __ocml_cos_f64(double); float __ocml_cos_f32(float); +float16 __ocml_cos_f16(float16); float __ocml_cosh_f32(float); +float16 __ocml_cosh_f16(float16); float __ocml_cospi_f32(float); float __ocml_erf_f32(float); double __ocml_exp_f64(double); float __ocml_exp_f32(float); +float16 __ocml_exp_f16(float16); double __ocml_exp10_f64(double); float __ocml_exp10_f32(float); +float16 __ocml_exp10_f16(float16); double __ocml_exp2_f64(double); float __ocml_exp2_f32(float); +float16 __ocml_exp2_f16(float16); double __ocml_expm1_f64(double); float __ocml_expm1_f32(float); +float16 __ocml_expm1_f16(float16); double __ocml_hypot_f64(double, double); float __ocml_hypot_f32(float, float); double __ocml_log_f64(double); float __ocml_log_f32(float); +float16 __ocml_log_f16(float16); double __ocml_log10_f64(double); float __ocml_log10_f32(float); +float16 __ocml_log10_f16(float16); double __ocml_log1p_f64(double); float __ocml_log1p_f32(float); double __ocml_log2_f64(double); float __ocml_log2_f32(float); +float16 __ocml_log2_f16(float16); float __ocml_pow_f32(float, float); float __ocml_round_f32(float); double __ocml_sin_f64(double); float __ocml_sin_f32(float); +float16 __ocml_sin_f16(float16); double __ocml_sincos_f64(double, double *); float __ocml_sincos_f32(float, float *); float __ocml_sinh_f32(float); +float16 __ocml_sinh_f16(float16); float __ocml_sinpi_f32(float); double __ocml_tan_f64(double); float __ocml_tan_f32(float); +float16 __ocml_tan_f16(float16); float __ocml_tanh_f32(float); +float16 __ocml_tanh_f16(float16); } // extern "C" #endif // HIP_MATH_FOUND diff --git a/offload/unittests/Conformance/device_code/HIPMath.cpp b/offload/unittests/Conformance/device_code/HIPMath.cpp index 71dea4c8d2656..7cc0ad5d9142e 100644 --- a/offload/unittests/Conformance/device_code/HIPMath.cpp +++ b/offload/unittests/Conformance/device_code/HIPMath.cpp @@ -70,11 +70,21 @@ __gpu_kernel void acosfKernel(const float *X, float *Out, runKernelBody<__ocml_acos_f32>(NumElements, Out, X); } +__gpu_kernel void acosf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_acos_f16>(NumElements, Out, X); +} + __gpu_kernel void acoshfKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody<__ocml_acosh_f32>(NumElements, Out, X); } +__gpu_kernel void acoshf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_acosh_f16>(NumElements, Out, X); +} + __gpu_kernel void asinKernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody<__ocml_asin_f64>(NumElements, Out, X); @@ -85,16 +95,31 @@ __gpu_kernel void asinfKernel(const float *X, float *Out, runKernelBody<__ocml_asin_f32>(NumElements, Out, X); } +__gpu_kernel void asinf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_asin_f16>(NumElements, Out, X); +} + __gpu_kernel void asinhfKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody<__ocml_asinh_f32>(NumElements, Out, X); } +__gpu_kernel void asinhf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_asinh_f16>(NumElements, Out, X); +} + __gpu_kernel void atanfKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody<__ocml_atan_f32>(NumElements, Out, X); } +__gpu_kernel void atanf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_atan_f16>(NumElements, Out, X); +} + __gpu_kernel void atan2fKernel(const float *X, const float *Y, float *Out, size_t NumElements) noexcept { runKernelBody<__ocml_atan2_f32>(NumElements, Out, X, Y); @@ -105,6 +130,11 @@ __gpu_kernel void atanhfKernel(const float *X, float *Out, runKernelBody<__ocml_atanh_f32>(NumElements, Out, X); } +__gpu_kernel void atanhf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_atanh_f16>(NumElements, Out, X); +} + __gpu_kernel void cbrtKernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody<__ocml_cbrt_f64>(NumElements, Out, X); @@ -125,11 +155,21 @@ __gpu_kernel void cosfKernel(const float *X, float *Out, runKernelBody<__ocml_cos_f32>(NumElements, Out, X); } +__gpu_kernel void cosf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_cos_f16>(NumElements, Out, X); +} + __gpu_kernel void coshfKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody<__ocml_cosh_f32>(NumElements, Out, X); } +__gpu_kernel void coshf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_cosh_f16>(NumElements, Out, X); +} + __gpu_kernel void cospifKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody<__ocml_cospi_f32>(NumElements, Out, X); @@ -150,6 +190,11 @@ __gpu_kernel void expfKernel(const float *X, float *Out, runKernelBody<__ocml_exp_f32>(NumElements, Out, X); } +__gpu_kernel void expf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_exp_f16>(NumElements, Out, X); +} + __gpu_kernel void exp10Kernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody<__ocml_exp10_f64>(NumElements, Out, X); @@ -160,6 +205,11 @@ __gpu_kernel void exp10fKernel(const float *X, float *Out, runKernelBody<__ocml_exp10_f32>(NumElements, Out, X); } +__gpu_kernel void exp10f16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_exp10_f16>(NumElements, Out, X); +} + __gpu_kernel void exp2Kernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody<__ocml_exp2_f64>(NumElements, Out, X); @@ -170,6 +220,11 @@ __gpu_kernel void exp2fKernel(const float *X, float *Out, runKernelBody<__ocml_exp2_f32>(NumElements, Out, X); } +__gpu_kernel void exp2f16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_exp2_f16>(NumElements, Out, X); +} + __gpu_kernel void expm1Kernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody<__ocml_expm1_f64>(NumElements, Out, X); @@ -180,6 +235,11 @@ __gpu_kernel void expm1fKernel(const float *X, float *Out, runKernelBody<__ocml_expm1_f32>(NumElements, Out, X); } +__gpu_kernel void expm1f16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_expm1_f16>(NumElements, Out, X); +} + __gpu_kernel void hypotKernel(const double *X, const double *Y, double *Out, size_t NumElements) noexcept { runKernelBody<__ocml_hypot_f64>(NumElements, Out, X, Y); @@ -200,6 +260,11 @@ __gpu_kernel void logfKernel(const float *X, float *Out, runKernelBody<__ocml_log_f32>(NumElements, Out, X); } +__gpu_kernel void logf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_log_f16>(NumElements, Out, X); +} + __gpu_kernel void log10Kernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody<__ocml_log10_f64>(NumElements, Out, X); @@ -210,6 +275,11 @@ __gpu_kernel void log10fKernel(const float *X, float *Out, runKernelBody<__ocml_log10_f32>(NumElements, Out, X); } +__gpu_kernel void log10f16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_log10_f16>(NumElements, Out, X); +} + __gpu_kernel void log1pKernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody<__ocml_log1p_f64>(NumElements, Out, X); @@ -230,6 +300,11 @@ __gpu_kernel void log2fKernel(const float *X, float *Out, runKernelBody<__ocml_log2_f32>(NumElements, Out, X); } +__gpu_kernel void log2f16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_log2_f16>(NumElements, Out, X); +} + __gpu_kernel void powfKernel(const float *X, float *Y, float *Out, size_t NumElements) noexcept { runKernelBody<__ocml_pow_f32>(NumElements, Out, X, Y); @@ -251,6 +326,11 @@ __gpu_kernel void sinfKernel(const float *X, float *Out, runKernelBody<__ocml_sin_f32>(NumElements, Out, X); } +__gpu_kernel void sinf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_sin_f16>(NumElements, Out, X); +} + __gpu_kernel void sincosSinKernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); @@ -276,6 +356,11 @@ __gpu_kernel void sinhfKernel(const float *X, float *Out, runKernelBody<__ocml_sinh_f32>(NumElements, Out, X); } +__gpu_kernel void sinhf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_sinh_f16>(NumElements, Out, X); +} + __gpu_kernel void sinpifKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody<__ocml_sinpi_f32>(NumElements, Out, X); @@ -291,10 +376,20 @@ __gpu_kernel void tanfKernel(const float *X, float *Out, runKernelBody<__ocml_tan_f32>(NumElements, Out, X); } +__gpu_kernel void tanf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_tan_f16>(NumElements, Out, X); +} + __gpu_kernel void tanhfKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody<__ocml_tanh_f32>(NumElements, Out, X); } + +__gpu_kernel void tanhf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody<__ocml_tanh_f16>(NumElements, Out, X); +} } // extern "C" #endif // HIP_MATH_FOUND diff --git a/offload/unittests/Conformance/device_code/LLVMLibm.cpp b/offload/unittests/Conformance/device_code/LLVMLibm.cpp index baf23a3467f35..8673d809fd0a2 100644 --- a/offload/unittests/Conformance/device_code/LLVMLibm.cpp +++ b/offload/unittests/Conformance/device_code/LLVMLibm.cpp @@ -69,11 +69,26 @@ __gpu_kernel void acosfKernel(const float *X, float *Out, runKernelBody(NumElements, Out, X); } +__gpu_kernel void acosf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void acoshfKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); } +__gpu_kernel void acoshf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + +__gpu_kernel void acospif16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void asinKernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); @@ -84,16 +99,31 @@ __gpu_kernel void asinfKernel(const float *X, float *Out, runKernelBody(NumElements, Out, X); } +__gpu_kernel void asinf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void asinhfKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); } +__gpu_kernel void asinhf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void atanfKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); } +__gpu_kernel void atanf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void atan2fKernel(const float *X, const float *Y, float *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X, Y); @@ -104,6 +134,11 @@ __gpu_kernel void atanhfKernel(const float *X, float *Out, runKernelBody(NumElements, Out, X); } +__gpu_kernel void atanhf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void cbrtKernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); @@ -124,16 +159,31 @@ __gpu_kernel void cosfKernel(const float *X, float *Out, runKernelBody(NumElements, Out, X); } +__gpu_kernel void cosf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void coshfKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); } +__gpu_kernel void coshf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void cospifKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); } +__gpu_kernel void cospif16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void erffKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); @@ -149,6 +199,11 @@ __gpu_kernel void expfKernel(const float *X, float *Out, runKernelBody(NumElements, Out, X); } +__gpu_kernel void expf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void exp10Kernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); @@ -159,6 +214,11 @@ __gpu_kernel void exp10fKernel(const float *X, float *Out, runKernelBody(NumElements, Out, X); } +__gpu_kernel void exp10f16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void exp2Kernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); @@ -169,6 +229,11 @@ __gpu_kernel void exp2fKernel(const float *X, float *Out, runKernelBody(NumElements, Out, X); } +__gpu_kernel void exp2f16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void expm1Kernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); @@ -179,6 +244,11 @@ __gpu_kernel void expm1fKernel(const float *X, float *Out, runKernelBody(NumElements, Out, X); } +__gpu_kernel void expm1f16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void hypotKernel(const double *X, const double *Y, double *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X, Y); @@ -204,6 +274,11 @@ __gpu_kernel void logfKernel(const float *X, float *Out, runKernelBody(NumElements, Out, X); } +__gpu_kernel void logf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void log10Kernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); @@ -214,6 +289,11 @@ __gpu_kernel void log10fKernel(const float *X, float *Out, runKernelBody(NumElements, Out, X); } +__gpu_kernel void log10f16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void log1pKernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); @@ -234,6 +314,11 @@ __gpu_kernel void log2fKernel(const float *X, float *Out, runKernelBody(NumElements, Out, X); } +__gpu_kernel void log2f16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void powfKernel(const float *X, float *Y, float *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X, Y); @@ -255,6 +340,11 @@ __gpu_kernel void sinfKernel(const float *X, float *Out, runKernelBody(NumElements, Out, X); } +__gpu_kernel void sinf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void sincosSinKernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); @@ -280,11 +370,21 @@ __gpu_kernel void sinhfKernel(const float *X, float *Out, runKernelBody(NumElements, Out, X); } +__gpu_kernel void sinhf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void sinpifKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); } +__gpu_kernel void sinpif16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void tanKernel(const double *X, double *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); @@ -295,13 +395,28 @@ __gpu_kernel void tanfKernel(const float *X, float *Out, runKernelBody(NumElements, Out, X); } +__gpu_kernel void tanf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void tanhfKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); } +__gpu_kernel void tanhf16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} + __gpu_kernel void tanpifKernel(const float *X, float *Out, size_t NumElements) noexcept { runKernelBody(NumElements, Out, X); } + +__gpu_kernel void tanpif16Kernel(const float16 *X, float16 *Out, + size_t NumElements) noexcept { + runKernelBody(NumElements, Out, X); +} } // extern "C" diff --git a/offload/unittests/Conformance/tests/Acosf16Test.cpp b/offload/unittests/Conformance/tests/Acosf16Test.cpp new file mode 100644 index 0000000000000..ce11cc2aa1e83 --- /dev/null +++ b/offload/unittests/Conformance/tests/Acosf16Test.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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 acosf16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 acosf16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "acosf16"; + static constexpr llvm::StringRef KernelName = "acosf16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 acosf16 function"); + + using namespace mathtest; + + IndexedRange Range(/*Begin=*/float16(-1.0), + /*End=*/float16(1.0), + /*Inclusive=*/true); + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Acoshf16Test.cpp b/offload/unittests/Conformance/tests/Acoshf16Test.cpp new file mode 100644 index 0000000000000..80434477aa437 --- /dev/null +++ b/offload/unittests/Conformance/tests/Acoshf16Test.cpp @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// 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 acoshf16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/Numerics.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 acoshf16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "acoshf16"; + static constexpr llvm::StringRef KernelName = "acoshf16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 acoshf16 function"); + + using namespace mathtest; + + IndexedRange Range(/*Begin=*/float16(1.0), + /*End=*/getMaxOrInf(), + /*Inclusive=*/true); + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Acospif16Test.cpp b/offload/unittests/Conformance/tests/Acospif16Test.cpp new file mode 100644 index 0000000000000..c5871e27cafc2 --- /dev/null +++ b/offload/unittests/Conformance/tests/Acospif16Test.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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 acospif16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 acospif16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "acospif16"; + static constexpr llvm::StringRef KernelName = "acospif16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 acospif16 function"); + + using namespace mathtest; + + IndexedRange Range(/*Begin=*/float16(-1.0), + /*End=*/float16(1.0), + /*Inclusive=*/true); + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Asinf16Test.cpp b/offload/unittests/Conformance/tests/Asinf16Test.cpp new file mode 100644 index 0000000000000..5784d6bfe08e0 --- /dev/null +++ b/offload/unittests/Conformance/tests/Asinf16Test.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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 asinf16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 asinf16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "asinf16"; + static constexpr llvm::StringRef KernelName = "asinf16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 asinf16 function"); + + using namespace mathtest; + + IndexedRange Range(/*Begin=*/float16(-1.0), + /*End=*/float16(1.0), + /*Inclusive=*/true); + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Asinhf16Test.cpp b/offload/unittests/Conformance/tests/Asinhf16Test.cpp new file mode 100644 index 0000000000000..0af9bcb06fef0 --- /dev/null +++ b/offload/unittests/Conformance/tests/Asinhf16Test.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 asinhf16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 asinhf16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "asinhf16"; + static constexpr llvm::StringRef KernelName = "asinhf16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 asinhf16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Atanf16Test.cpp b/offload/unittests/Conformance/tests/Atanf16Test.cpp new file mode 100644 index 0000000000000..3d3fa384e84df --- /dev/null +++ b/offload/unittests/Conformance/tests/Atanf16Test.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 atanf16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 atanf16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "atanf16"; + static constexpr llvm::StringRef KernelName = "atanf16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 atanf16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Atanhf16Test.cpp b/offload/unittests/Conformance/tests/Atanhf16Test.cpp new file mode 100644 index 0000000000000..86a0f82ce376c --- /dev/null +++ b/offload/unittests/Conformance/tests/Atanhf16Test.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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 atanhf16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 atanhf16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "atanhf16"; + static constexpr llvm::StringRef KernelName = "atanhf16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 atanhf16 function"); + + using namespace mathtest; + + IndexedRange Range(/*Begin=*/float16(-1.0), + /*End=*/float16(1.0), + /*Inclusive=*/true); + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(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 b608a52f8061d..ad94df8e79788 100644 --- a/offload/unittests/Conformance/tests/CMakeLists.txt +++ b/offload/unittests/Conformance/tests/CMakeLists.txt @@ -5,47 +5,70 @@ endif() add_conformance_test(acos AcosTest.cpp) add_conformance_test(acosf AcosfTest.cpp) +add_conformance_test(acosf16 Acosf16Test.cpp) add_conformance_test(acoshf AcoshfTest.cpp) +add_conformance_test(acoshf16 Acoshf16Test.cpp) +add_conformance_test(acospif16 Acospif16Test.cpp) add_conformance_test(asin AsinTest.cpp) add_conformance_test(asinf AsinfTest.cpp) +add_conformance_test(asinf16 Asinf16Test.cpp) add_conformance_test(asinhf AsinhfTest.cpp) +add_conformance_test(asinhf16 Asinhf16Test.cpp) add_conformance_test(atanf AtanfTest.cpp) +add_conformance_test(atanf16 Atanf16Test.cpp) add_conformance_test(atan2f Atan2fTest.cpp) add_conformance_test(atanhf AtanhfTest.cpp) +add_conformance_test(atanhf16 Atanhf16Test.cpp) add_conformance_test(cbrt CbrtTest.cpp) add_conformance_test(cbrtf CbrtfTest.cpp) add_conformance_test(cos CosTest.cpp) add_conformance_test(cosf CosfTest.cpp) +add_conformance_test(cosf16 Cosf16Test.cpp) add_conformance_test(coshf CoshfTest.cpp) +add_conformance_test(coshf16 Coshf16Test.cpp) add_conformance_test(cospif CospifTest.cpp) +add_conformance_test(cospif16 Cospif16Test.cpp) add_conformance_test(erff ErffTest.cpp) add_conformance_test(exp ExpTest.cpp) add_conformance_test(expf ExpfTest.cpp) +add_conformance_test(expf16 Expf16Test.cpp) add_conformance_test(exp10 Exp10Test.cpp) add_conformance_test(exp10f Exp10fTest.cpp) +add_conformance_test(exp10f16 Exp10f16Test.cpp) add_conformance_test(exp2 Exp2Test.cpp) add_conformance_test(exp2f Exp2fTest.cpp) +add_conformance_test(exp2f16 Exp2f16Test.cpp) add_conformance_test(expm1 Expm1Test.cpp) add_conformance_test(expm1f Expm1fTest.cpp) +add_conformance_test(expm1f16 Expm1f16Test.cpp) add_conformance_test(hypot HypotTest.cpp) add_conformance_test(hypotf HypotfTest.cpp) add_conformance_test(hypotf16 Hypotf16Test.cpp) add_conformance_test(log LogTest.cpp) add_conformance_test(logf LogfTest.cpp) +add_conformance_test(logf16 Logf16Test.cpp) add_conformance_test(log10 Log10Test.cpp) add_conformance_test(log10f Log10fTest.cpp) +add_conformance_test(log10f16 Log10f16Test.cpp) add_conformance_test(log1p Log1pTest.cpp) add_conformance_test(log1pf Log1pfTest.cpp) add_conformance_test(log2 Log2Test.cpp) add_conformance_test(log2f Log2fTest.cpp) +add_conformance_test(log2f16 Log2f16Test.cpp) add_conformance_test(powf PowfTest.cpp) add_conformance_test(sin SinTest.cpp) add_conformance_test(sinf SinfTest.cpp) +add_conformance_test(sinf16 Sinf16Test.cpp) add_conformance_test(sincos SincosTest.cpp) add_conformance_test(sincosf SincosfTest.cpp) add_conformance_test(sinhf SinhfTest.cpp) +add_conformance_test(sinhf16 Sinhf16Test.cpp) add_conformance_test(sinpif SinpifTest.cpp) +add_conformance_test(sinpif16 Sinpif16Test.cpp) add_conformance_test(tan TanTest.cpp) add_conformance_test(tanf TanfTest.cpp) +add_conformance_test(tanf16 Tanf16Test.cpp) add_conformance_test(tanhf TanhfTest.cpp) +add_conformance_test(tanhf16 Tanhf16Test.cpp) add_conformance_test(tanpif TanpifTest.cpp) +add_conformance_test(tanpif16 Tanpif16Test.cpp) diff --git a/offload/unittests/Conformance/tests/Cosf16Test.cpp b/offload/unittests/Conformance/tests/Cosf16Test.cpp new file mode 100644 index 0000000000000..680e4b99c549f --- /dev/null +++ b/offload/unittests/Conformance/tests/Cosf16Test.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 cosf16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 cosf16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "cosf16"; + static constexpr llvm::StringRef KernelName = "cosf16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 cosf16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Coshf16Test.cpp b/offload/unittests/Conformance/tests/Coshf16Test.cpp new file mode 100644 index 0000000000000..1b378b5a9401a --- /dev/null +++ b/offload/unittests/Conformance/tests/Coshf16Test.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 coshf16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 coshf16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "coshf16"; + static constexpr llvm::StringRef KernelName = "coshf16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 coshf16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Cospif16Test.cpp b/offload/unittests/Conformance/tests/Cospif16Test.cpp new file mode 100644 index 0000000000000..84aa682b48847 --- /dev/null +++ b/offload/unittests/Conformance/tests/Cospif16Test.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 cospif16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 cospif16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "cospif16"; + static constexpr llvm::StringRef KernelName = "cospif16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 cospif16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Exp10f16Test.cpp b/offload/unittests/Conformance/tests/Exp10f16Test.cpp new file mode 100644 index 0000000000000..7d61ad0c6aef6 --- /dev/null +++ b/offload/unittests/Conformance/tests/Exp10f16Test.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 exp10f16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 exp10f16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "exp10f16"; + static constexpr llvm::StringRef KernelName = "exp10f16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 exp10f16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Exp2f16Test.cpp b/offload/unittests/Conformance/tests/Exp2f16Test.cpp new file mode 100644 index 0000000000000..9ea92564e7389 --- /dev/null +++ b/offload/unittests/Conformance/tests/Exp2f16Test.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 exp2f16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 exp2f16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "exp2f16"; + static constexpr llvm::StringRef KernelName = "exp2f16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 exp2f16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Expf16Test.cpp b/offload/unittests/Conformance/tests/Expf16Test.cpp new file mode 100644 index 0000000000000..8938815e26a8c --- /dev/null +++ b/offload/unittests/Conformance/tests/Expf16Test.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 expf16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 expf16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "expf16"; + static constexpr llvm::StringRef KernelName = "expf16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 expf16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Expm1f16Test.cpp b/offload/unittests/Conformance/tests/Expm1f16Test.cpp new file mode 100644 index 0000000000000..447196bb8ea37 --- /dev/null +++ b/offload/unittests/Conformance/tests/Expm1f16Test.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 expm1f16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 expm1f16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "expm1f16"; + static constexpr llvm::StringRef KernelName = "expm1f16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 expm1f16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Log10f16Test.cpp b/offload/unittests/Conformance/tests/Log10f16Test.cpp new file mode 100644 index 0000000000000..605e1ae49077e --- /dev/null +++ b/offload/unittests/Conformance/tests/Log10f16Test.cpp @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// 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 log10f16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/Numerics.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 log10f16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "log10f16"; + static constexpr llvm::StringRef KernelName = "log10f16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 log10f16 function"); + + using namespace mathtest; + + IndexedRange Range(/*Begin=*/float16(0.0), + /*End=*/getMaxOrInf(), + /*Inclusive=*/true); + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Log2f16Test.cpp b/offload/unittests/Conformance/tests/Log2f16Test.cpp new file mode 100644 index 0000000000000..5ce46960774a0 --- /dev/null +++ b/offload/unittests/Conformance/tests/Log2f16Test.cpp @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// 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 log2f16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/Numerics.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 log2f16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "log2f16"; + static constexpr llvm::StringRef KernelName = "log2f16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 log2f16 function"); + + using namespace mathtest; + + IndexedRange Range(/*Begin=*/float16(0.0), + /*End=*/getMaxOrInf(), + /*Inclusive=*/true); + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Logf16Test.cpp b/offload/unittests/Conformance/tests/Logf16Test.cpp new file mode 100644 index 0000000000000..372dccb2ebb9a --- /dev/null +++ b/offload/unittests/Conformance/tests/Logf16Test.cpp @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// 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 logf16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/Numerics.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 logf16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "logf16"; + static constexpr llvm::StringRef KernelName = "logf16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 logf16 function"); + + using namespace mathtest; + + IndexedRange Range(/*Begin=*/float16(0.0), + /*End=*/getMaxOrInf(), + /*Inclusive=*/true); + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Sinf16Test.cpp b/offload/unittests/Conformance/tests/Sinf16Test.cpp new file mode 100644 index 0000000000000..4c5fb22262889 --- /dev/null +++ b/offload/unittests/Conformance/tests/Sinf16Test.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 sinf16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 sinf16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "sinf16"; + static constexpr llvm::StringRef KernelName = "sinf16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 sinf16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Sinhf16Test.cpp b/offload/unittests/Conformance/tests/Sinhf16Test.cpp new file mode 100644 index 0000000000000..fe6f7dd4a49c2 --- /dev/null +++ b/offload/unittests/Conformance/tests/Sinhf16Test.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 sinhf16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 sinhf16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "sinhf16"; + static constexpr llvm::StringRef KernelName = "sinhf16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 sinhf16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Sinpif16Test.cpp b/offload/unittests/Conformance/tests/Sinpif16Test.cpp new file mode 100644 index 0000000000000..ff9c93c0bb5b8 --- /dev/null +++ b/offload/unittests/Conformance/tests/Sinpif16Test.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 sinpif16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 sinpif16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "sinpif16"; + static constexpr llvm::StringRef KernelName = "sinpif16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 sinpif16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Tanf16Test.cpp b/offload/unittests/Conformance/tests/Tanf16Test.cpp new file mode 100644 index 0000000000000..eae9818830a2f --- /dev/null +++ b/offload/unittests/Conformance/tests/Tanf16Test.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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 tanf16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 tanf16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "tanf16"; + static constexpr llvm::StringRef KernelName = "tanf16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), Khronos Registry [July 10, 2025]. + // Note: The minimum accuracy at the source is 2.5 ULP, but we round it + // down to ensure conformance. + static constexpr uint64_t UlpTolerance = 2; +}; +} // namespace mathtest + +int main(int argc, const char **argv) { + llvm::cl::ParseCommandLineOptions(argc, argv, + "Conformance test of the tanf16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Tanhf16Test.cpp b/offload/unittests/Conformance/tests/Tanhf16Test.cpp new file mode 100644 index 0000000000000..1a11f3da7f09a --- /dev/null +++ b/offload/unittests/Conformance/tests/Tanhf16Test.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 tanhf16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 tanhf16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "tanhf16"; + static constexpr llvm::StringRef KernelName = "tanhf16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 tanhf16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/offload/unittests/Conformance/tests/Tanpif16Test.cpp b/offload/unittests/Conformance/tests/Tanpif16Test.cpp new file mode 100644 index 0000000000000..76374807b92f1 --- /dev/null +++ b/offload/unittests/Conformance/tests/Tanpif16Test.cpp @@ -0,0 +1,59 @@ +//===----------------------------------------------------------------------===// +// +// 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 tanpif16 function. +/// +//===----------------------------------------------------------------------===// + +#include "mathtest/CommandLineExtras.hpp" +#include "mathtest/ExhaustiveGenerator.hpp" +#include "mathtest/IndexedRange.hpp" +#include "mathtest/TestConfig.hpp" +#include "mathtest/TestRunner.hpp" +#include "mathtest/TypeExtras.hpp" + +#include "llvm/ADT/StringRef.h" + +#include +#include + +using namespace mathtest; + +extern "C" float16 tanpif16(float16); + +namespace mathtest { + +template <> struct FunctionConfig { + static constexpr llvm::StringRef Name = "tanpif16"; + static constexpr llvm::StringRef KernelName = "tanpif16Kernel"; + + // Source: The Khronos Group, The OpenCL C Specification v3.0.19, Sec. 7.4, + // Table 69 (Full Profile), 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 tanpif16 function"); + + using namespace mathtest; + + IndexedRange Range; + ExhaustiveGenerator Generator(Range); + + const auto Configs = cl::getTestConfigs(); + const llvm::StringRef DeviceBinaryDir = DEVICE_BINARY_DIR; + const bool IsVerbose = cl::IsVerbose; + + bool Passed = + runTests(Generator, Configs, DeviceBinaryDir, IsVerbose); + + return Passed ? EXIT_SUCCESS : EXIT_FAILURE; +} From fea443e942ea15c64fbf5db16d9c4b3ef10f09de Mon Sep 17 00:00:00 2001 From: Leandro Augusto Lacerda Campos Date: Sat, 23 Aug 2025 13:45:57 -0300 Subject: [PATCH 2/2] Fix some testing ranges --- offload/unittests/Conformance/tests/AcosTest.cpp | 4 +++- offload/unittests/Conformance/tests/AcosfTest.cpp | 4 +++- offload/unittests/Conformance/tests/AsinTest.cpp | 4 +++- offload/unittests/Conformance/tests/AsinfTest.cpp | 4 +++- offload/unittests/Conformance/tests/Log1pTest.cpp | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/offload/unittests/Conformance/tests/AcosTest.cpp b/offload/unittests/Conformance/tests/AcosTest.cpp index ba98b2947343f..bc0d1d2b72804 100644 --- a/offload/unittests/Conformance/tests/AcosTest.cpp +++ b/offload/unittests/Conformance/tests/AcosTest.cpp @@ -50,7 +50,9 @@ int main(int argc, const char **argv) { uint64_t Seed = 42; uint64_t Size = 1ULL << 32; - IndexedRange Range; + IndexedRange Range(/*Begin=*/-1.0, + /*End=*/1.0, + /*Inclusive=*/true); RandomGenerator Generator(SeedTy{Seed}, Size, Range); const auto Configs = cl::getTestConfigs(); diff --git a/offload/unittests/Conformance/tests/AcosfTest.cpp b/offload/unittests/Conformance/tests/AcosfTest.cpp index e69ee3b7d1fd7..65b2d18d77284 100644 --- a/offload/unittests/Conformance/tests/AcosfTest.cpp +++ b/offload/unittests/Conformance/tests/AcosfTest.cpp @@ -40,7 +40,9 @@ int main(int argc, const char **argv) { using namespace mathtest; - IndexedRange Range; + IndexedRange Range(/*Begin=*/-1.0f, + /*End=*/1.0f, + /*Inclusive=*/true); ExhaustiveGenerator Generator(Range); const auto Configs = cl::getTestConfigs(); diff --git a/offload/unittests/Conformance/tests/AsinTest.cpp b/offload/unittests/Conformance/tests/AsinTest.cpp index 3594d5e115e08..aaaa37af02bca 100644 --- a/offload/unittests/Conformance/tests/AsinTest.cpp +++ b/offload/unittests/Conformance/tests/AsinTest.cpp @@ -50,7 +50,9 @@ int main(int argc, const char **argv) { uint64_t Seed = 42; uint64_t Size = 1ULL << 32; - IndexedRange Range; + IndexedRange Range(/*Begin=*/-1.0, + /*End=*/1.0, + /*Inclusive=*/true); RandomGenerator Generator(SeedTy{Seed}, Size, Range); const auto Configs = cl::getTestConfigs(); diff --git a/offload/unittests/Conformance/tests/AsinfTest.cpp b/offload/unittests/Conformance/tests/AsinfTest.cpp index 991f79b111efe..aeee648b5fa0e 100644 --- a/offload/unittests/Conformance/tests/AsinfTest.cpp +++ b/offload/unittests/Conformance/tests/AsinfTest.cpp @@ -40,7 +40,9 @@ int main(int argc, const char **argv) { using namespace mathtest; - IndexedRange Range; + IndexedRange Range(/*Begin=*/-1.0f, + /*End=*/1.0f, + /*Inclusive=*/true); ExhaustiveGenerator Generator(Range); const auto Configs = cl::getTestConfigs(); diff --git a/offload/unittests/Conformance/tests/Log1pTest.cpp b/offload/unittests/Conformance/tests/Log1pTest.cpp index 0c3a9042f1605..023b67e770de0 100644 --- a/offload/unittests/Conformance/tests/Log1pTest.cpp +++ b/offload/unittests/Conformance/tests/Log1pTest.cpp @@ -51,7 +51,7 @@ int main(int argc, const char **argv) { uint64_t Seed = 42; uint64_t Size = 1ULL << 32; - IndexedRange Range(/*Begin=*/0.0, + IndexedRange Range(/*Begin=*/-1.0, /*End=*/std::numeric_limits::infinity(), /*Inclusive=*/true); RandomGenerator Generator(SeedTy{Seed}, Size, Range);