Skip to content

Commit 49febca

Browse files
committed
chore: implement tests for {ceil,floor,round,roundeven,trunc}bf16 functions
Signed-off-by: Krishna Pandey <[email protected]>
1 parent bdb82ad commit 49febca

File tree

6 files changed

+135
-0
lines changed

6 files changed

+135
-0
lines changed

libc/test/src/math/smoke/CMakeLists.txt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,19 @@ add_fp_unittest(
320320
libc.src.__support.FPUtil.fp_bits
321321
)
322322

323+
add_fp_unittest(
324+
truncbf16_test
325+
SUITE
326+
libc-math-smoke-tests
327+
SRCS
328+
truncbf16_test.cpp
329+
HDRS
330+
TruncTest.h
331+
DEPENDS
332+
libc.src.__support.FPUtil.bfloat16
333+
libc.src.math.truncbf16
334+
)
335+
323336
add_fp_unittest(
324337
canonicalize_test
325338
SUITE
@@ -519,6 +532,19 @@ add_fp_unittest(
519532
libc.src.__support.FPUtil.fp_bits
520533
)
521534

535+
add_fp_unittest(
536+
ceilbf16_test
537+
SUITE
538+
libc-math-smoke-tests
539+
SRCS
540+
ceilbf16_test.cpp
541+
HDRS
542+
CeilTest.h
543+
DEPENDS
544+
libc.src.__support.FPUtil.bfloat16
545+
libc.src.math.ceilbf16
546+
)
547+
522548
add_fp_unittest(
523549
dfmal_test
524550
SUITE
@@ -639,6 +665,19 @@ add_fp_unittest(
639665
libc.src.__support.FPUtil.fp_bits
640666
)
641667

668+
add_fp_unittest(
669+
floorbf16_test
670+
SUITE
671+
libc-math-smoke-tests
672+
SRCS
673+
floorbf16_test.cpp
674+
HDRS
675+
FloorTest.h
676+
DEPENDS
677+
libc.src.__support.FPUtil.bfloat16
678+
libc.src.math.floorbf16
679+
)
680+
642681
add_fp_unittest(
643682
round_test
644683
SUITE
@@ -767,6 +806,19 @@ add_fp_unittest(
767806
libc.src.__support.FPUtil.fp_bits
768807
)
769808

809+
add_fp_unittest(
810+
roundevenbf16_test
811+
SUITE
812+
libc-math-smoke-tests
813+
SRCS
814+
roundevenbf16_test.cpp
815+
HDRS
816+
RoundEvenTest.h
817+
DEPENDS
818+
libc.src.__support.FPUtil.bfloat16
819+
libc.src.math.roundevenbf16
820+
)
821+
770822
add_fp_unittest(
771823
lround_test
772824
SUITE
@@ -847,6 +899,19 @@ add_fp_unittest(
847899
libc.src.__support.FPUtil.fp_bits
848900
)
849901

902+
add_fp_unittest(
903+
roundbf16_test
904+
SUITE
905+
libc-math-smoke-tests
906+
SRCS
907+
roundbf16_test.cpp
908+
HDRS
909+
RoundTest.h
910+
DEPENDS
911+
libc.src.__support.FPUtil.bfloat16
912+
libc.src.math.roundbf16
913+
)
914+
850915
add_fp_unittest(
851916
llround_test
852917
SUITE
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===-- Unittests for ceilbf16 --------------------------------------------===//
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-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "CeilTest.h"
10+
11+
#include "src/__support/FPUtil/bfloat16.h"
12+
#include "src/math/ceilbf16.h"
13+
14+
LIST_CEIL_TESTS(bfloat16, LIBC_NAMESPACE::ceilbf16)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===-- Unittests for floorbf16 -------------------------------------------===//
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-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "FloorTest.h"
10+
11+
#include "src/__support/FPUtil/bfloat16.h"
12+
#include "src/math/floorbf16.h"
13+
14+
LIST_FLOOR_TESTS(bfloat16, LIBC_NAMESPACE::floorbf16)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===-- Unittests for roundbf16 -------------------------------------------===//
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-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "RoundTest.h"
10+
11+
#include "src/__support/FPUtil/bfloat16.h"
12+
#include "src/math/roundbf16.h"
13+
14+
LIST_ROUND_TESTS(bfloat16, LIBC_NAMESPACE::roundbf16)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===-- Unittests for roundevenbf16 ---------------------------------------===//
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-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "RoundEvenTest.h"
10+
11+
#include "src/__support/FPUtil/bfloat16.h"
12+
#include "src/math/roundevenbf16.h"
13+
14+
LIST_ROUNDEVEN_TESTS(bfloat16, LIBC_NAMESPACE::roundevenbf16)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//===-- Unittests for truncbf16 -------------------------------------------===//
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-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "TruncTest.h"
10+
11+
#include "src/__support/FPUtil/bfloat16.h"
12+
#include "src/math/truncbf16.h"
13+
14+
LIST_TRUNC_TESTS(bfloat16, LIBC_NAMESPACE::truncbf16)

0 commit comments

Comments
 (0)