Skip to content

[libc] Re-Enable GPU tests and fix math exception handling #83172

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

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libc/include/llvm-libc-macros/math-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#define math_errhandling 0
#elif defined(__NO_MATH_ERRNO__)
#define math_errhandling (MATH_ERREXCEPT)
#elif defined(__NVPTX__) || defined(__AMDGPU__)
#define math_errhandling (MATH_ERRNO)
#else
#define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT)
#endif
Expand Down
23 changes: 9 additions & 14 deletions libc/test/src/__support/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down
281 changes: 136 additions & 145 deletions libc/test/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading