[openmp] Fix flang detection for offloading test

This patch fixes the flang detection in the openmp fortran offloading test.

Reviewed By: jsjodin

Differential Revision: https://reviews.llvm.org/D158546
This commit is contained in:
Ethan Luis McDonough
2023-08-29 16:27:30 -05:00
parent a43bf8a889
commit 9e3d59e4c2
6 changed files with 19 additions and 25 deletions

View File

@@ -36,6 +36,8 @@ if (OPENMP_STANDALONE_BUILD)
"C compiler to use for testing OpenMP runtime libraries.")
set(OPENMP_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE STRING
"C++ compiler to use for testing OpenMP runtime libraries.")
set(OPENMP_TEST_Fortran_COMPILER ${CMAKE_Fortran_COMPILER} CACHE STRING
"FORTRAN compiler to use for testing OpenMP runtime libraries.")
set(OPENMP_LLVM_TOOLS_DIR "" CACHE PATH "Path to LLVM tools for testing.")
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
@@ -54,6 +56,11 @@ else()
set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++.exe)
endif()
find_program(OPENMP_TEST_Fortran_COMPILER flang-new PATHS LLVM_RUNTIME_OUTPUT_INTDIR)
if (NOT OPENMP_TEST_Fortran_COMPILER)
unset(OPENMP_TEST_Fortran_COMPILER CACHE)
endif()
# If not standalone, set CMAKE_CXX_STANDARD but don't set the global cache value,
# only set it locally for OpenMP.
set(CMAKE_CXX_STANDARD 17)

View File

@@ -119,6 +119,10 @@ Options for all Libraries
Compiler to use for testing. Defaults to the compiler that was also used for
building.
**OPENMP_TEST_Fortran_COMPILER** = ``${CMAKE_Fortran_COMPILER}``
Compiler to use for testing. Defaults to the compiler that was also used for
building. Will default to flang if build is in-tree.
**OPENMP_LLVM_TOOLS_DIR** = ``/path/to/built/llvm/tools``
Additional path to search for LLVM tools needed by tests.
@@ -165,12 +169,6 @@ Options for ``libomp``
**LIBOMP_FORTRAN_MODULES** = ``OFF|ON``
Create the Fortran modules (requires Fortran compiler).
.. note::
If libomptarget is built in-tree with both flang and openmp in
`LLVM_ENABLE_PROJECTS`, flang will be used for Fortran offloading
tests.
macOS* Fat Libraries
""""""""""""""""""""
On macOS* machines, it is possible to build universal (or fat) libraries which

View File

@@ -33,13 +33,10 @@ foreach(CURRENT_TARGET IN LISTS SYSTEM_TARGETS)
configure_file(lit.site.cfg.in ${CURRENT_TARGET}/lit.site.cfg @ONLY)
endforeach()
if ("flang" IN_LIST LLVM_ENABLE_PROJECTS)
SET(FORTRAN_TEST_DEPS flang-new)
endif()
add_openmp_testsuite(check-libomptarget
"Running libomptarget tests"
${LIBOMPTARGET_LIT_TESTSUITES}
EXCLUDE_FROM_CHECK_ALL
DEPENDS omptarget omp ${LIBOMPTARGET_TESTED_PLUGINS} ${FORTRAN_TEST_DEPS}
DEPENDS omptarget omp ${LIBOMPTARGET_TESTED_PLUGINS}
ARGS ${LIBOMPTARGET_LIT_ARG_LIST})

View File

@@ -4,10 +4,6 @@
import os
import lit.formats
from lit.llvm import llvm_config
from lit.llvm.subst import ToolSubst
from lit.llvm.subst import FindTool
# Tell pylint that we know config and lit_config exist somewhere.
if 'PYLINT_IMPORT' in os.environ:
config = object()
@@ -70,8 +66,6 @@ config.test_source_root = os.path.dirname(__file__)
# test_exec_root: The root object directory where output is placed
config.test_exec_root = config.libomptarget_obj_root
tools = []
# test format
config.test_format = lit.formats.ShTest()
@@ -100,10 +94,6 @@ if config.has_libomptarget_ompt:
config.available_features.add(config.libomptarget_current_target)
if 'flang' in config.llvm_enabled_projects:
config.available_features.add('flang')
tools.append(ToolSubst('%flang', command=FindTool('flang-new'), unresolved='fatal'))
if config.libomptarget_has_libc:
config.available_features.add('libc')
@@ -320,6 +310,11 @@ for libomptarget_target in config.libomptarget_all_targets:
config.substitutions.append(("%clangxx", config.test_cxx_compiler))
config.substitutions.append(("%clang", config.test_c_compiler))
if config.test_fortran_compiler:
config.available_features.add('flang')
config.substitutions.append(("%flang", config.test_fortran_compiler))
config.substitutions.append(("%openmp_flags", config.test_openmp_flags))
if config.libomptarget_current_target.startswith('nvptx') and config.cuda_path:
config.substitutions.append(("%cuda_flags", "--cuda-path=" + config.cuda_path))
@@ -327,4 +322,3 @@ else:
config.substitutions.append(("%cuda_flags", ""))
config.substitutions.append(("%flags", config.test_flags))
config.substitutions.append(("%not", config.libomptarget_not))
llvm_config.add_tool_substitutions(tools, config.bin_llvm_tools_dir)

View File

@@ -3,6 +3,7 @@
config.bin_llvm_tools_dir = "@CMAKE_BINARY_DIR@/bin"
config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@"
config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@"
config.test_fortran_compiler="@OPENMP_TEST_Fortran_COMPILER@"
config.test_compiler_features = @OPENMP_TEST_COMPILER_FEATURES@
config.test_openmp_flags = "@OPENMP_TEST_OPENMP_FLAGS@"
config.test_extra_flags = "@OPENMP_TEST_FLAGS@"
@@ -21,11 +22,7 @@ config.libomptarget_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@"
config.libomptarget_not = "@OPENMP_NOT_EXECUTABLE@"
config.libomptarget_debug = @LIBOMPTARGET_DEBUG@
config.has_libomptarget_ompt = @LIBOMPTARGET_OMPT_SUPPORT@
config.llvm_enabled_projects = "@LLVM_ENABLE_PROJECTS@".split(";")
config.libomptarget_has_libc = @LIBOMPTARGET_GPU_LIBC_SUPPORT@
import lit.llvm
lit.llvm.initialize(lit_config, config)
# Let the main config do the real work.
lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")

View File

@@ -1,5 +1,6 @@
subroutine increment_at(c_index, arr) bind(C, name="increment_at")
use ISO_C_BINDING
!$omp declare target
integer (C_INT), dimension(*), intent(inout) :: arr
integer (C_INT), value :: c_index
arr(c_index+1) = arr(c_index+1) + 1