File tree Expand file tree Collapse file tree 8 files changed +67
-9
lines changed Expand file tree Collapse file tree 8 files changed +67
-9
lines changed Original file line number Diff line number Diff line change @@ -532,6 +532,10 @@ if(build_runtimes)
532
532
endif ()
533
533
endforeach ()
534
534
endif ()
535
+ # Allow openmp to see the Fortran compiler
536
+ if ("openmp" IN_LIST LLVM_ENABLE_RUNTIMES AND "flang" IN_LIST LLVM_ENABLE_PROJECTS)
537
+ list (APPEND extra_args ENABLE_FORTRAN)
538
+ endif ()
535
539
if ("openmp" IN_LIST LLVM_ENABLE_RUNTIMES OR "offload" IN_LIST LLVM_ENABLE_RUNTIMES)
536
540
if (${LLVM_TOOL_FLANG_BUILD} )
537
541
message (STATUS "Configuring build of omp_lib.mod and omp_lib_kinds.mod via flang" )
Original file line number Diff line number Diff line change @@ -78,13 +78,6 @@ else()
78
78
set (OPENMP_TEST_CXX_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR} /clang++.exe)
79
79
endif ()
80
80
81
- # Check for flang
82
- if (NOT MSVC )
83
- set (OPENMP_TEST_Fortran_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR} /flang)
84
- else ()
85
- set (OPENMP_TEST_Fortran_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR} /flang.exe)
86
- endif ()
87
-
88
81
# Set fortran test compiler if flang is found
89
82
if (EXISTS "${OPENMP_TEST_Fortran_COMPILER} " )
90
83
message ("Using local flang build at ${OPENMP_TEST_Fortran_COMPILER} " )
@@ -103,6 +96,14 @@ endif()
103
96
include (config-ix)
104
97
include (HandleOpenMPOptions)
105
98
99
+ # Check for flang
100
+ set (OPENMP_TEST_Fortran_COMPILER_default "flang" )
101
+ if (CMAKE_Fortran_COMPILER)
102
+ set (OPENMP_TEST_Fortran_COMPILER_default "${CMAKE_Fortran_COMPILER} " )
103
+ endif ()
104
+ set (OPENMP_TEST_Fortran_COMPILER "${OPENMP_TEST_Fortran_COMPILER_default} " CACHE STRING
105
+ "Fortran compiler to use for testing OpenMP runtime libraries." )
106
+
106
107
# Set up testing infrastructure.
107
108
include (OpenMPTesting)
108
109
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ Options for all Libraries
121
121
122
122
**OPENMP_TEST_Fortran_COMPILER ** = ``${CMAKE_Fortran_COMPILER} ``
123
123
Compiler to use for testing. Defaults to the compiler that was also used for
124
- building. Will default to flang if build is in-tree.
124
+ building.
125
125
126
126
**OPENMP_LLVM_TOOLS_DIR ** = ``/path/to/built/llvm/tools ``
127
127
Additional path to search for LLVM tools needed by tests.
Original file line number Diff line number Diff line change @@ -238,6 +238,10 @@ function(add_openmp_testsuite target comment)
238
238
)
239
239
endif ()
240
240
endif ()
241
+
242
+ if (TARGET flang-rt)
243
+ add_dependencies (${target} flang-rt)
244
+ endif ()
241
245
endfunction ()
242
246
243
247
function (construct_check_openmp_target)
Original file line number Diff line number Diff line change @@ -41,7 +41,13 @@ add_library(ompt-print-callback INTERFACE)
41
41
target_include_directories (ompt-print-callback INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} /ompt)
42
42
43
43
44
- add_openmp_testsuite(check-libomp "Running libomp tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS omp)
44
+ add_custom_target (libomp-test -depends )
45
+ add_dependencies (libomp-test -depends omp)
46
+ if (LLVM_RUNTIMES_BUILD AND OPENMP_TEST_Fortran_COMPILER AND "flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
47
+ add_dependencies (libomp-test -depends flang-rt)
48
+ endif ()
49
+
50
+ add_openmp_testsuite(check-libomp "Running libomp tests" ${CMAKE_CURRENT_BINARY_DIR} DEPENDS libomp-test -depends )
45
51
# Add target check-ompt, but make sure to not add the tests twice to check-openmp.
46
52
add_openmp_testsuite(check-ompt "Running OMPT tests" ${CMAKE_CURRENT_BINARY_DIR} /ompt EXCLUDE_FROM_CHECK_ALL DEPENDS omp)
47
53
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import os
5
5
import re
6
6
import subprocess
7
7
import lit .formats
8
+ from lit .llvm .subst import ToolSubst
9
+ from lit .llvm import llvm_config
8
10
9
11
# Tell pylint that we know config and lit_config exist somewhere.
10
12
if 'PYLINT_IMPORT' in os .environ :
@@ -39,6 +41,19 @@ config.name = 'libomp'
39
41
# suffixes: A list of file extensions to treat as test files.
40
42
config .suffixes = ['.c' , '.cpp' ]
41
43
44
+ if config .test_fortran_compiler :
45
+ lit_config .note ("OpenMP Fortran tests enabled" )
46
+ config .suffixes += ['.f90' , '.F90' ]
47
+ llvm_config .add_tool_substitutions ([
48
+ ToolSubst (
49
+ "%flang" ,
50
+ command = config .test_fortran_compiler ,
51
+ unresolved = "fatal" ,
52
+ ),
53
+ ], [config .llvm_tools_dir ])
54
+ else :
55
+ lit_config .note ("OpenMP Fortran tests disabled" )
56
+
42
57
# test_source_root: The root path where tests are located.
43
58
config .test_source_root = os .path .dirname (__file__ )
44
59
Original file line number Diff line number Diff line change 2
2
3
3
config.test_c_compiler = "@OPENMP_TEST_C_COMPILER@"
4
4
config.test_cxx_compiler = "@OPENMP_TEST_CXX_COMPILER@"
5
+ config.test_fortran_compiler = "@OPENMP_TEST_Fortran_COMPILER@"
5
6
config.test_compiler_features = @OPENMP_TEST_COMPILER_FEATURES@
6
7
config.test_compiler_has_omp_h = @OPENMP_TEST_COMPILER_HAS_OMP_H@
7
8
config.test_filecheck = "@OPENMP_FILECHECK_EXECUTABLE@"
@@ -24,6 +25,7 @@ config.has_omit_frame_pointer_flag = @OPENMP_TEST_COMPILER_HAS_OMIT_FRAME_POINTE
24
25
config.target_arch = "@LIBOMP_ARCH@"
25
26
config.compiler_frontend_variant = "@CMAKE_C_COMPILER_FRONTEND_VARIANT@"
26
27
config.compiler_simulate_id = "@CMAKE_C_SIMULATE_ID@"
28
+ config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
27
29
28
30
import lit.llvm
29
31
lit.llvm.initialize(lit_config, config)
Original file line number Diff line number Diff line change
1
+ ! This test checks lowering of OpenMP unroll directive
2
+
3
+ ! RUN: %flang %flags %openmp_flags -fopenmp-version=51 %s -o %t.exe
4
+ ! RUN: %t.exe | FileCheck %s --match-full-lines
5
+
6
+
7
+ program unroll_heuristic
8
+ integer :: i
9
+ print * , ' do'
10
+
11
+ ! $OMP UNROLL
12
+ do i= 7 , 18 , 3
13
+ print ' ("i=", I0)' , i
14
+ end do
15
+ ! $OMP END UNROLL
16
+
17
+ print * , ' done'
18
+ end program
19
+
20
+
21
+ ! CHECK: do
22
+ ! CHECK-NEXT: i=7
23
+ ! CHECK-NEXT: i=10
24
+ ! CHECK-NEXT: i=13
25
+ ! CHECK-NEXT: i=16
26
+ ! CHECK-NEXT: done
You can’t perform that action at this time.
0 commit comments