Files
TheRock/rocm-systems/projects/hip-tests/catch/unit/math/casting_half2int_funcs.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

430 lines
13 KiB
C++

/*
* 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_HALF2INT_RN_TEST_DEF(kern_name, T) \
CAST_KERNEL_DEF(kern_name, T, Float16) \
CAST_F2I_RZ_REF_DEF(kern_name, T, Float16) \
\
HIP_TEST_CASE(Unit_Device_##kern_name##_Accuracy_Positive) { \
T (*ref)(Float16) = kern_name##_ref; \
CastUnaryHalfPrecisionTest(kern_name##_kernel, ref, EqValidatorBuilderFactory<T>()); \
}
/**
* Test Description
* ------------------------
* - Tests that checks `__half2int_rn` for all possible inputs. The results are compared against
* reference function which performs __half cast to int.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2int_rn, int)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2int_rz` for all possible inputs. The results are compared against
* reference function which performs __half cast to int.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2int_rz, int)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2int_rd` for all possible inputs. The results are compared against
* reference function which performs __half cast to int.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2int_rd, int)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2int_ru` for all possible inputs. The results are compared against
* reference function which performs __half cast to int.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2int_ru, int)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2uint_rn` for all possible inputs. The results are compared against
* reference function which performs __half cast to unsigned int.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2uint_rn, unsigned int)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2uint_rz` for all possible inputs. The results are compared against
* reference function which performs __half cast to unsigned int.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2uint_rz, unsigned int)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2uint_rd` for all possible inputs. The results are compared against
* reference function which performs __half cast to unsigned int.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2uint_rd, unsigned int)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2uint_ru` for all possible inputs. The results are compared against
* reference function which performs __half cast to unsigned int.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2uint_ru, unsigned int)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2short_rn` for all possible inputs. The results are compared
* against reference function which performs __half cast to short.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2short_rn, short)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2short_rz` for all possible inputs. The results are compared
* against reference function which performs __half cast to short.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2short_rz, short)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2short_rd` for all possible inputs. The results are compared
* against reference function which performs __half cast to short.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2short_rd, short)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2short_ru` for all possible inputs. The results are compared
* against reference function which performs __half cast to short.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2short_ru, short)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2ushort_rn` for all possible inputs. The results are compared
* against reference function which performs __half cast to unsigned short.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2ushort_rn, unsigned short)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2ushort_rz` for all possible inputs. The results are compared
* against reference function which performs __half cast to unsigned short.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2ushort_rz, unsigned short)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2ushort_rd` for all possible inputs. The results are compared
* against reference function which performs __half cast to unsigned short.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2ushort_rd, unsigned short)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2ushort_ru` for all possible inputs. The results are compared
* against reference function which performs __half cast to unsigned short.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2ushort_ru, unsigned short)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2ll_rn` for all possible inputs. The results are compared against
* reference function which performs __half cast to long long.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2ll_rn, long long)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2ll_rz` for all possible inputs. The results are compared against
* reference function which performs __half cast to long long.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2ll_rz, long long)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2ll_rd` for all possible inputs. The results are compared against
* reference function which performs __half cast to long long.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2ll_rd, long long)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2ll_ru` for all possible inputs. The results are compared against
* reference function which performs __half cast to long long.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2ll_ru, long long)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2ull_rn` for all possible inputs. The results are compared against
* reference function which performs __half cast to unsigned long long.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2ull_rn, unsigned long long)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2ull_rz` for all possible inputs. The results are compared against
* reference function which performs __half cast to unsigned long long.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2ull_rz, unsigned long long)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2ull_rd` for all possible inputs. The results are compared against
* reference function which performs __half cast to unsigned long long.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2ull_rd, unsigned long long)
/**
* Test Description
* ------------------------
* - Tests that checks `__half2ull_ru` for all possible inputs. The results are compared against
* reference function which performs __half cast to unsigned long long.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
CAST_HALF2INT_RN_TEST_DEF(__half2ull_ru, unsigned long long)
CAST_KERNEL_DEF(__half_as_short, short, Float16)
/**
* Test Description
* ------------------------
* - Tests that checks `__half_as_short` for all possible inputs. The results are compared
* against reference function which performs copy of __half value to short variable.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
HIP_TEST_CASE(Unit_Device___half_as_short_Accuracy_Positive) {
short (*ref)(Float16) = type2_as_type1_ref<short, Float16>;
CastUnaryHalfPrecisionTest(__half_as_short_kernel, ref, EqValidatorBuilderFactory<short>());
}
CAST_KERNEL_DEF(__half_as_ushort, unsigned short, Float16)
/**
* Test Description
* ------------------------
* - Tests that checks `__half_as_ushort` for all possible inputs. The results are compared
* against reference function which performs copy of __half value to unsigned short variable.
*
* Test source
* ------------------------
* - unit/math/casting_half2int_funcs.cc
* Test requirements
* ------------------------
* - HIP_VERSION >= 5.2
*/
HIP_TEST_CASE(Unit_Device___half_as_ushort_Accuracy_Positive) {
unsigned short (*ref)(Float16) = type2_as_type1_ref<unsigned short, Float16>;
CastUnaryHalfPrecisionTest(__half_as_ushort_kernel, ref,
EqValidatorBuilderFactory<unsigned short>());
}
/**
* End doxygen group MathTest.
* @}
*/