Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
64121d4
feat: implement {canonicalize,iscanonical,fdim,copysign,issignaling}b…
krishna2803 Aug 27, 2025
ff3915c
chore: update CMakeLists
krishna2803 Aug 27, 2025
cbdfc66
chore: add smoke tests for {canonicalize,iscanonical,fdim,copysign,is…
krishna2803 Aug 27, 2025
170f9b2
fix: add 0 to T cast
krishna2803 Aug 27, 2025
ceb8818
chore: update entrypoints
krishna2803 Aug 27, 2025
99f5872
docs: add {canonicalize,iscanonical,fdim,copysign,issignaling}bf16 ma…
krishna2803 Aug 27, 2025
204df34
feat: implement totalorder{,mag}bf16 math functions
krishna2803 Aug 27, 2025
06ca9a3
chore: add smoke tests for totalorder{,mag}bf16 math functions
krishna2803 Aug 27, 2025
f83bce4
chore: update entrypoints
krishna2803 Aug 27, 2025
4396ea9
docs: add totalorder{,mag}bf16 math functions
krishna2803 Aug 27, 2025
b633a76
feat: implement scalb{,l}nbf16 math functions
krishna2803 Aug 27, 2025
e99d5c2
chore: add smoke tests for scalb{,l}nbf16 math functions
krishna2803 Aug 27, 2025
a7187f9
chore: update entrypoints
krishna2803 Aug 27, 2025
5ff2ddc
docs: add scalb{,l}nbf16 math functions
krishna2803 Aug 27, 2025
d7930ac
feat: implement fmodbf16 math function
krishna2803 Aug 27, 2025
a772790
chore: add smoke tests for fmodbf16 math function
krishna2803 Aug 27, 2025
e5036f7
chore: add exahaustive tests for fmodbf16 math function
krishna2803 Aug 27, 2025
a902723
chore: update entrypoints
krishna2803 Aug 27, 2025
d451393
docs: add smoke tests for fmodbf16 math function
krishna2803 Aug 27, 2025
0e2a7d9
fix: FE_INEXACT exception
krishna2803 Aug 27, 2025
3c1a191
chore: remove redundant `uint16_t`
krishna2803 Aug 27, 2025
e42677d
Merge branch 'main' into users/krishna2803/fmodbf16
krishna2803 Aug 30, 2025
d8c8870
nit: rename test constant names
krishna2803 Sep 1, 2025
391111f
fix: typo POS_{START,STOP} -> NEG_{START,STOP}
krishna2803 Sep 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc/config/baremetal/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fmodbf16
libc.src.math.frexpbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
Expand Down
1 change: 1 addition & 0 deletions libc/config/baremetal/arm/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fmodbf16
libc.src.math.frexpbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
Expand Down
1 change: 1 addition & 0 deletions libc/config/baremetal/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fmodbf16
libc.src.math.frexpbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
Expand Down
1 change: 1 addition & 0 deletions libc/config/darwin/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fmodbf16
libc.src.math.frexpbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
Expand Down
1 change: 1 addition & 0 deletions libc/config/darwin/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fmodbf16
libc.src.math.frexpbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
Expand Down
1 change: 1 addition & 0 deletions libc/config/gpu/amdgpu/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fmodbf16
libc.src.math.frexpbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
Expand Down
1 change: 1 addition & 0 deletions libc/config/gpu/nvptx/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fmodbf16
libc.src.math.frexpbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fmodbf16
libc.src.math.frexpbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/arm/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fmodbf16
libc.src.math.frexpbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fmodbf16
libc.src.math.frexpbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fmodbf16
libc.src.math.frexpbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
Expand Down
1 change: 1 addition & 0 deletions libc/config/windows/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fmodbf16
libc.src.math.frexpbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
Expand Down
2 changes: 1 addition & 1 deletion libc/docs/headers/math/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| fminimum_num | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.12.9 | F.10.9.5 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| fmod | |check| | |check| | |check| | |check| | |check| | | 7.12.10.1 | F.10.7.1 |
| fmod | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.10.1 | F.10.7.1 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| fmul | N/A | |check| | |check| | N/A | |check|\* | N/A | 7.12.14.3 | F.10.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
Expand Down
1 change: 1 addition & 0 deletions libc/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ add_math_entrypoint_object(fmodf)
add_math_entrypoint_object(fmodl)
add_math_entrypoint_object(fmodf16)
add_math_entrypoint_object(fmodf128)
add_math_entrypoint_object(fmodbf16)

add_math_entrypoint_object(frexp)
add_math_entrypoint_object(frexpf)
Expand Down
21 changes: 21 additions & 0 deletions libc/src/math/fmodbf16.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation header for fmodbf16 ----------------------*- 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
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_MATH_FMODBF16_H
#define LLVM_LIBC_SRC_MATH_FMODBF16_H

#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE_DECL {

bfloat16 fmodbf16(bfloat16 x, bfloat16 y);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_FMODBF16_H
14 changes: 14 additions & 0 deletions libc/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4015,6 +4015,20 @@ add_entrypoint_object(
libc.src.__support.FPUtil.generic.fmod
)

add_entrypoint_object(
fmodbf16
SRCS
fmodbf16.cpp
HDRS
../fmodbf16.h
DEPENDS
libc.src.__support.common
libc.src.__support.macros.config
libc.src.__support.macros.properties.types
libc.src.__support.FPUtil.bfloat16
libc.src.__support.FPUtil.generic.fmod
)

add_entrypoint_object(
fromfp
SRCS
Expand Down
21 changes: 21 additions & 0 deletions libc/src/math/generic/fmodbf16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation of fmodbf16 function -------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "src/math/fmodbf16.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/__support/FPUtil/generic/FMod.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(bfloat16, fmodbf16, (bfloat16 x, bfloat16 y)) {
return fputil::generic::FMod<bfloat16>::eval(x, y);
}

} // namespace LIBC_NAMESPACE_DECL
16 changes: 16 additions & 0 deletions libc/test/src/math/exhaustive/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,22 @@ add_fp_unittest(
-lpthread
)

