brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 186ddd5 Raw
30 lines · cpp
1//===-- Exhaustive test for sqrtbf16 --------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "src/__support/FPUtil/bfloat16.h"10#include "src/math/sqrtbf16.h"11#include "test/UnitTest/FPMatcher.h"12#include "test/UnitTest/Test.h"13#include "utils/MPFRWrapper/MPFRUtils.h"14 15using LlvmLibcSqrtf16Test = LIBC_NAMESPACE::testing::FPTest<bfloat16>;16 17namespace mpfr = LIBC_NAMESPACE::testing::mpfr;18 19// range: [0, inf]20static constexpr uint16_t POS_START = 0x0000U;21static constexpr uint16_t POS_STOP = 0x7f80U;22 23TEST_F(LlvmLibcSqrtf16Test, PositiveRange) {24  for (uint16_t v = POS_START; v <= POS_STOP; ++v) {25    bfloat16 x = FPBits(v).get_val();26    EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sqrt, x,27                                   LIBC_NAMESPACE::sqrtbf16(x), 0.5);28  }29}30