Skip to content

Commit fd42044

Browse files
authored
[libc] Re-Enable GPU tests and fix math exception handling (#83172)
Summary: A lot of these tests failed previously and were disabled. However we have fixed some things since then and many of these seem to pass. Additionally, the last remaining math tests that failed seemed to be due to the exception handling. For now we just set it to be 'errno'. These pass locally when tested on a gfx1030, gfx90a, and sm_89 architecture. Hopefully these pass correctly on the sm_60 bot as I've had things fail on that one only before.
1 parent f42e321 commit fd42044

File tree

6 files changed

+236
-264
lines changed

6 files changed

+236
-264
lines changed

libc/include/llvm-libc-macros/math-macros.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#define math_errhandling 0
3333
#elif defined(__NO_MATH_ERRNO__)
3434
#define math_errhandling (MATH_ERREXCEPT)
35+
#elif defined(__NVPTX__) || defined(__AMDGPU__)
36+
#define math_errhandling (MATH_ERRNO)
3537
#else
3638
#define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT)
3739
#endif

libc/test/src/__support/CMakeLists.txt

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
add_custom_target(libc-support-tests)
22

3-
# FIXME: These tests are currently broken on the GPU.
4-
if(NOT LIBC_TARGET_OS_IS_GPU)
5-
add_libc_test(
6-
blockstore_test
7-
SUITE
8-
libc-support-tests
9-
SRCS
10-
blockstore_test.cpp
11-
DEPENDS
12-
libc.src.__support.blockstore
13-
)
14-
endif()
3+
add_libc_test(
4+
blockstore_test
5+
SUITE
6+
libc-support-tests
7+
SRCS
8+
blockstore_test.cpp
9+
DEPENDS
10+
libc.src.__support.blockstore
11+
)
1512

1613
add_libc_test(
1714
endian_test
@@ -42,8 +39,6 @@ add_libc_test(
4239
DEPENDS
4340
libc.src.__support.high_precision_decimal
4441
libc.src.__support.uint128
45-
# FIXME Test segfaults on gfx90a GPU
46-
UNIT_TEST_ONLY
4742
)
4843

4944
add_libc_test(

libc/test/src/math/CMakeLists.txt

Lines changed: 136 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -758,40 +758,37 @@ add_fp_unittest(
758758
libc.src.__support.FPUtil.basic_operations
759759
)
760760

761-
# FIXME: These tests are currently broken for NVPTX.
762-
if(NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
763-
add_fp_unittest(
764-
ilogb_test
765-
SUITE
766-
libc-math-unittests
767-
SRCS
768-
ilogb_test.cpp
769-
HDRS
770-
ILogbTest.h
771-
DEPENDS
772-
libc.include.math
773-
libc.src.math.ilogb
774-
libc.src.__support.CPP.limits
775-
libc.src.__support.FPUtil.fp_bits
776-
libc.src.__support.FPUtil.manipulation_functions
777-
)
761+
add_fp_unittest(
762+
ilogb_test
763+
SUITE
764+
libc-math-unittests
765+
SRCS
766+
ilogb_test.cpp
767+
HDRS
768+
ILogbTest.h
769+
DEPENDS
770+
libc.include.math
771+
libc.src.math.ilogb
772+
libc.src.__support.CPP.limits
773+
libc.src.__support.FPUtil.fp_bits
774+
libc.src.__support.FPUtil.manipulation_functions
775+
)
778776

779-
add_fp_unittest(
780-
ilogbf_test
781-
SUITE
782-
libc-math-unittests
783-
SRCS
784-
ilogbf_test.cpp
785-
HDRS
786-
ILogbTest.h
787-
DEPENDS
788-
libc.include.math
789-
libc.src.math.ilogbf
790-
libc.src.__support.CPP.limits
791-
libc.src.__support.FPUtil.fp_bits
792-
libc.src.__support.FPUtil.manipulation_functions
793-
)
794-
endif()
777+
add_fp_unittest(
778+
ilogbf_test
779+
SUITE
780+
libc-math-unittests
781+
SRCS
782+
ilogbf_test.cpp
783+
HDRS
784+
ILogbTest.h
785+
DEPENDS
786+
libc.include.math
787+
libc.src.math.ilogbf
788+
libc.src.__support.CPP.limits
789+
libc.src.__support.FPUtil.fp_bits
790+
libc.src.__support.FPUtil.manipulation_functions
791+
)
795792

796793
add_fp_unittest(
797794
ilogbl_test
@@ -989,92 +986,89 @@ add_fp_unittest(
989986
libc.src.__support.FPUtil.fp_bits
990987
)
991988

992-
# FIXME: These tests are currently broken on the GPU.
993-
if(NOT LIBC_TARGET_OS_IS_GPU)
994-
add_fp_unittest(
995-
fminf_test
996-
SUITE
997-
libc-math-unittests
998-
SRCS
999-
fminf_test.cpp
1000-
HDRS
1001-
FMinTest.h
1002-
DEPENDS
1003-
libc.include.math
1004-
libc.src.math.fminf
1005-
libc.src.__support.FPUtil.fp_bits
1006-
)
989+
add_fp_unittest(
990+
fminf_test
991+
SUITE
992+
libc-math-unittests
993+
SRCS
994+
fminf_test.cpp
995+
HDRS
996+
FMinTest.h
997+
DEPENDS
998+
libc.include.math
999+
libc.src.math.fminf
1000+
libc.src.__support.FPUtil.fp_bits
1001+
)
10071002

1008-
add_fp_unittest(
1009-
fmin_test
1010-
SUITE
1011-
libc-math-unittests
1012-
SRCS
1013-
fmin_test.cpp
1014-
HDRS
1015-
FMinTest.h
1016-
DEPENDS
1017-
libc.include.math
1018-
libc.src.math.fmin
1019-
libc.src.__support.FPUtil.fp_bits
1020-
)
1003+
add_fp_unittest(
1004+
fmin_test
1005+
SUITE
1006+
libc-math-unittests
1007+
SRCS
1008+
fmin_test.cpp
1009+
HDRS
1010+
FMinTest.h
1011+
DEPENDS
1012+
libc.include.math
1013+
libc.src.math.fmin
1014+
libc.src.__support.FPUtil.fp_bits
1015+
)
10211016

1022-
add_fp_unittest(
1023-
fminl_test
1024-
SUITE
1025-
libc-math-unittests
1026-
SRCS
1027-
fminl_test.cpp
1028-
HDRS
1029-
FMinTest.h
1030-
DEPENDS
1031-
libc.include.math
1032-
libc.src.math.fminl
1033-
libc.src.__support.FPUtil.fp_bits
1034-
)
1017+
add_fp_unittest(
1018+
fminl_test
1019+
SUITE
1020+
libc-math-unittests
1021+
SRCS
1022+
fminl_test.cpp
1023+
HDRS
1024+
FMinTest.h
1025+
DEPENDS
1026+
libc.include.math
1027+
libc.src.math.fminl
1028+
libc.src.__support.FPUtil.fp_bits
1029+
)
10351030

1036-
add_fp_unittest(
1037-
fmaxf_test
1038-
SUITE
1039-
libc-math-unittests
1040-
SRCS
1041-
fmaxf_test.cpp
1042-
HDRS
1043-
FMaxTest.h
1044-
DEPENDS
1045-
libc.include.math
1046-
libc.src.math.fmaxf
1047-
libc.src.__support.FPUtil.fp_bits
1048-
)
1031+
add_fp_unittest(
1032+
fmaxf_test
1033+
SUITE
1034+
libc-math-unittests
1035+
SRCS
1036+
fmaxf_test.cpp
1037+
HDRS
1038+
FMaxTest.h
1039+
DEPENDS
1040+
libc.include.math
1041+
libc.src.math.fmaxf
1042+
libc.src.__support.FPUtil.fp_bits
1043+
)
10491044

1050-
add_fp_unittest(
1051-
fmax_test
1052-
SUITE
1053-
libc-math-unittests
1054-
SRCS
1055-
fmax_test.cpp
1056-
HDRS
1057-
FMaxTest.h
1058-
DEPENDS
1059-
libc.include.math
1060-
libc.src.math.fmax
1061-
libc.src.__support.FPUtil.fp_bits
1062-
)
1045+
add_fp_unittest(
1046+
fmax_test
1047+
SUITE
1048+
libc-math-unittests
1049+
SRCS
1050+
fmax_test.cpp
1051+
HDRS
1052+
FMaxTest.h
1053+
DEPENDS
1054+
libc.include.math
1055+
libc.src.math.fmax
1056+
libc.src.__support.FPUtil.fp_bits
1057+
)
10631058

1064-
add_fp_unittest(
1065-
fmaxl_test
1066-
SUITE
1067-
libc-math-unittests
1068-
SRCS
1069-
fmaxl_test.cpp
1070-
HDRS
1071-
FMaxTest.h
1072-
DEPENDS
1073-
libc.include.math
1074-
libc.src.math.fmaxl
1075-
libc.src.__support.FPUtil.fp_bits
1076-
)
1077-
endif()
1059+
add_fp_unittest(
1060+
fmaxl_test
1061+
SUITE
1062+
libc-math-unittests
1063+
SRCS
1064+
fmaxl_test.cpp
1065+
HDRS
1066+
FMaxTest.h
1067+
DEPENDS
1068+
libc.include.math
1069+
libc.src.math.fmaxl
1070+
libc.src.__support.FPUtil.fp_bits
1071+
)
10781072

10791073
add_fp_unittest(
10801074
sqrtf_test
@@ -1234,38 +1228,35 @@ add_fp_unittest(
12341228
libc.src.__support.FPUtil.fp_bits
12351229
)
12361230

1237-
# FIXME: These tests are currently spurious for NVPTX.
1238-
if(NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
1239-
add_fp_unittest(
1240-
nextafter_test
1241-
SUITE
1242-
libc-math-unittests
1243-
SRCS
1244-
nextafter_test.cpp
1245-
HDRS
1246-
NextAfterTest.h
1247-
DEPENDS
1248-
libc.include.math
1249-
libc.src.math.nextafter
1250-
libc.src.__support.FPUtil.basic_operations
1251-
libc.src.__support.FPUtil.fp_bits
1252-
)
1231+
add_fp_unittest(
1232+
nextafter_test
1233+
SUITE
1234+
libc-math-unittests
1235+
SRCS
1236+
nextafter_test.cpp
1237+
HDRS
1238+
NextAfterTest.h
1239+
DEPENDS
1240+
libc.include.math
1241+
libc.src.math.nextafter
1242+
libc.src.__support.FPUtil.basic_operations
1243+
libc.src.__support.FPUtil.fp_bits
1244+
)
12531245

1254-
add_fp_unittest(
1255-
nextafterf_test
1256-
SUITE
1257-
libc-math-unittests
1258-
SRCS
1259-
nextafterf_test.cpp
1260-
HDRS
1261-
NextAfterTest.h
1262-
DEPENDS
1263-
libc.include.math
1264-
libc.src.math.nextafterf
1265-
libc.src.__support.FPUtil.basic_operations
1266-
libc.src.__support.FPUtil.fp_bits
1267-
)
1268-
endif()
1246+
add_fp_unittest(
1247+
nextafterf_test
1248+
SUITE
1249+
libc-math-unittests
1250+
SRCS
1251+
nextafterf_test.cpp
1252+
HDRS
1253+
NextAfterTest.h
1254+
DEPENDS
1255+
libc.include.math
1256+
libc.src.math.nextafterf
1257+
libc.src.__support.FPUtil.basic_operations
1258+
libc.src.__support.FPUtil.fp_bits
1259+
)
12691260

12701261
add_fp_unittest(
12711262
nextafterl_test

0 commit comments

Comments
 (0)