Skip to content
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

[External] Add OpenACC Validation and Verification Testsuite #88

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ include(TestSuite)
include(SingleMultiSource)
# Needs by External/sollve_vv.
find_package(OpenMP)
# Needs by External/OpenACCV_V.
find_package(OpenACC)
# Fortran Helper Modules
if(TEST_SUITE_FORTRAN)
include(Fortran)
Expand Down
1 change: 1 addition & 0 deletions External/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ add_subdirectory(Povray)
add_subdirectory(SPEC)
add_subdirectory(skidmarks10)
add_subdirectory(sollve_vv)
add_subdirectory(OpenACCV_V)
add_subdirectory(smoke)
82 changes: 82 additions & 0 deletions External/OpenACCV_V/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# OpenACCV&V Validation & Verification Suite
# https://github.com/OpenACCUserGroup/OpenACCV-V

include(External)

option(TEST_SUITE_FORCE_ALL "Execute all OpenACC V&V tests, even those known to be unsupported by Clang" OFF)

set(TEST_SUITE_OFFLOADING_FLAGS --offload-arch=native CACHE STRING "Compiler arguments for offloading")
set(TEST_SUITE_OFFLOADING_LDFLAGS --offload-arch=native CACHE STRING "Linker arguments for offloading")

set(EXPECT_FAIL
)

function (add_OpenACC_vv LANG)

if (NOT OpenACC_${LANG}_FOUND)
message(FATAL_ERROR "OpenACC for $(LANG} not found ")
return ()
endif ()

if ("${LANG}" STREQUAL "C")
set(_langext ".c")
elseif ("${LANG}" STREQUAL "CXX")
set(_langext ".cpp")
elseif ("${LANG}" STREQUAL "Fortran")
set(_langext ".F90")
else ()
message(FATAL_ERROR "Unsupported languge ${LANG}")
endif ()

file(GLOB_RECURSE _tests_sources RELATIVE "${TEST_SUITE_OPENACCVV_ROOT}/Tests" "${TEST_SUITE_OPENACCVV_ROOT}/Tests/*${_langext}" )
foreach (_file IN LISTS _tests_sources)
get_filename_component(_ext "${_file}" EXT)
get_filename_component(_basename "${_file}" NAME_WE)
string(REPLACE "." "" _ext "${_ext}")
set(_name "acctargetvv-${_basename}.${_ext}")

if (NOT TEST_SUITE_FORCE_ALL AND "$(_file)" IN_LIST EXPECT_FAIL)
message(STATUS "Skipping OpenACC V&V test ${_file}")
continue ()
else ()
message(STATUS "Compiling OpenACC V&V test ${_file}")
endif ()

llvm_test_run()

llvm_test_executable(${_name} "${TEST_SUITE_OPENACCVV_ROOT}/Tests/${_file}")

if (ENABLE_EXPERIMENTAL_OPENACC_MACRO_OVERRIDE)
target_compile_options(${_name} PUBLIC -fexperimental-openacc-macro-override)
endif ()

# Add -fopenacc to linker command line; only done with target_link_options.
target_link_options(${_name} PRIVATE ${OpenACC_${LANG}_FLAGS})

# CMake's find_package(OpenACC) currently does not not introspect flags necessary for offloading.
target_compile_options(${_name} PUBLIC ${TEST_SUITE_OFFLOADING_FLAGS})
target_link_options(${_name} PUBLIC ${TEST_SUITE_OFFLOADING_LDFLAGS})
endforeach ()
endfunction ()

llvm_externals_find(TEST_SUITE_OPENACCVV_ROOT "OpenACCV_V" "OpenACC Offloading Validation & Verification Suite")


if(TEST_SUITE_OPENACCVV_ROOT AND NOT TEST_SUITE_BENCHMARKING_ONLY)
if(OpenACC_FOUND)
message(STATUS "Adding OpenACC Validiation & Verification")
else()
message(STATUS "NOT using OpenACC Validiation & Verification because OpenACC was not found")
return()
endif()

if(${CMAKE_VERSION} VERSION_LESS 3.25)
message(STATUS "The cmake version must be at least 3.25 to perform OpenACC tests")
endif()

foreach (_lang in C CXX Fortran)
if(CMAKE_${_lang}_COMPILER)
add_OpenACC_vv(${_lang})
endif()
endforeach ()
endif ()
52 changes: 52 additions & 0 deletions External/OpenACCV_V/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
OpenACC Validation & Verification Suite
https://github.com/OpenACCUserGroup/OpenACCV-V

This directory contains a CMakeLists.txt for the OpenACC
Validation and Verification Suite so it can be built as part
of the LLVM test-suite. Its sources are not part of the test-suite but
have to be fetched separately from https://github.com/OpenACCUserGroup/OpenACCV-V

The sources are expected either in ${TEST_SUITE_OpenACCVV_ROOT} or
where TEST_SUITE_OpenACCVV_ROOT is CMake configure variables. If none of
them are set, it will look into
${CMAKE_SOURCE_DIR}/Extern/External/OpenACC_vv where
CMAKE_SOURCE_DIR is the root directory of the test-suite sources.

The CMakeLists.txt will search for all C 、C++ and Fortran source files of the
OpenACC V&V suite, compile and run them. That is, running llvm-lit
(or "make check") will require a compatible accelerator on the running
machine.

OpenACC support is autodetected by CMake, but clang requires additional
flags to enable offloading. An example run is:

$ cd /path/to/llvm-test-suit
$ mkdir build
$ cd build
$ cmake -GNinja -DTEST_SUITE_FORTRAN=ON \
-DTEST_SUITE_BENCHMARKING_ONLY=OFF \
-DTEST_SUITE_RUN_BENCHMARKS=ON \
-DTEST_SUITE_COLLECT_STATS=OFF \
-DTEST_SUITE_SUBDIRS="External/OpenACCV_V" \
-DCMAKE_BUILD_TYPE=Release \
-DTEST_SUITE_OpenACCVV_ROOT=/path/to/OpenACCV_V \
-DTEST_SUITE_COLLECT_CODE_SIZE=OFF \
-DTEST_SUITE_LIT=${HOME}/path/to/llvm-project/build/bin/llvm-lit \
-DCMAKE_C_COMPILER=${HOME}/install/llvm/bin/clang \
-DCMAKE_CXX_COMPILER=${HOME}/install/llvm/bin/clang++ \
-DCMAKE_Fortran_COMPILER=${HOME}/install/llvm/bin/flang \
-DTEST_SUITE_OFFLOADING_FLAGS="-lm;-foffload='-lm';" \
-DTEST_SUITE_OFFLOADING_LDFLAGS="-lm;-foffload='-lm';" \
../

To make:
$ LD_LIBRARY_PATH=${HOME}/install/llvm-project/release/lib
$ ninja check

To run:
The test results are saved in the reule file
$ llvm-lit -svj1 --shuffle --xunit-xml-output=result-xunit.xml .

Attention:
Because find_package(OpenACC) is used in this test case, attempting to execute this test case requires cmake version >= 3.25
take a closer look at FindOpenACC in cmake:https://cmake.org/cmake/help/latest/module/FindOpenACC.html