Skip to content
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
4 changes: 4 additions & 0 deletions llvm/runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ if(build_runtimes)
endif()
endforeach()
endif()
# Allow openmp to see the Fortran compiler
if ("openmp" IN_LIST LLVM_ENABLE_RUNTIMES AND "flang" IN_LIST LLVM_ENABLE_PROJECTS)
list(APPEND extra_args ENABLE_FORTRAN)
endif()
if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES OR "offload" IN_LIST LLVM_ENABLE_RUNTIMES)
if (${LLVM_TOOL_FLANG_BUILD})
message(STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang")
Expand Down
15 changes: 8 additions & 7 deletions openmp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@ else()
set(OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++.exe)
endif()

# Check for flang
if (NOT MSVC)
set(OPENMP_TEST_Fortran_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/flang)
else()
set(OPENMP_TEST_Fortran_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/flang.exe)
endif()

# Set fortran test compiler if flang is found
if (EXISTS "${OPENMP_TEST_Fortran_COMPILER}")
message("Using local flang build at ${OPENMP_TEST_Fortran_COMPILER}")
Expand All @@ -103,6 +96,14 @@ endif()
include(config-ix)
include(HandleOpenMPOptions)

# Check for flang
set(OPENMP_TEST_Fortran_COMPILER_default "flang")
if (CMAKE_Fortran_COMPILER)
set(OPENMP_TEST_Fortran_COMPILER_default "${CMAKE_Fortran_COMPILER}")
endif ()
set(OPENMP_TEST_Fortran_COMPILER "${OPENMP_TEST_Fortran_COMPILER_default}" CACHE STRING
"Fortran compiler to use for testing OpenMP runtime libraries.")

# Set up testing infrastructure.
include(OpenMPTesting)

Expand Down
2 changes: 1 addition & 1 deletion openmp/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Options for all Libraries

**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.
building.

**OPENMP_LLVM_TOOLS_DIR** = ``/path/to/built/llvm/tools``
Additional path to search for LLVM tools needed by tests.
Expand Down
4 changes: 4 additions & 0 deletions openmp/cmake/OpenMPTesting.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ function(add_openmp_testsuite target comment)
)
endif()
endif()

if (TARGET flang-rt)
add_dependencies(${target} flang-rt)
endif ()
endfunction()

function(construct_check_openmp_target)
Expand Down
8 changes: 7 additions & 1 deletion openmp/runtime/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ add_library(ompt-print-callback INTERFACE)
target_include_directories(ompt-print-callback INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/ompt)


add_openmp_testsuite(check-libomp "Running libomp tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS omp)
add_custom_target(libomp-test-depends)
add_dependencies(libomp-test-depends omp)
if (LLVM_RUNTIMES_BUILD AND OPENMP_TEST_Fortran_COMPILER AND "flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
add_dependencies(libomp-test-depends flang-rt)
endif ()

add_openmp_testsuite(check-libomp "Running libomp tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS libomp-test-depends)
# Add target check-ompt, but make sure to not add the tests twice to check-openmp.
add_openmp_testsuite(check-ompt "Running OMPT tests" ${CMAKE_CURRENT_BINARY_DIR}/ompt EXCLUDE_FROM_CHECK_ALL DEPENDS omp)

Expand Down
15 changes: 15 additions & 0 deletions openmp/runtime/test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import os
import re
import subprocess
import lit.formats
from lit.llvm.subst import ToolSubst
from lit.llvm import llvm_config

# Tell pylint that we know config and lit_config exist somewhere.
if 'PYLINT_IMPORT' in os.environ:
Expand Down Expand Up @@ -39,6 +41,19 @@ config.name = 'libomp'
# suffixes: A list of file extensions to treat as test files.
config.suffixes = ['.c', '.cpp']

if config.test_fortran_compiler:
lit_config.note("OpenMP Fortran tests enabled")
config.suffixes += ['.f90', '.F90']
llvm_config.add_tool_substitutions([
ToolSubst(
"%flang",
command=config.test_fortran_compiler,
unresolved="fatal",
),
], [config.llvm_tools_dir])
else:
lit_config.note("OpenMP Fortran tests disabled")

# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)

Expand Down
2 changes: 2 additions & 0 deletions openmp/runtime/test/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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_compiler_has_omp_h = @OPENMP_TEST_COMPILER_HAS_OMP_H@
config.test_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@"
Expand All @@ -24,6 +25,7 @@ config.has_omit_frame_pointer_flag = @OPENMP_TEST_COMPILER_HAS_OMIT_FRAME_POINTE
config.target_arch = "@LIBOMP_ARCH@"
config.compiler_frontend_variant = "@CMAKE_C_COMPILER_FRONTEND_VARIANT@"
config.compiler_simulate_id = "@CMAKE_C_SIMULATE_ID@"
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"

import lit.llvm
lit.llvm.initialize(lit_config, config)
Expand Down
26 changes: 26 additions & 0 deletions openmp/runtime/test/transform/unroll/heuristic_intdo.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
! This test checks lowering of OpenMP unroll directive

! RUN: %flang %flags %openmp_flags -fopenmp-version=51 %s -o %t.exe
! RUN: %t.exe | FileCheck %s --match-full-lines


program unroll_heuristic
integer :: i
print *, 'do'

!$OMP UNROLL
do i=7, 18, 3
print '("i=", I0)', i
end do
!$OMP END UNROLL

print *, 'done'
end program


! CHECK: do
! CHECK-NEXT: i=7
! CHECK-NEXT: i=10
! CHECK-NEXT: i=13
! CHECK-NEXT: i=16
! CHECK-NEXT: done