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
58 lines
2.0 KiB
C++
58 lines
2.0 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Returns sqrt(x*x + y*y) with no overflow or underflow unless the result
|
|
// warrants it
|
|
|
|
#if __CLC_FPSIZE == 32
|
|
_CLC_OVERLOAD _CLC_DEF _CLC_CONST __CLC_GENTYPE __clc_hypot(__CLC_GENTYPE x,
|
|
__CLC_GENTYPE y) {
|
|
__CLC_GENTYPE a = __clc_fabs(x);
|
|
__CLC_GENTYPE b = __clc_fabs(y);
|
|
__CLC_GENTYPE t = __clc_fmax(a, b);
|
|
__CLC_INTN e = __clc_frexp_exp(t);
|
|
|
|
a = __clc_ldexp(a, -e);
|
|
b = __clc_ldexp(b, -e);
|
|
__CLC_GENTYPE ret = __clc_ldexp(__clc_sqrt_fast(__clc_mad(a, a, b * b)), e);
|
|
|
|
return __clc_isinf(t) ? __CLC_GENTYPE_INF : ret;
|
|
}
|
|
|
|
#elif __CLC_FPSIZE == 64
|
|
|
|
_CLC_OVERLOAD _CLC_DEF _CLC_CONST __CLC_GENTYPE __clc_hypot(__CLC_GENTYPE x,
|
|
__CLC_GENTYPE y) {
|
|
__CLC_GENTYPE a = __clc_fabs(x);
|
|
__CLC_GENTYPE b = __clc_fabs(y);
|
|
__CLC_GENTYPE t = __clc_fmax(a, b);
|
|
__CLC_INTN e = __clc_frexp_exp(t);
|
|
|
|
a = __clc_ldexp(a, -e);
|
|
b = __clc_ldexp(b, -e);
|
|
__CLC_GENTYPE ret = __clc_ldexp(__clc_sqrt_fast(__clc_mad(a, a, b * b)), e);
|
|
|
|
ret = __clc_isunordered(x, y) ? __CLC_GENTYPE_NAN : ret;
|
|
return __clc_isinf(x) || __clc_isinf(y) ? __CLC_GENTYPE_INF : ret;
|
|
}
|
|
|
|
#elif __CLC_FPSIZE == 16
|
|
|
|
_CLC_OVERLOAD _CLC_DEF _CLC_CONST __CLC_GENTYPE __clc_hypot(__CLC_GENTYPE x,
|
|
__CLC_GENTYPE y) {
|
|
__CLC_FLOATN fx = __CLC_CONVERT_FLOATN(x);
|
|
__CLC_FLOATN fy = __CLC_CONVERT_FLOATN(y);
|
|
__CLC_FLOATN d2 = __clc_mad(fx, fx, fy * fy);
|
|
|
|
__CLC_GENTYPE ret = __CLC_CONVERT_HALFN(__clc_sqrt_fast(d2));
|
|
|
|
return __clc_isinf(x) || __clc_isinf(y) ? __CLC_GENTYPE_INF : ret;
|
|
}
|
|
|
|
#endif
|