Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions .github/workflows/sycl-linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ jobs:
# TODO consider moving this to Dockerfile.
export LD_LIBRARY_PATH=/usr/local/cuda/compat/:/usr/local/cuda/lib64:$LD_LIBRARY_PATH
cmake --build $GITHUB_WORKSPACE/build --target check-sycl-unittests
- name: check-sycl-unittests-preview
if: always() && !cancelled() && contains(inputs.changes, 'sycl')
run: |
# TODO consider moving this to Dockerfile.
export LD_LIBRARY_PATH=/usr/local/cuda/compat/:/usr/local/cuda/lib64:$LD_LIBRARY_PATH
cmake --build $GITHUB_WORKSPACE/build --target check-sycl-unittests-preview
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, existing target should just check both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean that check-sycl-unittests should check both preview and non-preview?
OR
Was you comment specific to the CI job, like a single job for both preview and non-preview unittest run?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check-sycl-unittests should check both preview and non-preview.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 22d66d0

- name: check-llvm-spirv
if: always() && !cancelled() && contains(inputs.changes, 'llvm_spirv')
run: |
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/sycl-windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ jobs:
if: always() && !cancelled() && contains(inputs.changes, 'sycl')
run: |
cmake --build build --target check-sycl-unittests
- name: check-sycl-unittests-preview
if: always() && !cancelled() && contains(inputs.changes, 'sycl')
run: |
cmake --build build --target check-sycl-unittests-preview
- name: check-llvm-spirv
if: always() && !cancelled() && contains(inputs.changes, 'llvm_spirv')
run: |
Expand Down
5 changes: 5 additions & 0 deletions sycl/cmake/modules/AddSYCLUnitTest.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
include(AddSYCLUnitTestPreview)

# add_sycl_unittest(test_dirname SHARED|OBJECT file1.cpp, file2.cpp ...)
#
# Will compile the list of files together and link against SYCL.
# Produces a binary names `basename(test_dirname)`.
macro(add_sycl_unittest test_dirname link_variant)

add_sycl_unittest_preview(${test_dirname}_preview ${link_variant} ${ARGN})

# Enable exception handling for these unit tests
set(LLVM_REQUIRES_EH ON)
set(LLVM_REQUIRES_RTTI ON)
Expand Down
128 changes: 128 additions & 0 deletions sycl/cmake/modules/AddSYCLUnitTestPreview.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# add_sycl_unittest(test_dirname SHARED|OBJECT file1.cpp, file2.cpp ...)
#
# Will compile the list of files together and link against SYCL.
# Produces a binary names `basename(test_dirname)`.
macro(add_sycl_unittest_preview test_dirname link_variant)
# Enable exception handling for these unit tests
set(LLVM_REQUIRES_EH ON)
set(LLVM_REQUIRES_RTTI ON)

get_target_property(SYCL_BINARY_DIR sycl-toolchain BINARY_DIR)

string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lower)
if (MSVC AND build_type_lower MATCHES "debug")
set(sycl_obj_target "sycl-previewd_object")
set(sycl_so_target "sycl-previewd")
else()
set(sycl_obj_target "sycl-preview_object")
set(sycl_so_target "sycl-preview")
endif()

if ("${link_variant}" MATCHES "SHARED")
set(SYCL_LINK_LIBS ${sycl_so_target})
add_unittest(SYCLUnitTestsPreview ${test_dirname} ${ARGN})
else()
add_unittest(SYCLUnitTestsPreview ${test_dirname}
$<TARGET_OBJECTS:${sycl_obj_target}> ${ARGN})
target_compile_definitions(${test_dirname}
PRIVATE __SYCL_BUILD_SYCL_DLL)

get_target_property(SYCL_LINK_LIBS ${sycl_so_target} LINK_LIBRARIES)
endif()

if (SYCL_ENABLE_COVERAGE)
target_compile_options(${test_dirname} PUBLIC
-fprofile-instr-generate -fcoverage-mapping
)
target_link_options(${test_dirname} PUBLIC
-fprofile-instr-generate -fcoverage-mapping
)
endif()

