-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL][PI] Fix PI unittests and always build them #585
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,9 +159,23 @@ add_custom_target( sycl-toolchain | |
COMMENT "Building SYCL compiler toolchain..." | ||
) | ||
|
||
add_subdirectory( test ) | ||
add_subdirectory( unittests ) | ||
add_subdirectory( tools ) | ||
if (NOT DEFINED LLVM_INCLUDE_TESTS) | ||
set(LLVM_INCLUDE_TESTS ON) | ||
endif() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aligns testing and unittests with other LLVM projects CMake usage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add this as a comment too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The commit contains a comment that SYCL CMake is now stronger aligned with how the other LLVM projects are set up. Other LLVM projects I checked do not comment on where they copied and adapted from other LLVM projects though it is clear that they are aligned. |
||
|
||
option(SYCL_INCLUDE_TESTS | ||
"Generate build targets for the SYCL unit tests." | ||
${LLVM_INCLUDE_TESTS}) | ||
|
||
add_subdirectory(tools) | ||
|
||
if(SYCL_INCLUDE_TESTS) | ||
if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h) | ||
add_subdirectory(unittests) | ||
list(APPEND SYCL_TEST_DEPS SYCLUnitTests) | ||
endif() | ||
add_subdirectory(test) | ||
endif() | ||
|
||
# Package deploy support | ||
# Listed here are component names contributing the package | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,22 +4,41 @@ set(LLVM_TOOLS_DIR "${LLVM_BINARY_DIR}/bin/") | |
set(CLANG_IN_BUILD "${LLVM_BINARY_DIR}/bin/clang") | ||
set(CLANGXX_IN_BUILD "${LLVM_BINARY_DIR}/bin/clang++") | ||
|
||
set(SYCL_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
set(SYCL_TESTS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
set(SYCL_TESTS_BINARY_DIR ${SYCL_BINARY_DIR}/test) | ||
get_target_property(SYCL_BINARY_DIR sycl-toolchain BINARY_DIR) | ||
get_target_property(SYCL_SOURCE_DIR sycl-toolchain SOURCE_DIR) | ||
|
||
set(SYCL_INCLUDE "${dst_dir}") | ||
|
||
set(RT_TEST_ARGS ${RT_TEST_ARGS} "-v") | ||
|
||
configure_lit_site_cfg( | ||
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in | ||
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg | ||
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in | ||
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aligning with Clang. |
||
MAIN_CONFIG | ||
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py | ||
) | ||
|
||
configure_lit_site_cfg( | ||
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in | ||
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py | ||
MAIN_CONFIG | ||
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg | ||
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py | ||
) | ||
|
||
list(APPEND SYCL_TEST_DEPS | ||
sycl-toolchain | ||
FileCheck | ||
get_device_count_by_type | ||
llvm-config | ||
) | ||
|
||
add_lit_testsuite(check-sycl "Running the SYCL regression tests" | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
ARGS ${RT_TEST_ARGS} | ||
DEPENDS sycl-toolchain FileCheck get_device_count_by_type llvm-config | ||
DEPENDS ${SYCL_TEST_DEPS} | ||
) | ||
set_target_properties(check-sycl PROPERTIES FOLDER "SYCL tests") | ||
|
||
add_lit_testsuites(SYCL ${CMAKE_CURRENT_SOURCE_DIR} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds a |
||
DEPENDS ${SYCL_TEST_DEPS} | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- Python -*- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copied and adapted from Clang. |
||
|
||
# Configuration file for the 'lit' test runner. | ||
|
||
import os | ||
import platform | ||
import subprocess | ||
|
||
import lit.formats | ||
import lit.util | ||
|
||
# name: The name of this test suite. | ||
config.name = 'SYCL-Unit' | ||
|
||
# suffixes: A list of file extensions to treat as test files. | ||
config.suffixes = [] | ||
|
||
# test_source_root: The root path where tests are located. | ||
# test_exec_root: The root path where tests should be run. | ||
config.test_exec_root = os.path.join(config.sycl_obj_root, 'unittests') | ||
config.test_source_root = config.test_exec_root | ||
|
||
# testFormat: The test format to use to interpret tests. | ||
config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, 'Tests') | ||
|
||
# Propagate the temp directory. Windows requires this because it uses \Windows\ | ||
# if none of these are present. | ||
if 'TMP' in os.environ: | ||
config.environment['TMP'] = os.environ['TMP'] | ||
if 'TEMP' in os.environ: | ||
config.environment['TEMP'] = os.environ['TEMP'] | ||
|
||
# Propagate path to symbolizer for ASan/MSan. | ||
for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']: | ||
if symbolizer in os.environ: | ||
config.environment[symbolizer] = os.environ[symbolizer] | ||
|
||
def find_shlibpath_var(): | ||
if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']: | ||
yield 'LD_LIBRARY_PATH' | ||
elif platform.system() == 'Darwin': | ||
yield 'DYLD_LIBRARY_PATH' | ||
elif platform.system() == 'Windows': | ||
yield 'PATH' | ||
elif platform.system() == 'AIX': | ||
yield 'LIBPATH' | ||
|
||
for shlibpath_var in find_shlibpath_var(): | ||
# in stand-alone builds, shlibdir is clang's build tree | ||
# while llvm_libs_dir is installed LLVM (and possibly older clang) | ||
shlibpath = os.path.pathsep.join( | ||
(config.shlibdir, | ||
config.llvm_libs_dir, | ||
config.environment.get(shlibpath_var, ''))) | ||
config.environment[shlibpath_var] = shlibpath | ||
break | ||
else: | ||
lit_config.warning("unable to inject shared library path on '{}'" | ||
.format(platform.system())) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@LIT_SITE_CFG_IN_HEADER@ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copied and adapted from Clang. |
||
|
||
import sys | ||
|
||
config.llvm_src_root = "@LLVM_SOURCE_DIR@" | ||
config.llvm_obj_root = "@LLVM_BINARY_DIR@" | ||
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" | ||
config.llvm_libs_dir = "@LLVM_LIBS_DIR@" | ||
config.llvm_build_mode = "@LLVM_BUILD_MODE@" | ||
config.clang_obj_root = "@CLANG_BINARY_DIR@" | ||
config.enable_shared = @ENABLE_SHARED@ | ||
config.shlibdir = "@SHLIBDIR@" | ||
config.target_triple = "@TARGET_TRIPLE@" | ||
config.sycl_obj_root = "@SYCL_BINARY_DIR@" | ||
|
||
# Support substitution of the tools_dir, libs_dirs, and build_mode with user | ||
# parameters. This is used when we can't determine the tool dir at | ||
# configuration time. | ||
try: | ||
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params | ||
config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params | ||
config.llvm_build_mode = config.llvm_build_mode % lit_config.params | ||
except KeyError: | ||
e = sys.exc_info()[1] | ||
key, = e.args | ||
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) | ||
|
||
# Let the main config do the real work. | ||
lit_config.load_config(config, "@SYCL_SOURCE_DIR@/test/Unit/lit.cfg.py") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
# Configuration file for the 'lit' test runner. | ||
|
||
# name: The name of this test suite. | ||
config.name = 'SYCLUnitTests' | ||
config.name = 'SYCL' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is in line with Clang now. |
||
|
||
# testFormat: The test format to use to interpret tests. | ||
# | ||
|
@@ -31,7 +31,7 @@ | |
config.test_source_root = os.path.dirname(__file__) | ||
|
||
# test_exec_root: The root path where tests should be run. | ||
config.test_exec_root = os.path.join(config.sycl_dir, 'test') | ||
config.test_exec_root = os.path.join(config.sycl_obj_root, 'test') | ||
|
||
if platform.system() == "Linux": | ||
# Propagate 'LD_LIBRARY_PATH' through the environment. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
add_custom_target(PiUnitTests) | ||
set_target_properties(PiUnitTests PROPERTIES FOLDER "Tests") | ||
add_custom_target(SYCLUnitTests) | ||
set_target_properties(SYCLUnitTests PROPERTIES FOLDER "SYCL tests") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aligns testing and unittests with other LLVM projects CMake usage, e.g., Clang There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other LLVM projects I checked do not comment on where they copied and adapted from other LLVM projects though it is clear that they are aligned. |
||
|
||
function(add_llvm_unittest test_dirname) | ||
add_unittest(PiUnitTests ${test_dirname} ${ARGN}) | ||
endfunction() | ||
# add_sycl_unittest(test_dirname file1.cpp, file2.cpp ...) | ||
# | ||
# Will compile the list of files together and link against SYCL. | ||
# Produces a binary names `basename(test_dirname)`. | ||
function(add_sycl_unittest test_dirname) | ||
# Enable exception handling for these unit tests | ||
set(LLVM_REQUIRES_EH 1) | ||
|
||
function(add_llvm_unittest_with_input_files test_dirname) | ||
add_unittest_with_input_files(PiUnitTests ${test_dirname} ${ARGN}) | ||
add_unittest(SYCLUnitTests ${test_dirname} ${ARGN}) | ||
target_link_libraries(${test_dirname} | ||
PRIVATE | ||
sycl | ||
LLVMTestingSupport | ||
OpenCL-Headers | ||
) | ||
target_include_directories(${test_dirname} PRIVATE SYSTEM ${sycl_inc_dir}) | ||
# LLVM gtest uses LLVM utilities that require C++-14 | ||
# CXX_STANDARD_REQUIRED makes CXX_STANDARD a hard requirement. | ||
set_target_properties(${test_dirname} | ||
PROPERTIES | ||
CXX_STANDARD 14 | ||
CXX_STANDARD_REQUIRED ON | ||
) | ||
endfunction() | ||
|
||
add_subdirectory(pi) | ||
add_subdirectory(pi) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
# Enable exception handling for these unit tests | ||
set(LLVM_REQUIRES_EH 1) | ||
add_llvm_unittest(PiTests | ||
add_sycl_unittest(PiTests | ||
PlatformTest.cpp | ||
) | ||
|
||
add_dependencies(PiTests sycl) | ||
target_link_libraries(PiTests PRIVATE sycl LLVMTestingSupport) | ||
) | ||
AlexeySachkov marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.