Skip to content

Commit

Permalink
Detect if libomp is supported in the environment
Browse files Browse the repository at this point in the history
From LLVM 18, libomp is supported in s390x. Previously all the libomp related
tests were marked as XFAIL for s390x, which is no longer valid and marks
passing tests as failures. With the libomp detection and a new REQUIRE rule for
them the XFAIL is no longer needed.
  • Loading branch information
Jesus Checa Hidalgo committed Mar 5, 2024
1 parent d822092 commit 6a77d4a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@ option(ENABLE_HWASAN
${SUPPORT_HWASAN}
)

# Detect if libomp is supported in the current host. Setting it manually in all
# the environments can be tricky as s390x supports it only in llvm < 18
# This can still be explicitly enforced via -DENABLE_LIBOMP=ON|OFF
file(WRITE ${CMAKE_BINARY_DIR}/test.c "int main(){return 0;}")
message(STATUS "Checking libomp support")
execute_process(COMMAND
${CLANG_BINARY} -x c -fopenmp ${CMAKE_BINARY_DIR}/test.c
RESULT_VARIABLE PROC_RETURN
)
if (PROC_RETURN EQUAL 0)
set(SUPPORT_LIBOMP ON)
else()
message(STATUS "libomp not supported, related tests will be disabled")
set(SUPPORT_LIBOMP OFF)
endif()
OPTION(ENABLE_LIBOMP
"Enable tests that require libomp"
${SUPPORT_LIBOMP})

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/tests/lit.site.cfg.in
${CMAKE_BINARY_DIR}/tests/lit.site.cfg
Expand Down
3 changes: 1 addition & 2 deletions tests/basic_openmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
//
// RUN: %clang -fopenmp %s -o %t
// RUN: %t | grep "Num Threads: 1"
// REQUIRES: clang
// XFAIL: s390x
// REQUIRES: clang, libomp

#include <omp.h>
#include <stdio.h>
Expand Down
1 change: 1 addition & 0 deletions tests/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ enable_feature("libc++", "@ENABLE_LIBCXX@")
enable_feature("static-libc++", "@ENABLE_STATIC_LIBCXX@")
enable_feature("libunwind", "@ENABLE_LIBUNWIND@")
enable_feature("support_hwasan", "@ENABLE_HWASAN@")
enable_feature("libomp", "@ENABLE_LIBOMP@")
3 changes: 1 addition & 2 deletions tests/openmp_headers.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Test OpenMP headers install
//
// RUN: %clang -fopenmp -E %s -o %t
// REQUIRES: clang
// XFAIL: s390x
// REQUIRES: clang, libomp

#include <omp.h>
#if _OPENMP >= 201811
Expand Down
3 changes: 1 addition & 2 deletions tests/openmp_tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// RUN: %clang -fopenmp -DTOOLS %s -shared -o %t_Tools.so
// RUN: %clang -fopenmp -UTOOLS %s -o %t
// RUN: OMP_TOOL_LIBRARIES=%t_Tools.so %t | grep "INIT"
// REQUIRES: clang
// XFAIL: s390x
// REQUIRES: clang, libomp
#ifdef TOOLS

// OpenMP Tools are only supported starting OpenMP 5
Expand Down

0 comments on commit 6a77d4a

Please sign in to comment.