Skip to content

[OpenMP] Add Fortran tests #150722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
8 changes: 3 additions & 5 deletions openmp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ else()
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(OPENMP_TEST_Fortran_COMPILER ${CMAKE_Fortran_COMPILER} CACHE STRING
"FORTRAN compiler to use for testing OpenMP runtime libraries.")


# Set fortran test compiler if flang is found
if (EXISTS "${OPENMP_TEST_Fortran_COMPILER}")
Expand Down
4 changes: 4 additions & 0 deletions openmp/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

**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.
Expand Down
16 changes: 16 additions & 0 deletions openmp/runtime/test/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ 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']
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 Expand Up @@ -225,3 +231,13 @@ if config.has_ompt:
config.substitutions.append(("%no-as-needed-flag", "-Wl,--no-as-needed"))
else:
config.substitutions.append(("FileCheck", config.test_filecheck))

tools = [
ToolSubst(
"%flang",
command=config.test_fortran_compiler,
unresolved="fatal",
),
]

llvm_config.add_tool_substitutions(tools, [config.llvm_tools_dir])
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
Loading