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 #38

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions External/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ add_subdirectory(Povray)
add_subdirectory(SPEC)
add_subdirectory(skidmarks10)
add_subdirectory(sollve_vv)
add_subdirectory(OpenACCV_V)
52 changes: 52 additions & 0 deletions External/OpenACCV_V/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 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")

function (add_OpenACC_vv LANG)
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)
get_filename_component(_directory "${_file}" DIRECTORY)
string(REPLACE "." "" _ext "${_ext}")
set(_name "acctargetvv-${_basename}.${_ext}")

llvm_test_run()

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

# 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(${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="-fopenacc;-lm;-foffload='-lm';" \
-DTEST_SUITE_OFFLOADING_LDFLAGS="-fopenacc;-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