target_compile_definitions(${test_dirname}
PRIVATE __INTEL_PREVIEW_BREAKING_CHANGES)

if (SYCL_ENABLE_XPTI_TRACING)
target_compile_definitions(${test_dirname}
PRIVATE XPTI_ENABLE_INSTRUMENTATION XPTI_STATIC_LIBRARY)
endif()

# check-sycl-unittests was using an old sycl library. So, to get
# around this problem, we add the new sycl library to the PATH and
# LD_LIBRARY_PATH on Windows and Linux respectively.
if (WIN32)
add_custom_target(check-sycl-${test_dirname}
${CMAKE_COMMAND} -E env
LLVM_PROFILE_FILE="${SYCL_COVERAGE_PATH}/${test_dirname}.profraw"
SYCL_CONFIG_FILE_NAME=null.cfg
SYCL_DEVICELIB_NO_FALLBACK=1
SYCL_CACHE_DIR="${CMAKE_BINARY_DIR}/sycl_cache"
"PATH=${CMAKE_BINARY_DIR}/bin;$ENV{PATH}"
${CMAKE_CURRENT_BINARY_DIR}/${test_dirname}
DEPENDS
${test_dirname}
)
else()
add_custom_target(check-sycl-${test_dirname}
${CMAKE_COMMAND} -E env
LLVM_PROFILE_FILE="${SYCL_COVERAGE_PATH}/${test_dirname}.profraw"
SYCL_CONFIG_FILE_NAME=null.cfg
SYCL_DEVICELIB_NO_FALLBACK=1
SYCL_CACHE_DIR="${CMAKE_BINARY_DIR}/sycl_cache"
"LD_LIBRARY_PATH=${SYCL_BINARY_DIR}/unittests/lib:${CMAKE_BINARY_DIR}/lib:$ENV{LD_LIBRARY_PATH}"
${CMAKE_CURRENT_BINARY_DIR}/${test_dirname}
DEPENDS
${test_dirname}
)
endif()

add_dependencies(check-sycl-unittests-preview check-sycl-${test_dirname})

if(WIN32)
# Windows doesn't support LD_LIBRARY_PATH, so instead we copy the mock OpenCL binary next to the test and ensure
# that the test itself links to OpenCL (rather than through ur_adapter_opencl.dll)
set(mock_ocl ${CMAKE_CURRENT_BINARY_DIR}/OpenCL.dll)
add_custom_command(TARGET ${test_dirname} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:mockOpenCL> ${mock_ocl}
DEPENDS mockOpenCL
BYPRODUCTS ${mock_ocl}_preview
COMMAND_EXPAND_LISTS
)
endif()

target_link_libraries(${test_dirname}
PRIVATE
mockOpenCL
LLVMTestingSupport
OpenCL-Headers
unified-runtime::mock
${SYCL_LINK_LIBS}
)

add_dependencies(${test_dirname} ur_adapter_mock mockOpenCL)

if(SYCL_ENABLE_EXTENSION_JIT)
target_link_libraries(${test_dirname} PRIVATE sycl-jit)
endif(SYCL_ENABLE_EXTENSION_JIT)

if(WIN32)
target_link_libraries(${test_dirname} PRIVATE UnifiedRuntimeLoader ur_win_proxy_loader)
endif()

target_include_directories(${test_dirname}
PRIVATE SYSTEM
${sycl_inc_dir}
${SYCL_SOURCE_DIR}/source/
${SYCL_SOURCE_DIR}/unittests/
)
if (UNIX)
# These warnings are coming from Google Test code.
target_compile_options(${test_dirname}
PRIVATE
-Wno-unused-parameter
-Wno-inconsistent-missing-override
)
endif()

target_compile_definitions(${test_dirname} PRIVATE SYCL_DISABLE_FSYCL_SYCLHPP_WARNING)
endmacro()
4 changes: 4 additions & 0 deletions sycl/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
add_custom_target(SYCLUnitTests)
set_target_properties(SYCLUnitTests PROPERTIES FOLDER "SYCL tests")

add_custom_target(SYCLUnitTestsPreview)
set_target_properties(SYCLUnitTestsPreview PROPERTIES FOLDER "SYCL tests")

foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
Expand All @@ -27,6 +30,7 @@ include(AddSYCLUnitTest)
add_subdirectory(mock_opencl)

add_custom_target(check-sycl-unittests)
add_custom_target(check-sycl-unittests-preview)

add_subdirectory(ur)
add_subdirectory(allowlist)
Expand Down
4 changes: 4 additions & 0 deletions sycl/unittests/Extensions/LaunchQueries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ auto getKernel(const sycl::queue &Q) {
return KernelBundle.get_kernel(KernelID);
}

// These tests fail in preview breaking mode.
// Failure Tracker: https://github.com/intel/llvm/issues/18910
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
TEST(LaunchQueries, GetWorkGroupSizeSuccess) {
sycl::unittest::UrMock<> Mock;
mock::getCallbacks().set_replace_callback(
Expand Down Expand Up @@ -146,6 +149,7 @@ TEST(LaunchQueries, GetMaxWorkGroupItemSizesExceptionCode) {
syclex::info::kernel_queue_specific::max_work_item_sizes<3>>(Queue),
sycl::exception);
}
#endif // __INTEL_PREVIEW_BREAKING_CHANGES

TEST(LaunchQueries, GetMaxSubGroupSize3DSuccess) {
sycl::unittest::UrMock<> Mock;
Expand Down
4 changes: 4 additions & 0 deletions sycl/unittests/misc/OsUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ bool isSameDir(const char* LHS, const char* RHS) {
class OsUtilsTest : public ::testing::Test {
};

// This test fails with preview breaking changes enabled.
// Failure tracker: https://github.com/intel/llvm/issues/19626
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
TEST_F(OsUtilsTest, getCurrentDSODir) {
std::string DSODir = sycl::detail::OSUtil::getCurrentDSODir();
ASSERT_TRUE(isSameDir(DSODir.c_str(), SYCL_LIB_DIR)) <<
"expected: " << SYCL_LIB_DIR << ", got: " << DSODir;
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ class MockHandler : public sycl::handler {
using sycl::handler::impl;

MockHandler(sycl::detail::queue_impl &Queue)
: sycl::handler(Queue.shared_from_this(), /*CallerNeedsEvent*/ true) {}
: sycl::handler(std::make_unique<sycl::detail::handler_impl>(
Queue, nullptr, /*CallerNeedsEvent*/ true)) {}

std::unique_ptr<sycl::detail::CG> finalize() {
auto CGH = static_cast<sycl::handler *>(this);
Expand Down
2 changes: 1 addition & 1 deletion sycl/unittests/scheduler/InOrderQueueSyncCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class LimitedHandler {

#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
virtual sycl::detail::EventImplPtr finalize() {
return std::make_shared<detail::event_impl>();
return detail::event_impl::create_default_event();
}
#else
virtual event finalize() {
Expand Down
3 changes: 2 additions & 1 deletion sycl/unittests/scheduler/SchedulerTestUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ sycl::detail::Requirement getMockRequirement(const MemObjT &MemObj) {
class MockHandler : public sycl::handler {
public:
MockHandler(sycl::detail::queue_impl &Queue, bool CallerNeedsEvent)
: sycl::handler(Queue.shared_from_this(), CallerNeedsEvent) {}
: sycl::handler(std::make_unique<sycl::detail::handler_impl>(
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The constructor call spans multiple lines but the closing parenthesis and brace are on separate lines. Consider formatting this consistently, either keeping the entire constructor call on one line or aligning the closing elements properly.

Copilot uses AI. Check for mistakes.
Queue, nullptr, CallerNeedsEvent)) {}
// Methods
using sycl::handler::addReduction;
using sycl::handler::getType;
Expand Down
1 change: 1 addition & 0 deletions sycl/unittests/xpti_trace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ add_sycl_unittest(XptiTraceTests OBJECT
QueueIDCheck.cpp
)
target_link_libraries(XptiTraceTests PRIVATE xpti xptitest_subscriber)
target_link_libraries(XptiTraceTests_preview PRIVATE xpti xptitest_subscriber)
Loading