Files
TheRock/rocm-systems/projects/hip-tests/catch/unit/math/half_precision_comparison.cc
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

837 lines
28 KiB
C++

/*
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
*
* SPDX-License-Identifier: MIT
*/
#include "half_precision_common.hh"
/**
* @addtogroup HalfPrecisionComparison HalfPrecisionComparison
* @{
* @ingroup MathTest
*/
/********** Unary Functions **********/
#define MATH_BOOL_UNARY_HP_TEST_DEF(func_name, ref_func) \
__global__ void func_name##_kernel(bool* const ys, const size_t num_xs, Float16* const xs) { \
const auto tid = cg::this_grid().thread_rank(); \
const auto stride = cg::this_grid().size(); \
\
for (size_t i = tid; i < num_xs; i += stride) { \
ys[i] = func_name(xs[i]); \
} \
} \
\
HIP_TEST_CASE(Unit_Device_##func_name##_Accuracy_Positive) { \
UnaryHalfPrecisionTest(func_name##_kernel, ref_func, EqValidatorBuilderFactory<bool>()); \
}
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hisinf(x)` for all possible inputs. The results are
* compared against reference function `bool std::isinf(float)`.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_BOOL_UNARY_HP_TEST_DEF(__hisinf, static_cast<bool (*)(float)>(std::isinf))
static float __hisinf2_ref(float x) { return static_cast<float>(std::isinf(x)); }
MATH_UNARY_HP_KERNEL_DEF(__hisinf2)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hisinf2(x)` for all possible inputs. The results are
* compared against reference function `float std::isinf(float)`.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_UNARY_HP_TEST_DEF_IMPL(__hisinf2, __hisinf2_ref, EqValidatorBuilderFactory<float>());
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hisnan(x)` for all possible inputs. The results are
* compared against reference function `bool std::isnan(float)`.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_BOOL_UNARY_HP_TEST_DEF(__hisnan, static_cast<bool (*)(float)>(std::isnan))
static float __hisnan2_ref(float x) { return static_cast<float>(std::isnan(x)); }
MATH_UNARY_HP_KERNEL_DEF(__hisnan2)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hisnan2(x)` for all possible inputs. The results are
* compared against reference function `float std::isnan(float)`.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_UNARY_HP_TEST_DEF_IMPL(__hisnan2, __hisnan2_ref, EqValidatorBuilderFactory<float>());
/********** Binary Functions **********/
#define MATH_COMPARISON_HP_TEST_DEF(func_name, ref_func, T, RT, nan_value) \
__global__ void func_name##_kernel(T* const ys, const size_t num_xs, Float16* const x1s, \
Float16* const x2s) { \
const auto tid = cg::this_grid().thread_rank(); \
const auto stride = cg::this_grid().size(); \
\
for (size_t i = tid; i < num_xs; i += stride) { \
ys[i] = func_name(x1s[i], x2s[i]); \
} \
} \
\
HIP_TEST_CASE(Unit_Device_##func_name##_Accuracy_Positive) { \
BinaryFloatingPointTest(func_name##_kernel, ref_func<nan_value, RT>, \
EqValidatorBuilderFactory<RT>()); \
}
template <bool nan_value, typename T> static T __heq_ref(float x1, float x2) {
if (std::isnan(x1) || std::isnan(x2)) {
return static_cast<T>(nan_value);
}
return x1 == x2;
}
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__heq(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'equal
* to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__heq, __heq_ref, bool, bool, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hbeq2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'equal
* to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hbeq2, __heq_ref, bool, bool, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hequ(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'equal
* to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hequ, __heq_ref, bool, bool, true)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hbequ2(x,y)` against a table of difficult values,
* followed by a large number of randomly generated values. The results are compared against result
* of 'equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hbequ2, __heq_ref, bool, bool, true)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__heq2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'equal
* to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__heq2, __heq_ref, Float16, float, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hequ2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'equal
* to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hequ2, __heq_ref, Float16, float, true)
template <bool nan_value, typename T> static T __hne_ref(float x1, float x2) {
if (std::isnan(x1) || std::isnan(x2)) {
return static_cast<T>(nan_value);
}
return x1 != x2;
}
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hne(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'not
* equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hne, __hne_ref, bool, bool, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hbne2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'not
* equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hbne2, __hne_ref, bool, bool, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hneu(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'not
* equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hneu, __hne_ref, bool, bool, true)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hbneu2(x,y)` against a table of difficult values,
* followed by a large number of randomly generated values. The results are compared against result
* of 'not equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hbneu2, __hne_ref, bool, bool, true)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hne2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'not
* equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hne2, __hne_ref, Float16, float, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hneu2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'not
* equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hneu2, __hne_ref, Float16, float, true)
template <bool nan_value, typename T> static T __hge_ref(float x1, float x2) {
if (std::isnan(x1) || std::isnan(x2)) {
return static_cast<T>(nan_value);
}
return x1 >= x2;
}
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hge(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of
* 'greater than equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hge, __hge_ref, bool, bool, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hbge2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of
* 'greater than equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hbge2, __hge_ref, bool, bool, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hgeu(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of
* 'greater than equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hgeu, __hge_ref, bool, bool, true)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hbgeu2(x,y)` against a table of difficult values,
* followed by a large number of randomly generated values. The results are compared against result
* of 'greater than equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hbgeu2, __hge_ref, bool, bool, true)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hge2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of
* 'greater than equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hge2, __hge_ref, Float16, float, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hgeu2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of
* 'greater than equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hgeu2, __hge_ref, Float16, float, true)
template <bool nan_value, typename T> static T __hgt_ref(float x1, float x2) {
if (std::isnan(x1) || std::isnan(x2)) {
return static_cast<T>(nan_value);
}
return x1 > x2;
}
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hgt(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of
* 'greater than' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hgt, __hgt_ref, bool, bool, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hbgt2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of
* 'greater than' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hbgt2, __hgt_ref, bool, bool, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hgtu(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of
* 'greater than' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hgtu, __hgt_ref, bool, bool, true)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hbgtu2(x,y)` against a table of difficult values,
* followed by a large number of randomly generated values. The results are compared against result
* of 'greater than' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hbgtu2, __hgt_ref, bool, bool, true)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hgt2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of
* 'greater than' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hgt2, __hgt_ref, Float16, float, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hgtu2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of
* 'greater than' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hgtu2, __hgt_ref, Float16, float, true)
template <bool nan_value, typename T> static T __hle_ref(float x1, float x2) {
if (std::isnan(x1) || std::isnan(x2)) {
return static_cast<T>(nan_value);
}
return x1 <= x2;
}
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hle(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'less
* than equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hle, __hle_ref, bool, bool, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hble2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'less
* than equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hble2, __hle_ref, bool, bool, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hleu(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'less
* than equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hleu, __hle_ref, bool, bool, true)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hbleu2(x,y)` against a table of difficult values,
* followed by a large number of randomly generated values. The results are compared against result
* of 'less than equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hbleu2, __hle_ref, bool, bool, true)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hle2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'less
* than equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hle2, __hle_ref, Float16, float, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hleu2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'less
* than equal to' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hleu2, __hle_ref, Float16, float, true)
template <bool nan_value, typename T> static T __hlt_ref(float x1, float x2) {
if (std::isnan(x1) || std::isnan(x2)) {
return static_cast<T>(nan_value);
}
return x1 < x2;
}
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hlt(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'less
* than' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hlt, __hlt_ref, bool, bool, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hblt2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'less
* than' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hblt2, __hlt_ref, bool, bool, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hltu(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'less
* than' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hltu, __hlt_ref, bool, bool, true)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hbltu2(x,y)` against a table of difficult values,
* followed by a large number of randomly generated values. The results are compared against result
* of 'less than' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hbltu2, __hlt_ref, bool, bool, true)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hlt2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'less
* than' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hlt2, __hlt_ref, Float16, float, false)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hltu2(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against result of 'less
* than' relational operator for float operands.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_COMPARISON_HP_TEST_DEF(__hltu2, __hlt_ref, Float16, float, true)
MATH_BINARY_HP_KERNEL_DEF(__hmax)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hmax(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against reference
* function `float std::fmax(float, float)`
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_BINARY_HP_TEST_DEF_IMPL(__hmax, static_cast<float (*)(float, float)>(std::fmax),
EqValidatorBuilderFactory<float>())
MATH_BINARY_HP_KERNEL_DEF(__hmin)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hmin(x,y)` against a table of difficult values, followed
* by a large number of randomly generated values. The results are compared against reference
* function `float std::fmin(float, float)`
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_BINARY_HP_TEST_DEF_IMPL(__hmin, static_cast<float (*)(float, float)>(std::fmin),
EqValidatorBuilderFactory<float>())
static float __hmax_nan_ref(float x1, float x2) {
if (std::isnan(x1))
return x1;
else if (std::isnan(x2))
return x2;
else
return std::fmax(x1, x2);
}
MATH_BINARY_HP_KERNEL_DEF(__hmax_nan)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hmax_nan(x,y)` against a table of difficult values,
* followed by a large number of randomly generated values. The results are compared against
* reference function `float std::fmax(float, float)` with modified result when an operand is nan.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_BINARY_HP_TEST_DEF_IMPL(__hmax_nan, __hmax_nan_ref, EqValidatorBuilderFactory<float>())
static float __hmin_nan_ref(float x1, float x2) {
if (std::isnan(x1))
return x1;
else if (std::isnan(x2))
return x2;
else
return std::fmin(x1, x2);
}
MATH_BINARY_HP_KERNEL_DEF(__hmin_nan)
/**
* Test Description
* ------------------------
* - Tests the numerical accuracy of `__hmin_nan(x,y)` against a table of difficult values,
* followed by a large number of randomly generated values. The results are compared against
* reference function `float std::fmin(float, float)` with modified result when an operand is nan.
*
* Test source
* ------------------------
* - unit/math/half_precision_comparison.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
MATH_BINARY_HP_TEST_DEF_IMPL(__hmin_nan, __hmin_nan_ref, EqValidatorBuilderFactory<float>())
/**
* End doxygen group MathTest.
* @}
*/