-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
[libc] Re-Enable GPU tests and fix math exception handling #83172
Conversation
@llvm/pr-subscribers-libc Author: Joseph Huber (jhuber6) ChangesSummary: These pass locally when tested on a gfx1030, gfx90a, and sm_89 Full diff: https://github.com/llvm/llvm-project/pull/83172.diff 6 Files Affected:
diff --git a/libc/include/llvm-libc-macros/math-macros.h b/libc/include/llvm-libc-macros/math-macros.h
index 0a23647319f4d3..0fe8359d2c7f5f 100644
--- a/libc/include/llvm-libc-macros/math-macros.h
+++ b/libc/include/llvm-libc-macros/math-macros.h
@@ -10,6 +10,7 @@
#define __LLVM_LIBC_MACROS_MATH_MACROS_H
#include "limits-macros.h"
+#include "src/__support/macros/properties/architectures.h"
#define MATH_ERRNO 1
#define MATH_ERREXCEPT 2
@@ -32,6 +33,8 @@
#define math_errhandling 0
#elif defined(__NO_MATH_ERRNO__)
#define math_errhandling (MATH_ERREXCEPT)
+#elif defined(LIBC_TARGET_ARCH_IS_GPU)
+#define math_errhandling (MATH_ERRNO)
#else
#define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT)
#endif
diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index c5634866f839b3..7200ac276fe502 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -1,17 +1,14 @@
add_custom_target(libc-support-tests)
-# FIXME: These tests are currently broken on the GPU.
-if(NOT LIBC_TARGET_OS_IS_GPU)
- add_libc_test(
- blockstore_test
- SUITE
- libc-support-tests
- SRCS
- blockstore_test.cpp
- DEPENDS
- libc.src.__support.blockstore
- )
-endif()
+add_libc_test(
+ blockstore_test
+ SUITE
+ libc-support-tests
+ SRCS
+ blockstore_test.cpp
+ DEPENDS
+ libc.src.__support.blockstore
+)
add_libc_test(
endian_test
@@ -42,8 +39,6 @@ add_libc_test(
DEPENDS
libc.src.__support.high_precision_decimal
libc.src.__support.uint128
- # FIXME Test segfaults on gfx90a GPU
- UNIT_TEST_ONLY
)
add_libc_test(
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 81d2e1e55b5525..ad7dfdb3dfd9ec 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -758,40 +758,37 @@ add_fp_unittest(
libc.src.__support.FPUtil.basic_operations
)
-# FIXME: These tests are currently broken for NVPTX.
-if(NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
- add_fp_unittest(
- ilogb_test
- SUITE
- libc-math-unittests
- SRCS
- ilogb_test.cpp
- HDRS
- ILogbTest.h
- DEPENDS
- libc.include.math
- libc.src.math.ilogb
- libc.src.__support.CPP.limits
- libc.src.__support.FPUtil.fp_bits
- libc.src.__support.FPUtil.manipulation_functions
- )
+add_fp_unittest(
+ ilogb_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ ilogb_test.cpp
+ HDRS
+ ILogbTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.ilogb
+ libc.src.__support.CPP.limits
+ libc.src.__support.FPUtil.fp_bits
+ libc.src.__support.FPUtil.manipulation_functions
+)
- add_fp_unittest(
- ilogbf_test
- SUITE
- libc-math-unittests
- SRCS
- ilogbf_test.cpp
- HDRS
- ILogbTest.h
- DEPENDS
- libc.include.math
- libc.src.math.ilogbf
- libc.src.__support.CPP.limits
- libc.src.__support.FPUtil.fp_bits
- libc.src.__support.FPUtil.manipulation_functions
- )
-endif()
+add_fp_unittest(
+ ilogbf_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ ilogbf_test.cpp
+ HDRS
+ ILogbTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.ilogbf
+ libc.src.__support.CPP.limits
+ libc.src.__support.FPUtil.fp_bits
+ libc.src.__support.FPUtil.manipulation_functions
+)
add_fp_unittest(
ilogbl_test
@@ -989,92 +986,89 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)
-# FIXME: These tests are currently broken on the GPU.
-if(NOT LIBC_TARGET_OS_IS_GPU)
- add_fp_unittest(
- fminf_test
- SUITE
- libc-math-unittests
- SRCS
- fminf_test.cpp
- HDRS
- FMinTest.h
- DEPENDS
- libc.include.math
- libc.src.math.fminf
- libc.src.__support.FPUtil.fp_bits
- )
+add_fp_unittest(
+ fminf_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ fminf_test.cpp
+ HDRS
+ FMinTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.fminf
+ libc.src.__support.FPUtil.fp_bits
+)
- add_fp_unittest(
- fmin_test
- SUITE
- libc-math-unittests
- SRCS
- fmin_test.cpp
- HDRS
- FMinTest.h
- DEPENDS
- libc.include.math
- libc.src.math.fmin
- libc.src.__support.FPUtil.fp_bits
- )
+add_fp_unittest(
+ fmin_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ fmin_test.cpp
+ HDRS
+ FMinTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.fmin
+ libc.src.__support.FPUtil.fp_bits
+)
- add_fp_unittest(
- fminl_test
- SUITE
- libc-math-unittests
- SRCS
- fminl_test.cpp
- HDRS
- FMinTest.h
- DEPENDS
- libc.include.math
- libc.src.math.fminl
- libc.src.__support.FPUtil.fp_bits
- )
+add_fp_unittest(
+ fminl_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ fminl_test.cpp
+ HDRS
+ FMinTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.fminl
+ libc.src.__support.FPUtil.fp_bits
+)
- add_fp_unittest(
- fmaxf_test
- SUITE
- libc-math-unittests
- SRCS
- fmaxf_test.cpp
- HDRS
- FMaxTest.h
- DEPENDS
- libc.include.math
- libc.src.math.fmaxf
- libc.src.__support.FPUtil.fp_bits
- )
+add_fp_unittest(
+ fmaxf_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ fmaxf_test.cpp
+ HDRS
+ FMaxTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.fmaxf
+ libc.src.__support.FPUtil.fp_bits
+)
- add_fp_unittest(
- fmax_test
- SUITE
- libc-math-unittests
- SRCS
- fmax_test.cpp
- HDRS
- FMaxTest.h
- DEPENDS
- libc.include.math
- libc.src.math.fmax
- libc.src.__support.FPUtil.fp_bits
- )
+add_fp_unittest(
+ fmax_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ fmax_test.cpp
+ HDRS
+ FMaxTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.fmax
+ libc.src.__support.FPUtil.fp_bits
+)
- add_fp_unittest(
- fmaxl_test
- SUITE
- libc-math-unittests
- SRCS
- fmaxl_test.cpp
- HDRS
- FMaxTest.h
- DEPENDS
- libc.include.math
- libc.src.math.fmaxl
- libc.src.__support.FPUtil.fp_bits
- )
-endif()
+add_fp_unittest(
+ fmaxl_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ fmaxl_test.cpp
+ HDRS
+ FMaxTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.fmaxl
+ libc.src.__support.FPUtil.fp_bits
+)
add_fp_unittest(
sqrtf_test
@@ -1234,38 +1228,35 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)
-# FIXME: These tests are currently spurious for NVPTX.
-if(NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
- add_fp_unittest(
- nextafter_test
- SUITE
- libc-math-unittests
- SRCS
- nextafter_test.cpp
- HDRS
- NextAfterTest.h
- DEPENDS
- libc.include.math
- libc.src.math.nextafter
- libc.src.__support.FPUtil.basic_operations
- libc.src.__support.FPUtil.fp_bits
- )
+add_fp_unittest(
+ nextafter_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ nextafter_test.cpp
+ HDRS
+ NextAfterTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.nextafter
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.fp_bits
+)
- add_fp_unittest(
- nextafterf_test
- SUITE
- libc-math-unittests
- SRCS
- nextafterf_test.cpp
- HDRS
- NextAfterTest.h
- DEPENDS
- libc.include.math
- libc.src.math.nextafterf
- libc.src.__support.FPUtil.basic_operations
- libc.src.__support.FPUtil.fp_bits
- )
-endif()
+add_fp_unittest(
+ nextafterf_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ nextafterf_test.cpp
+ HDRS
+ NextAfterTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.nextafterf
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.fp_bits
+)
add_fp_unittest(
nextafterl_test
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 825000e1cb7afe..be1810944495b2 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -758,38 +758,35 @@ add_fp_unittest(
libc.src.math.frexpf128
)
-# FIXME: These tests are currently broken for NVPTX.
-if(NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
- add_fp_unittest(
- ilogb_test
- SUITE
- libc-math-smoke-tests
- SRCS
- ilogb_test.cpp
- HDRS
- ILogbTest.h
- DEPENDS
- libc.src.math.ilogb
- libc.src.__support.CPP.limits
- libc.src.__support.FPUtil.fp_bits
- libc.src.__support.FPUtil.manipulation_functions
- )
+add_fp_unittest(
+ ilogb_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ ilogb_test.cpp
+ HDRS
+ ILogbTest.h
+ DEPENDS
+ libc.src.math.ilogb
+ libc.src.__support.CPP.limits
+ libc.src.__support.FPUtil.fp_bits
+ libc.src.__support.FPUtil.manipulation_functions
+)
- add_fp_unittest(
- ilogbf_test
- SUITE
- libc-math-smoke-tests
- SRCS
- ilogbf_test.cpp
- HDRS
- ILogbTest.h
- DEPENDS
- libc.src.math.ilogbf
- libc.src.__support.CPP.limits
- libc.src.__support.FPUtil.fp_bits
- libc.src.__support.FPUtil.manipulation_functions
- )
-endif()
+add_fp_unittest(
+ ilogbf_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ ilogbf_test.cpp
+ HDRS
+ ILogbTest.h
+ DEPENDS
+ libc.src.math.ilogbf
+ libc.src.__support.CPP.limits
+ libc.src.__support.FPUtil.fp_bits
+ libc.src.__support.FPUtil.manipulation_functions
+)
add_fp_unittest(
ilogbl_test
@@ -1417,38 +1414,35 @@ add_fp_unittest(
UNIT_TEST_ONLY
)
-# FIXME: These tests are currently spurious for NVPTX.
-if(NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
- add_fp_unittest(
- nextafter_test
- SUITE
- libc-math-smoke-tests
- SRCS
- nextafter_test.cpp
- HDRS
- NextAfterTest.h
- DEPENDS
- libc.include.math
- libc.src.math.nextafter
- libc.src.__support.FPUtil.basic_operations
- libc.src.__support.FPUtil.fp_bits
- )
+add_fp_unittest(
+ nextafter_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ nextafter_test.cpp
+ HDRS
+ NextAfterTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.nextafter
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.fp_bits
+)
- add_fp_unittest(
- nextafterf_test
- SUITE
- libc-math-smoke-tests
- SRCS
- nextafterf_test.cpp
- HDRS
- NextAfterTest.h
- DEPENDS
- libc.include.math
- libc.src.math.nextafterf
- libc.src.__support.FPUtil.basic_operations
- libc.src.__support.FPUtil.fp_bits
- )
-endif()
+add_fp_unittest(
+ nextafterf_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ nextafterf_test.cpp
+ HDRS
+ NextAfterTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.nextafterf
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.fp_bits
+)
add_fp_unittest(
nextafterl_test
diff --git a/libc/test/src/stdlib/CMakeLists.txt b/libc/test/src/stdlib/CMakeLists.txt
index 5826cfe8d4ca34..5488a61c4ef187 100644
--- a/libc/test/src/stdlib/CMakeLists.txt
+++ b/libc/test/src/stdlib/CMakeLists.txt
@@ -54,20 +54,17 @@ add_libc_test(
libc.src.stdlib.atoll
)
-# This fails on NVPTX where the output value is one-off of the expected value.
-if(NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
- add_fp_unittest(
- strtod_test
- SUITE
- libc-stdlib-tests
- SRCS
- strtod_test.cpp
- DEPENDS
- libc.src.errno.errno
- libc.src.stdlib.strtod
- libc.src.__support.FPUtil.fenv_impl
- )
-endif()
+add_fp_unittest(
+ strtod_test
+ SUITE
+ libc-stdlib-tests
+ SRCS
+ strtod_test.cpp
+ DEPENDS
+ libc.src.errno.errno
+ libc.src.stdlib.strtod
+ libc.src.__support.FPUtil.fenv_impl
+)
add_fp_unittest(
strtof_test
@@ -126,20 +123,17 @@ add_libc_test(
.strtol_test_support
)
-# This fails on NVPTX where the output value is one-off of the expected value.
-if(NOT LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
- add_libc_test(
- strtold_test
- SUITE
- libc-stdlib-tests
- SRCS
- strtold_test.cpp
- DEPENDS
- libc.src.errno.errno
- libc.src.__support.uint128
- libc.src.stdlib.strtold
- )
-endif()
+add_libc_test(
+ strtold_test
+ SUITE
+ libc-stdlib-tests
+ SRCS
+ strtold_test.cpp
+ DEPENDS
+ libc.src.errno.errno
+ libc.src.__support.uint128
+ libc.src.stdlib.strtold
+)
add_libc_test(
strtoll_test
diff --git a/libc/test/src/time/CMakeLists.txt b/libc/test/src/time/CMakeLists.txt
index ebb0998feb23e9..51cacef0a62fe8 100644
--- a/libc/test/src/time/CMakeLists.txt
+++ b/libc/test/src/time/CMakeLists.txt
@@ -102,21 +102,17 @@ add_libc_unittest(
libc.src.__support.CPP.limits
)
-# Sleeping is not supported on older NVPTX architectures.
-set(unsupported_architectures "sm_35;sm_37;sm_50;sm_52;sm_53;sm_60;sm_61;sm_62")
-if (NOT ("${LIBC_GPU_TARGET_ARCHITECTURE}" IN_LIST unsupported_architectures))
- add_libc_test(
- nanosleep_test
- SUITE
- libc_time_unittests
- SRCS
- nanosleep_test.cpp
- DEPENDS
- libc.include.time
- libc.src.time.nanosleep
- libc.src.errno.errno
- )
-endif()
+add_libc_test(
+ nanosleep_test
+ SUITE
+ libc_time_unittests
+ SRCS
+ nanosleep_test.cpp
+ DEPENDS
+ libc.include.time
+ libc.src.time.nanosleep
+ libc.src.errno.errno
+)
add_libc_unittest(
time_test
|
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.
90e3648
to
db3ecaf
Compare
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.