add_fp_unittest(
fmodbf16_test
NO_RUN_POSTBUILD
NEED_MPFR
SUITE
libc_math_exhaustive_tests
SRCS
fmodbf16_test.cpp
DEPENDS
.exhaustive_test
libc.src.math.fmodbf16
libc.src.__support.FPUtil.bfloat16
LINK_LIBRARIES
-lpthread
)

add_fp_unittest(
coshf_test
NO_RUN_POSTBUILD
Expand Down
42 changes: 42 additions & 0 deletions libc/test/src/math/exhaustive/fmodbf16_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//===-- Exhaustive test for fmodbf16 --------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include "exhaustive_test.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/math/fmodbf16.h"
#include "utils/MPFRWrapper/MPFRUtils.h"

namespace mpfr = LIBC_NAMESPACE::testing::mpfr;

using LlvmLibcFmodf16ExhaustiveTest =
LlvmLibcBinaryOpExhaustiveMathTest<bfloat16, mpfr::Operation::Fmod,
LIBC_NAMESPACE::fmodbf16>;

// range: [0, inf]
static constexpr uint16_t POS_START = 0x0000U;
static constexpr uint16_t POS_STOP = 0x7f80U;

// range: [-0, -inf]
static constexpr uint16_t NEG_START = 0x8000U;
static constexpr uint16_t NEG_STOP = 0xff80U;

TEST_F(LlvmLibcFmodf16ExhaustiveTest, PostivePositiveRange) {
test_full_range_all_roundings(POS_START, POS_STOP, POS_START, POS_STOP);
}

TEST_F(LlvmLibcFmodf16ExhaustiveTest, PostiveNegativeRange) {
test_full_range_all_roundings(POS_START, POS_STOP, NEG_START, NEG_STOP);
}

TEST_F(LlvmLibcFmodf16ExhaustiveTest, NegativePositiveRange) {
test_full_range_all_roundings(NEG_START, NEG_STOP, POS_START, POS_STOP);
}

TEST_F(LlvmLibcFmodf16ExhaustiveTest, NegativeNegativeRange) {
test_full_range_all_roundings(NEG_START, NEG_STOP, NEG_START, NEG_STOP);
}
17 changes: 17 additions & 0 deletions libc/test/src/math/smoke/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4503,6 +4503,23 @@ add_fp_unittest(
UNIT_TEST_ONLY
)

add_fp_unittest(
fmodbf16_test
SUITE
libc-math-smoke-tests
SRCS
fmodbf16_test.cpp
HDRS
FModTest.h
DEPENDS
libc.hdr.fenv_macros
libc.src.errno.errno
libc.src.math.fmodbf16
libc.src.__support.FPUtil.bfloat16
libc.src.__support.FPUtil.fenv_impl
UNIT_TEST_ONLY
)

add_fp_unittest(
coshf_test
SUITE
Expand Down
Loading
Loading