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

122 lines
4.7 KiB
C++

/*
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
*
* SPDX-License-Identifier: MIT
*/
#include "trig_negative_kernels_rtc.hh"
#include "unary_common.hh"
#include "binary_common.hh"
#include "math_reference_impl.hh"
MATH_UNARY_WITHIN_ULP_TEST_DEF(sin, std::sin, 2, 2);
HIP_TEST_CASE(Unit_Device_sin_sinf_Negative_RTC) { NegativeTestRTCWrapper<4>(kSin); }
MATH_UNARY_WITHIN_ULP_TEST_DEF(cos, std::cos, 2, 2)
HIP_TEST_CASE(Unit_Device_cos_cosf_Negative_RTC) { NegativeTestRTCWrapper<4>(kCos); }
MATH_UNARY_WITHIN_ULP_TEST_DEF(tan, std::tan, 4, 2)
HIP_TEST_CASE(Unit_Device_tan_tanf_Negative_RTC) { NegativeTestRTCWrapper<4>(kTan); }
MATH_UNARY_WITHIN_ULP_TEST_DEF(asin, std::asin, 3, 2)
HIP_TEST_CASE(Unit_Device_asin_asinf_Negative_RTC) { NegativeTestRTCWrapper<4>(kAsin); }
MATH_UNARY_WITHIN_ULP_TEST_DEF(acos, std::acos, 2, 2)
HIP_TEST_CASE(Unit_Device_acos_acosf_Negative_RTC) { NegativeTestRTCWrapper<4>(kAcos); }
MATH_UNARY_WITHIN_ULP_TEST_DEF(atan, std::atan, 2, 2)
HIP_TEST_CASE(Unit_Device_atan_atanf_Negative_RTC) { NegativeTestRTCWrapper<4>(kAtan); }
MATH_UNARY_WITHIN_ULP_TEST_DEF(sinh, std::sinh, 3, 2)
HIP_TEST_CASE(Unit_Device_sinh_sinhf_Negative_RTC) { NegativeTestRTCWrapper<4>(kSinh); }
MATH_UNARY_WITHIN_ULP_TEST_DEF(cosh, std::cosh, 2, 1)
HIP_TEST_CASE(Unit_Device_cosh_coshf_Negative_RTC) { NegativeTestRTCWrapper<4>(kCosh); }
MATH_UNARY_WITHIN_ULP_TEST_DEF(tanh, std::tanh, 2, 1)
HIP_TEST_CASE(Unit_Device_tanh_tanhf_Negative_RTC) { NegativeTestRTCWrapper<4>(kTanh); }
MATH_UNARY_WITHIN_ULP_TEST_DEF(asinh, std::asinh, 3, 2)
HIP_TEST_CASE(Unit_Device_asinh_asinhf_Negative_RTC) { NegativeTestRTCWrapper<4>(kAsinh); }
MATH_UNARY_WITHIN_ULP_TEST_DEF(acosh, std::acosh, 4, 2)
HIP_TEST_CASE(Unit_Device_acosh_acoshf_Negative_RTC) { NegativeTestRTCWrapper<4>(kAcosh); }
MATH_UNARY_WITHIN_ULP_TEST_DEF(atanh, std::atanh, 3, 2)
HIP_TEST_CASE(Unit_Device_atanh_atanhf_Negative_RTC) { NegativeTestRTCWrapper<4>(kAtanh); }
MATH_UNARY_WITHIN_ULP_TEST_DEF(sinpi, math_reference::sin_pi, 2, 2);
HIP_TEST_CASE(Unit_Device_sinpi_sinpif_Negative_RTC) { NegativeTestRTCWrapper<4>(kSinpi); }
MATH_UNARY_WITHIN_ULP_TEST_DEF(cospi, math_reference::cos_pi, 2, 2);
HIP_TEST_CASE(Unit_Device_cospi_cospif_Negative_RTC) { NegativeTestRTCWrapper<4>(kCospi); }
MATH_BINARY_WITHIN_ULP_TEST_DEF(atan2, std::atan2, 3, 2);
HIP_TEST_CASE(Unit_Device_atan2_atan2f_Negative_RTC) { NegativeTestRTCWrapper<8>(kAtan2); }
template <typename T>
__global__ void sincos_kernel(std::pair<T, T>* 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>) {
sincosf(xs[i], &ys[i].first, &ys[i].second);
} else if constexpr (std::is_same_v<double, T>) {
sincos(xs[i], &ys[i].first, &ys[i].second);
}
}
}
template <typename T> std::pair<T, T> sincos(T x) { return {std::sin(x), std::cos(x)}; }
HIP_TEST_CASE(Unit_Device_sincos_Accuracy_Positive_float) {
UnarySinglePrecisionTest(
sincos_kernel<float>, sincos<double>,
PairValidatorBuilderFactory<float>(ULPValidatorBuilderFactory<float>(2)));
}
HIP_TEST_CASE(Unit_Device_sincos_Accuracy_Positive_double) {
const auto validator_builder =
PairValidatorBuilderFactory<double>(ULPValidatorBuilderFactory<double>(2));
UnaryDoublePrecisionTest(sincos_kernel<double>, sincos<long double>, validator_builder);
}
HIP_TEST_CASE(Unit_Device_sincos_sincosf_Negative_RTC) { NegativeTestRTCWrapper<36>(kSincos); }
template <typename T>
__global__ void sincospi_kernel(std::pair<T, T>* 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>) {
sincospif(xs[i], &ys[i].first, &ys[i].second);
} else if constexpr (std::is_same_v<double, T>) {
sincospi(xs[i], &ys[i].first, &ys[i].second);
}
}
}
template <typename T> std::pair<T, T> sincospi(T x) {
return {math_reference::sin_pi(x), math_reference::cos_pi(x)};
}
HIP_TEST_CASE(Unit_Device_sincospi_Accuracy_Positive_float) {
UnarySinglePrecisionTest(
sincospi_kernel<float>, sincospi<double>,
PairValidatorBuilderFactory<float>(ULPValidatorBuilderFactory<float>(2)));
}
HIP_TEST_CASE(Unit_Device_sincospi_Accuracy_Positive_double) {
const auto validator_builder =
PairValidatorBuilderFactory<double>(ULPValidatorBuilderFactory<double>(2));
UnaryDoublePrecisionTest(sincospi_kernel<double>, sincospi<long double>, validator_builder);
}
HIP_TEST_CASE(Unit_Device_sincospi_sincospif_Negative_RTC) { NegativeTestRTCWrapper<36>(kSincospi); }