-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[libc][math][c++23] Add fmodbf16 math function #155575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
krishna2803
wants to merge
24
commits into
main
Choose a base branch
from
users/krishna2803/fmodbf16
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+193
−25
Open
Changes from 23 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 ff3915c
chore: update CMakeLists
krishna2803 cbdfc66
chore: add smoke tests for {canonicalize,iscanonical,fdim,copysign,is…
krishna2803 170f9b2
fix: add 0 to T cast
krishna2803 ceb8818
chore: update entrypoints
krishna2803 99f5872
docs: add {canonicalize,iscanonical,fdim,copysign,issignaling}bf16 ma…
krishna2803 204df34
feat: implement totalorder{,mag}bf16 math functions
krishna2803 06ca9a3
chore: add smoke tests for totalorder{,mag}bf16 math functions
krishna2803 f83bce4
chore: update entrypoints
krishna2803 4396ea9
docs: add totalorder{,mag}bf16 math functions
krishna2803 b633a76
feat: implement scalb{,l}nbf16 math functions
krishna2803 e99d5c2
chore: add smoke tests for scalb{,l}nbf16 math functions
krishna2803 a7187f9
chore: update entrypoints
krishna2803 5ff2ddc
docs: add scalb{,l}nbf16 math functions
krishna2803 d7930ac
feat: implement fmodbf16 math function
krishna2803 a772790
chore: add smoke tests for fmodbf16 math function
krishna2803 e5036f7
chore: add exahaustive tests for fmodbf16 math function
krishna2803 a902723
chore: update entrypoints
krishna2803 d451393
docs: add smoke tests for fmodbf16 math function
krishna2803 0e2a7d9
fix: FE_INEXACT exception
krishna2803 3c1a191
chore: remove redundant `uint16_t`
krishna2803 e42677d
Merge branch 'main' into users/krishna2803/fmodbf16
krishna2803 d8c8870
nit: rename test constant names
krishna2803 391111f
fix: typo POS_{START,STOP} -> NEG_{START,STOP}
krishna2803 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, POS_START, POS_STOP); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.