-
Notifications
You must be signed in to change notification settings - Fork 327
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
wangxin0321
wants to merge
15
commits into
llvm:main
Choose a base branch
from
wangxin0321:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c0d6f38
Update CMakeLists.txt
wangxin0321 2c7ac96
Update CMakeLists.txt
wangxin0321 e44459b
Create OpenACC_VV
wangxin0321 1dee022
Delete External/OpenACC_VV
wangxin0321 890de0f
Create OpenACC_VV
wangxin0321 974b5c5
Delete External/OpenACC_VV
wangxin0321 b07cd4b
Create README
wangxin0321 f6f8afe
Update README
wangxin0321 bdbb340
Create CMakeLists.txt
wangxin0321 0e85b3f
Update README
wangxin0321 e0cb263
Update README
wangxin0321 18c7e97
Update CMakeLists.txt
wangxin0321 a5cf0b1
Update CMakeLists.txt
wangxin0321 458e8a9
fix
3da7556
Update CMakeLists.txt
wangxin0321 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# 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 (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) | ||
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}") | ||
|
||
target_link_libraries(${_name} PUBLIC OpenACC::OpenACC_${_lang} m) | ||
|
||
# Add -fopenacc to linker command line; for some reason this is not done by target_link_libraries. | ||
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(${CMAKE_VERSION} VERSION_LESS 3.25) | ||
message(STATUS "The cmake version must be at least 3.25 to perform OpenACC tests") | ||
else() | ||
find_package(OpenACC) | ||
endif() | ||
if(OpenACC_FOUND) | ||
message(STATUS "Adding OpenACC Offloading Validiation & Verification") | ||
else() | ||
message(STATUS "NOT using OpenACC Validiation & Verification because OpenACC was not found") | ||
return() | ||
endif() | ||
|
||
foreach (_lang in C CXX Fortran) | ||
if(CMAKE_${_lang}_COMPILER) | ||
add_OpenACC_vv(${_lang}) | ||
endif() | ||
endforeach () | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this comment isn't accurate, right? It is adding the openacc-language flags, not the -fopenacc? Or where are the
OpenACC_C_flags
andOpenACC_CXX_flags
set?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my fault - you were right before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"OpenACC_C_flags "and "OpenACC_CXX_flags" are set in cmake. Check out the official FindOpenACC documentation at the following website: https://cmake.org/cmake/help/latest/module/FindOpenACC.html
But my error, currently find_package(OpenACC), only NVHPC, PGI, GNU and Cray compilers are supported, We cannot use this method to see if the current llvm supports OpenACC. "OpenACC_C_flags "and "OpenACC_CXX_flags" are currently invalid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wangxin0321 Is there a way around? Or we have to make an issue with cmake?