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
252 lines
7.2 KiB
C++
252 lines
7.2 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include "unary_common.hh"
|
|
#include "math_log_negative_kernels_rtc.hh"
|
|
|
|
/**
|
|
* @addtogroup LogMathFuncs LogMathFuncs
|
|
* @{
|
|
* @ingroup MathTest
|
|
*/
|
|
|
|
/********** Unary Functions **********/
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests the numerical accuracy of `logf(x)` for all possible inputs and `log(x)` against a
|
|
* table of difficult values, followed by a large number of randomly generated values. The results
|
|
* are compared against reference function `T std::log(T)`. The maximum ulp error
|
|
* for single precision is 2 and for double precision is 1.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/log_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
MATH_UNARY_WITHIN_ULP_STL_REF_TEST_DEF(log, 2, 1)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - RTCs kernels that pass argument of invalid type for logf and log.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/log_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_Device_log_logf_Negative_RTC) { NegativeTestRTCWrapper<4>(kLog); }
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests the numerical accuracy of `log2f(x)` for all possible inputs and `log2(x)` against a
|
|
* table of difficult values, followed by a large number of randomly generated values. The results
|
|
* are compared against reference function `T std::log2(T)`. The maximum ulp error is 1.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/log_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
MATH_UNARY_WITHIN_ULP_STL_REF_TEST_DEF(log2, 1, 1)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - RTCs kernels that pass argument of invalid type for log2f and log2.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/log_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_Device_log2_log2f_Negative_RTC) { NegativeTestRTCWrapper<4>(kLog2); }
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests the numerical accuracy of `log10f(x)` for all possible inputs and `log10(x)` against a
|
|
* table of difficult values, followed by a large number of randomly generated values. The results
|
|
* are compared against reference function `T std::log10(T)`. The maximum ulp error for single
|
|
* precision is 2 and for double precision is 1.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/log_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
MATH_UNARY_WITHIN_ULP_STL_REF_TEST_DEF(log10, 2, 1)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - RTCs kernels that pass argument of invalid type for log10f and log10.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/log_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_Device_log10_log10f_Negative_RTC) { NegativeTestRTCWrapper<4>(kLog10); }
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests the numerical accuracy of `log1pf(x)` for all possible inputs and `log1p(x)` against a
|
|
* table of difficult values, followed by a large number of randomly generated values. The results
|
|
* are compared against reference function `T std::log1p(T)`. The maximum ulp error is 1.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/log_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
MATH_UNARY_WITHIN_ULP_STL_REF_TEST_DEF(log1p, 1, 1)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - RTCs kernels that pass argument of invalid type for log1pf and log1p.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/log_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_Device_log1p_log1pf_Negative_RTC) { NegativeTestRTCWrapper<4>(kLog1p); }
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests the numerical accuracy of `logb(x)` for all possible inputs and `logb(x)` against a
|
|
* table of difficult values, followed by a large number of randomly generated values. The results
|
|
* are compared against reference function `T std::logb(T)`. The maximum ulp error is 0.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/log_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
MATH_UNARY_WITHIN_ULP_STL_REF_TEST_DEF(logb, 0, 0)
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - RTCs kernels that pass argument of invalid type for logbf and logb.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/log_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_Device_logb_logbf_Negative_RTC) { NegativeTestRTCWrapper<4>(kLogb); }
|
|
|
|
|
|
template <typename T>
|
|
__global__ void ilogb_kernel(int* const ys, const size_t num_xs, T* 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) {
|
|
if constexpr (std::is_same_v<float, T>) {
|
|
ys[i] = ilogbf(xs[i]);
|
|
} else if constexpr (std::is_same_v<double, T>) {
|
|
ys[i] = ilogb(xs[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
template <typename T> int ilogb_ref(T arg) {
|
|
if (arg == 0) {
|
|
return std::numeric_limits<int>::min();
|
|
} else if (std::isnan(arg)) {
|
|
return std::numeric_limits<int>::min();
|
|
} else if (std::isinf(arg)) {
|
|
return std::numeric_limits<int>::max();
|
|
} else {
|
|
return std::ilogb(arg);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests the numerical accuracy of `ilogbf(x)` for all possible inputs. The results are
|
|
* compared against reference function `int std::ilogb(double)`. The maximum ulp error is 0.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/log_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_Device_ilogbf_Accuracy_Positive) {
|
|
UnarySinglePrecisionTest(ilogb_kernel<float>, ilogb_ref<double>,
|
|
EqValidatorBuilderFactory<int>());
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Tests the numerical accuracy of `ilogb(x)` against a table of difficult values,
|
|
* followed by a large number of randomly generated values. The results are
|
|
* compared against reference function `int std::ilogb(long double)`. The maximum ulp error is 0.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/log_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_Device_ilogb_Accuracy_Positive) {
|
|
UnaryDoublePrecisionTest(ilogb_kernel<double>, ilogb_ref<long double>,
|
|
EqValidatorBuilderFactory<int>());
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - RTCs kernels that pass argument of invalid type for ilogbf and ilogb.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/math/log_funcs.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit_Device_ilogb_ilogbf_Negative_RTC) { NegativeTestRTCWrapper<4>(kIlogb); }
|
|
|
|
/**
|
|
* End doxygen group MathTest.
|
|
* @}
|
|
*/
|