/* * Copyright (c) Advanced Micro Devices, Inc., or its affiliates. * * SPDX-License-Identifier: MIT */ #include "half_precision_common.hh" #include "casting_common.hh" /** * @addtogroup HalfPrecisionCastingIntTypes HalfPrecisionCastingIntTypes * @{ * @ingroup MathTest */ #define CAST_INT2HALF_RN_TEST_DEF(kern_name, T) \ CAST_KERNEL_DEF(kern_name, Float16, T) \ CAST_REF_DEF(kern_name, Float16, T) \ \ HIP_TEST_CASE(Unit_Device_##kern_name##_Accuracy_Positive) { \ Float16 (*ref)(T) = kern_name##_ref; \ CastIntRangeTest(kern_name##_kernel, ref, EqValidatorBuilderFactory()); \ } /** * Test Description * ------------------------ * - Tests that checks `__int2half_rn` for all possible inputs. The results are compared against * reference function which performs int cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__int2half_rn, int) /** * Test Description * ------------------------ * - Tests that checks `__int2half_rz` for all possible inputs. The results are compared against * reference function which performs int cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__int2half_rz, int) /** * Test Description * ------------------------ * - Tests that checks `__int2half_rd` for all possible inputs. The results are compared against * reference function which performs int cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__int2half_rd, int) /** * Test Description * ------------------------ * - Tests that checks `__int2half_ru` for all possible inputs. The results are compared against * reference function which performs int cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__int2half_ru, int) /** * Test Description * ------------------------ * - Tests that checks `__uint2half_rn` for all possible inputs. The results are compared against * reference function which performs unsigned int cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__uint2half_rn, unsigned int) /** * Test Description * ------------------------ * - Tests that checks `__uint2half_rz` for all possible inputs. The results are compared against * reference function which performs unsigned int cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__uint2half_rz, unsigned int) /** * Test Description * ------------------------ * - Tests that checks `__uint2half_rd` for all possible inputs. The results are compared against * reference function which performs unsigned int cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__uint2half_rd, unsigned int) /** * Test Description * ------------------------ * - Tests that checks `__uint2half_ru` for all possible inputs. The results are compared against * reference function which performs unsigned int cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__uint2half_ru, unsigned int) /** * Test Description * ------------------------ * - Tests that checks `__short2half_rn` for all possible inputs. The results are compared * against reference function which performs short cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__short2half_rn, short) /** * Test Description * ------------------------ * - Tests that checks `__short2half_rz` for all possible inputs. The results are compared * against reference function which performs short cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__short2half_rz, short) /** * Test Description * ------------------------ * - Tests that checks `__short2half_rd` for all possible inputs. The results are compared * against reference function which performs short cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__short2half_rd, short) /** * Test Description * ------------------------ * - Tests that checks `__short2half_ru` for all possible inputs. The results are compared * against reference function which performs short cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__short2half_ru, short) /** * Test Description * ------------------------ * - Tests that checks `__ushort2half_rn` for all possible inputs. The results are compared * against reference function which performs unsigned short cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__ushort2half_rn, unsigned short) /** * Test Description * ------------------------ * - Tests that checks `__ushort2half_rz` for all possible inputs. The results are compared * against reference function which performs unsigned short cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__ushort2half_rz, unsigned short) /** * Test Description * ------------------------ * - Tests that checks `__ushort2half_rd` for all possible inputs. The results are compared * against reference function which performs unsigned short cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__ushort2half_rd, unsigned short) /** * Test Description * ------------------------ * - Tests that checks `__ushort2half_ru` for all possible inputs. The results are compared * against reference function which performs unsigned short cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_INT2HALF_RN_TEST_DEF(__ushort2half_ru, unsigned short) #define CAST_LL2HALF_TEST_DEF(kern_name, T) \ CAST_KERNEL_DEF(kern_name, Float16, T) \ CAST_REF_DEF(kern_name, Float16, T) \ \ HIP_TEST_CASE(Unit_Device_##kern_name##_Accuracy_Positive) { \ Float16 (*ref)(T) = kern_name##_ref; \ CastIntBruteForceTest(kern_name##_kernel, ref, EqValidatorBuilderFactory()); \ } /** * Test Description * ------------------------ * - Tests that checks `__ll2half_rn` against a large number of randomly generated values. The * results are compared against reference function which performs long long cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_LL2HALF_TEST_DEF(__ll2half_rn, long long) /** * Test Description * ------------------------ * - Tests that checks `__ll2half_rz` against a large number of randomly generated values. The * results are compared against reference function which performs long long cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_LL2HALF_TEST_DEF(__ll2half_rz, long long) /** * Test Description * ------------------------ * - Tests that checks `__ll2half_rd` against a large number of randomly generated values. The * results are compared against reference function which performs long long cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_LL2HALF_TEST_DEF(__ll2half_rd, long long) /** * Test Description * ------------------------ * - Tests that checks `__ll2half_ru` against a large number of randomly generated values. The * results are compared against reference function which performs long long cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_LL2HALF_TEST_DEF(__ll2half_ru, long long) /** * Test Description * ------------------------ * - Tests that checks `__ull2half_rn` against a large number of randomly generated values. The * results are compared against reference function which performs unsigned long long cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_LL2HALF_TEST_DEF(__ull2half_rn, unsigned long long) /** * Test Description * ------------------------ * - Tests that checks `__ull2half_rz` against a large number of randomly generated values. The * results are compared against reference function which performs unsigned long long cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_LL2HALF_TEST_DEF(__ull2half_rz, unsigned long long) /** * Test Description * ------------------------ * - Tests that checks `__ull2half_rd` against a large number of randomly generated values. The * results are compared against reference function which performs unsigned long long cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_LL2HALF_TEST_DEF(__ull2half_rd, unsigned long long) /** * Test Description * ------------------------ * - Tests that checks `__ull2half_ru` against a large number of randomly generated values. The * results are compared against reference function which performs unsigned long long cast to __half. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ CAST_LL2HALF_TEST_DEF(__ull2half_ru, unsigned long long) CAST_KERNEL_DEF(__short_as_half, Float16, short) /** * Test Description * ------------------------ * - Tests that checks `__short_as_half` for all possible inputs. The results are compared * against reference function which performs copy of short value to __half variable. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ HIP_TEST_CASE(Unit_Device___short_as_half_Accuracy_Positive) { Float16 (*ref)(short) = type2_as_type1_ref; CastIntBruteForceTest(__short_as_half_kernel, ref, EqValidatorBuilderFactory()); } CAST_KERNEL_DEF(__ushort_as_half, Float16, unsigned short) /** * Test Description * ------------------------ * - Tests that checks `__ushort_as_half` for all possible inputs. The results are compared * against reference function which performs copy of unsigned short value to __half variable. * * Test source * ------------------------ * - unit/math/casting_int2half_funcs.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ HIP_TEST_CASE(Unit_Device___ushort_as_half_Accuracy_Positive) { Float16 (*ref)(unsigned short) = type2_as_type1_ref; CastIntBruteForceTest(__ushort_as_half_kernel, ref, EqValidatorBuilderFactory()); } /** * End doxygen group MathTest. * @} */