[Openmp-commits] [openmp] 9e3d59e - [openmp] Fix flang detection for offloading test
Ethan Luis McDonough via Openmp-commits
openmp-commits at lists.llvm.org
Tue Aug 29 14:49:45 PDT 2023
Author: Ethan Luis McDonough
Date: 2023-08-29T16:31:03-05:00
New Revision: 9e3d59e4c2d93af38cfdffe2378c4138872b9e03
URL: https://github.com/llvm/llvm-project/commit/9e3d59e4c2d93af38cfdffe2378c4138872b9e03
DIFF: https://github.com/llvm/llvm-project/commit/9e3d59e4c2d93af38cfdffe2378c4138872b9e03.diff
LOG: [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
Added:
Modified:
openmp/CMakeLists.txt
openmp/README.rst
openmp/libomptarget/test/CMakeLists.txt
openmp/libomptarget/test/lit.cfg
openmp/libomptarget/test/lit.site.cfg.in
openmp/libomptarget/test/offloading/fortran/basic_array.f90
Removed:
################################################################################
diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index c1efcaf80b54d6..c3338137479f33 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -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)
diff --git a/openmp/README.rst b/openmp/README.rst
index 2cdd38220d52a8..bb9443df56d765 100644
--- a/openmp/README.rst
+++ b/openmp/README.rst
@@ -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
diff --git a/openmp/libomptarget/test/CMakeLists.txt b/openmp/libomptarget/test/CMakeLists.txt
index 8908d2bb30adbd..a0ba233eaa5726 100644
--- a/openmp/libomptarget/test/CMakeLists.txt
+++ b/openmp/libomptarget/test/CMakeLists.txt
@@ -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})
diff --git a/openmp/libomptarget/test/lit.cfg b/openmp/libomptarget/test/lit.cfg
index 080ed197e8c00d..2406aaf44e39ea 100644
--- a/openmp/libomptarget/test/lit.cfg
+++ b/openmp/libomptarget/test/lit.cfg
@@ -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)
diff --git a/openmp/libomptarget/test/lit.site.cfg.in b/openmp/libomptarget/test/lit.site.cfg.in
index ffe9e182df49ec..9ee60d6082b77e 100644
--- a/openmp/libomptarget/test/lit.site.cfg.in
+++ b/openmp/libomptarget/test/lit.site.cfg.in
@@ -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")
diff --git a/openmp/libomptarget/test/offloading/fortran/basic_array.f90 b/openmp/libomptarget/test/offloading/fortran/basic_array.f90
index 776316bc9ed8c5..30fe7c8c0ef486 100644
--- a/openmp/libomptarget/test/offloading/fortran/basic_array.f90
+++ b/openmp/libomptarget/test/offloading/fortran/basic_array.f90
@@ -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
More information about the Openmp-commits
mailing list