llvm-project
[libc][math][c++23] Implement basic arithmetic operations for BFloat16
#151228
Merged

[libc][math][c++23] Implement basic arithmetic operations for BFloat16 #151228

lntue merged 91 commits into llvm:main from krishna2803:bf16-arithmetic
krishna2803
krishna2803 [libc][stdfix] Fix typo `ulk` -> `lk` in riscv entrypoints
3bd7c349
krishna2803 Merge branch 'llvm:main' into main
f5bec032
krishna2803 feat: add bfloat16 struct
369756cb
krishna2803 add: FPType::BFloat16
817cdfa5
krishna2803 chore: remove compiler version checks and add bfloat16 to is_floating…
39511a45
krishna2803 feat: update MPCommon.h for bfloat16 type and change __bf16 to our ow…
265896dc
krishna2803 feat: create a dummy struct for bfloat16
0038a8ab
krishna2803 feat: add BFloat16 checks in compiler features
4086984d
krishna2803 feat: add dummy bfloat16 -> float conversion function
af0bda34
krishna2803 chore: add entrypoints for fbfloat16 function
67786f38
krishna2803 chore: add dummy tests for fbfloat16
485592ae
krishna2803 chore: update fbfloat16 dummy smoke tests
f3ef6e0a
krishna2803 fix: circular dependencies
548417c5
krishna2803 refactor: remove `LIBC_TYPES_HAS_BFLOAT16` dependency from sources an…
95b10485
krishna2803 refactor: fputil::cast for bfloat16
f14ff95d
krishna2803 feat: complete arbitrary float to bfloat conversion
9ef7cc1d
krishna2803 chore: complete smoke tests for fbfloat16 function
0058b85c
krishna2803 refactor: rename fbfloat16 smoke test suite, refactor bfloat16 specia…
77d38974
krishna2803 feat: add exhaustive tests for fbfloat16
3a1493e7
krishna2803 chore: update bfloat16 ctor to support conversion from non-floats
32a5efd4
krishna2803 refactor: bfloat16.h dependencies
394f420f
krishna2803 chore: remove fbfloat16 dummy function
f137dcf6
krishna2803 feat!: implement f{add,mul,div}bf16 functions
6faf4181
krishna2803 style: clang-format
1ce3c78a
krishna2803 feat: implement unittests for bfloat16 conversions
0bef082a
krishna2803 feat: implement bf16add function
c83492d1
krishna2803 chore: prevent casting to same type in fputil::cast
d5b22c27
krishna2803 remove: operator overload for equals from bfloat16 type
78af99a7
krishna2803 feat: add exhaustive tests for float to bfloat16 conversion
11097876
krishna2803 feat[WIP]: implement integer to bfloat16 ctor
5e882aa7
krishna2803 feat[WIP]: implement dummy tests for integer to bfloat16 ctor
ab1eb04d
krishna2803 feat: update bf16 integer ctor for correct rounding
a8ac5843
krishna2803 refactor: update test structure
41983f88
krishna2803 fix: test failures
ac2a4d74
krishna2803 refactor: address nits
b764234b
krishna2803 revert: remove CMake detection changes
78ff165c
krishna2803 chore: fix typo `InType` -> `OutType`
d6ae7dd8
krishna2803 chore: nits
622556e1
krishna2803 chore: remove duplicate include
a172f3ed
krishna2803 nit: indentation
617c7f3b
krishna2803 Apply suggestion from @overmighty
a8b74f9b
krishna2803 nit: suggestions
43f1b6a8
krishna2803 nit: indentation
63d34a79
krishna2803 nit: sorting
4eea0dca
krishna2803 chore: revert entrypoint changes
b8e4034d
krishna2803 merge: branch 'bfloat16' into 'bf16-arithmetic'
bb105744
krishna2803 feat![WIP]: use DyadicFloat<16> for bf16 add function
f67e67e8
krishna2803 refactor: inline lambda for testing int
7e98df48
krishna2803 chore: inline float cast overload
9012f7ea
krishna2803 nit: remove extra space
e36208c4
krishna2803 nit: minor changes
88e849bd
krishna2803 refactor: merge bfloat16 MPFRNumber ctor with float & float16
08cc137e
krishna2803 fix: ARM tests
eb05fcbd
krishna2803 refactor: move bfloat16 inside fputil namespace
26cce094
krishna2803 merge: branch 'bfloat16' into bf16-arithmetic
8763c15f
krishna2803 merge: branch 'main' into bf16-arithmetic
f4509cf3
krishna2803 refactor: remove old files and clean
67a24b70
krishna2803 feat: implement unary - operator
e65f2f83
krishna2803 merge: branch 'main' into bf16-arithmetic
26d0fa08
krishna2803 merge: branch 'main' into bf16-arithmetic
5b013d8f
krishna2803 feat: implement addition and subtraction operations for bfloat16
a3d128c2
krishna2803 feat: bfloat16 addition smoke tests
ccdcf0a6
krishna2803 feat!: bfloat16 subtraction smoke tests
76367054
krishna2803 chore: update bf16 add test header
72f23bc4
krishna2803 chore: add InType in multiplication tests
49acb3dd
krishna2803 feat: implement multiplication operation for bfloat16
5aa803d6
krishna2803 chore: use DyadicFloat<16> instead of DyadicFloat<8> for bfloat16.
d307338c
krishna2803 feat: implement division operation for bfloat16
e94fd8cc
krishna2803 fix: mul warnings
6cf4ad3e
krishna2803 refactor: use cpp::max in DyadicFloat selection
6ac2e57a
krishna2803 fix: deps
f8b1a497
krishna2803 feat: exhaustive tests for bfloat16 addition
9ef51c9a
krishna2803 feat: explain_binary_operation_one_output for bfloat16
ab17caa5
overmighty
overmighty commented on 2025-08-02
krishna2803 style: indentation
03cf2b29
krishna2803 chore: remove `inline`
c95542f7
krishna2803 chore: nits
8d5fc797
krishna2803 fix: update deps
b6c9579d
krishna2803 fix: headers
1ffcca13
github-actions
krishna2803 fix: clang-format
1585db16
krishna2803 krishna2803 marked this pull request as ready for review 43 days ago
krishna2803 feat: exhaustive tests for bfloat16 {div,mul,sub} and nits for bfloat…
76377ee5
krishna2803 fix: deps
264fa99a
krishna2803 fix: use MantissaType::WORD_SIZE instead of sizeof(MantissaType)
b7e418dd
krishna2803 style: refactoring
1c7a0670
krishna2803 style: shorter test names
5dd2d7df
krishna2803 chore: add more special numbers
26ee04f5
krishna2803 style: refactor and add TODO
c73e1722
krishna2803 merge: branch 'main' into bf16-arithmetic
718884d9
krishna2803 merge: branch 'main' into bf16-arithmetic
8a99e2a5
krishna2803 fix: typo
dfa253b4
krishna2803 refactor: add_sub and cast for bfloat16
e431dc4b
lntue lntue requested a review from lntue lntue 40 days ago
lntue
lntue commented on 2025-08-06
lntue
lntue approved these changes on 2025-08-06
krishna2803 fix: typo
ae2b7fcf
lntue
lntue approved these changes on 2025-08-06
lntue lntue merged a4ff76e8 into main 39 days ago
krishna2803 krishna2803 deleted the bf16-arithmetic branch 39 days ago
llvm-ci

Login to write a write a comment.

Login via GitHub

Reviewers
Assignees
No one assigned
Labels
Milestone