From ae3274ede646f036dc5144bd2dadd84729b97d05 Mon Sep 17 00:00:00 2001 From: Fabian Knorr Date: Sat, 17 Feb 2024 18:49:48 +0100 Subject: [PATCH] Add support for SimSYCL as a SYCL implementation --- CMakeLists.txt | 7 ++++- ci/generate_exclude_filter.py | 2 +- ci/simsycl.filter | 20 ++++++++++++ cmake/AdaptSimSYCL.cmake | 45 +++++++++++++++++++++++++++ cmake/AddSYCLExecutable.cmake | 4 +-- tests/common/common.h | 4 +-- tests/common/disabled_for_test_case.h | 2 ++ tests/event/event.cpp | 16 ++++++++++ tests/event/event_semantics.cpp | 4 +++ tests/usm/CMakeLists.txt | 6 ++++ util/sycl_exceptions.h | 9 ++++++ 11 files changed, 113 insertions(+), 6 deletions(-) create mode 100644 ci/simsycl.filter create mode 100644 cmake/AdaptSimSYCL.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index c3161e9c1..65f8370de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,12 @@ cmake_minimum_required(VERSION 3.15) project(sycl_cts LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 17) +if(SYCL_IMPLEMENTATION STREQUAL SimSYCL) + set(CMAKE_CXX_STANDARD 20) +else() + set(CMAKE_CXX_STANDARD 17) +endif() + set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS ON) # Required for hex floats in C++11 mode on gcc 6+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") diff --git a/ci/generate_exclude_filter.py b/ci/generate_exclude_filter.py index 307456926..89c554ec7 100755 --- a/ci/generate_exclude_filter.py +++ b/ci/generate_exclude_filter.py @@ -42,7 +42,7 @@ def parse_arguments(): configuration-time test category filters for all failing targets.""") parser.add_argument('sycl_implementation', metavar="SYCL-Implementation", - choices=['DPCPP', 'hipSYCL'], type=str, + choices=['DPCPP', 'hipSYCL', 'SimSYCL'], type=str, help="The SYCL implementation to use") parser.add_argument('--cmake-args', type=str, help="Arguments to pass on to CMake during configuration") diff --git a/ci/simsycl.filter b/ci/simsycl.filter new file mode 100644 index 000000000..993c71735 --- /dev/null +++ b/ci/simsycl.filter @@ -0,0 +1,20 @@ +accessor_legacy +atomic +atomic_ref_stress +buffer +device +exception_handling +handler +image +image_accessor +invoke +kernel +kernel_args +kernel_bundle +math_builtin_api +multi_ptr +queue +reduction +sampler +spec_constants +stream diff --git a/cmake/AdaptSimSYCL.cmake b/cmake/AdaptSimSYCL.cmake new file mode 100644 index 000000000..388157689 --- /dev/null +++ b/cmake/AdaptSimSYCL.cmake @@ -0,0 +1,45 @@ +add_library(SYCL::SYCL INTERFACE IMPORTED GLOBAL) +target_link_libraries(SYCL::SYCL INTERFACE SimSYCL::simsycl) +# add_sycl_executable_implementation function +# Builds a SYCL program, compiling multiple SYCL test case source files into a +# test executable, invoking a single-source/device compiler +# Parameters are: +# - NAME Name of the test executable +# - OBJECT_LIBRARY Name of the object library of all the compiled test cases +# - TESTS List of SYCL test case source files to be built into the +# test executable +function(add_sycl_executable_implementation) + cmake_parse_arguments(args "" "NAME;OBJECT_LIBRARY" "TESTS" ${ARGN}) + set(exe_name ${args_NAME}) + set(object_lib_name ${args_OBJECT_LIBRARY}) + set(test_cases_list ${args_TESTS}) + + add_library(${object_lib_name} OBJECT ${test_cases_list}) + add_executable(${exe_name} $) + + # hipSYCL needs the macro to be called on both the object library (to + # override the compiler) and the executable (to override the linker). + add_sycl_to_target(TARGET ${object_lib_name} SOURCES ${test_cases_list}) + add_sycl_to_target(TARGET ${exe_name}) + + set_target_properties(${object_lib_name} PROPERTIES + INCLUDE_DIRECTORIES $ + COMPILE_DEFINITIONS $ + COMPILE_OPTIONS $ + COMPILE_FEATURES $ + POSITION_INDEPENDENT_CODE ON) +endfunction() + +function(add_sycl_to_target) + set(options) + set(one_value_keywords TARGET) + set(multi_value_keywords SOURCES) + cmake_parse_arguments(ADD_SYCL + "${options}" + "${one_value_keywords}" + "${multi_value_keywords}" + ${ARGN} + ) + + target_link_libraries(${ADD_SYCL_TARGET} PUBLIC SimSYCL::simsycl) +endfunction() diff --git a/cmake/AddSYCLExecutable.cmake b/cmake/AddSYCLExecutable.cmake index c074a71a2..759be14fd 100644 --- a/cmake/AddSYCLExecutable.cmake +++ b/cmake/AddSYCLExecutable.cmake @@ -1,8 +1,8 @@ -set (KNOWN_SYCL_IMPLEMENTATIONS "Intel_SYCL;DPCPP;hipSYCL") +set (KNOWN_SYCL_IMPLEMENTATIONS "Intel_SYCL;DPCPP;hipSYCL;SimSYCL") if (NOT ${SYCL_IMPLEMENTATION} IN_LIST KNOWN_SYCL_IMPLEMENTATIONS) message(FATAL_ERROR "The SYCL CTS requires specifying a SYCL implementation with " - "-DSYCL_IMPLEMENTATION=[Intel_SYCL,DPCPP;hipSYCL]") + "-DSYCL_IMPLEMENTATION=[Intel_SYCL,DPCPP;hipSYCL;SimSYCL]") endif() if(NOT TARGET OpenCL_Proxy) diff --git a/tests/common/common.h b/tests/common/common.h index 6b00a492f..b91aa830f 100644 --- a/tests/common/common.h +++ b/tests/common/common.h @@ -413,8 +413,8 @@ namespace pixel_tag { struct upper: generic {}; }; -// hipSYCL does not yet support images -#if !SYCL_CTS_COMPILING_WITH_HIPSYCL +// hipSYCL and SimSYCL do not yet support images +#if !SYCL_CTS_COMPILING_WITH_HIPSYCL && !SYCL_CTS_COMPILING_WITH_SIMSYCL /** * @brief Helps with retrieving the right access type for reading/writing diff --git a/tests/common/disabled_for_test_case.h b/tests/common/disabled_for_test_case.h index b48046c20..8774f710d 100644 --- a/tests/common/disabled_for_test_case.h +++ b/tests/common/disabled_for_test_case.h @@ -53,6 +53,8 @@ #define INTERNAL_CTS_SYCL_IMPL_DPCPP () #elif SYCL_CTS_COMPILING_WITH_HIPSYCL #define INTERNAL_CTS_SYCL_IMPL_hipSYCL () +#elif SYCL_CTS_COMPILING_WITH_SIMSYCL +#define INTERNAL_CTS_SYCL_IMPL_SimSYCL () #else #error Unknown SYCL implementation #endif diff --git a/tests/event/event.cpp b/tests/event/event.cpp index 6dcddacc3..d89bc7c82 100644 --- a/tests/event/event.cpp +++ b/tests/event/event.cpp @@ -74,6 +74,10 @@ TEST_CASE("event::get_backend returns the associated backend", "[event]") { TEST_CASE("event::get_wait_list returns a list of all direct dependencies", "[event]") { +#if SYCL_CTS_COMPILING_WITH_SIMSYCL + SKIP("SimSYCL does not implement asynchronous execution."); +#endif + resolvable_host_event e_a; resolvable_host_event e_b{{e_a.get_sycl_event()}}; resolvable_host_event e_c; @@ -117,6 +121,10 @@ class delayed_host_event : public resolvable_host_event { }; TEST_CASE("event can be waited upon", "[event]") { +#if SYCL_CTS_COMPILING_WITH_SIMSYCL + SKIP("SimSYCL does not implement asynchronous execution."); +#endif + // Give main thread some time to fail the did_resolve check delayed_host_event dhe{std::chrono::milliseconds(100)}; @@ -138,6 +146,10 @@ TEST_CASE("event can be waited upon", "[event]") { } TEST_CASE("multiple events can be waited upon simultaneously", "[event]") { +#if SYCL_CTS_COMPILING_WITH_SIMSYCL + SKIP("SimSYCL does not implement asynchronous execution."); +#endif + // Give main thread some time to fail the did_resolve check delayed_host_event dhe1{std::chrono::milliseconds(100)}; delayed_host_event dhe2{std::chrono::milliseconds(100)}; @@ -302,6 +314,10 @@ TEST_CASE("event::get_info returns correct command execution status", sycl::info::event_command_status>(make_device_event()); SECTION("for host_task event") { +#if SYCL_CTS_COMPILING_WITH_SIMSYCL + SKIP("SimSYCL does not implement asynchronous execution."); +#endif + resolvable_host_event rhe; auto& event = rhe.get_sycl_event(); diff --git a/tests/event/event_semantics.cpp b/tests/event/event_semantics.cpp index faf550bbe..474f68d60 100644 --- a/tests/event/event_semantics.cpp +++ b/tests/event/event_semantics.cpp @@ -43,6 +43,10 @@ TEST_CASE("event common reference semantics", "[event]") { } TEST_CASE("event common reference semantics, mutation", "[event]") { +#if SYCL_CTS_COMPILING_WITH_SIMSYCL + SKIP("SimSYCL does not implement asynchronous execution."); +#endif + resolvable_host_event dependent_event; resolvable_host_event rhe_t0{{dependent_event.get_sycl_event()}}; diff --git a/tests/usm/CMakeLists.txt b/tests/usm/CMakeLists.txt index 82f462065..2ca732b56 100644 --- a/tests/usm/CMakeLists.txt +++ b/tests/usm/CMakeLists.txt @@ -1,3 +1,9 @@ file(GLOB test_cases_list *.cpp) +if(SYCL_IMPLEMENTATION STREQUAL SimSYCL) + message(WARNING "SimSYCL does not provide true concurrency between host and device, disabling USM atomic tests") + list(FILTER test_cases_list EXCLUDE REGEX usm_atomic_access_.*\\.cpp$) +endif() + + add_cts_test(${test_cases_list}) diff --git a/util/sycl_exceptions.h b/util/sycl_exceptions.h index 19d7b9c5a..ac5cd5e4e 100644 --- a/util/sycl_exceptions.h +++ b/util/sycl_exceptions.h @@ -38,6 +38,15 @@ #define SYCL_CTS_SUPPORT_HAS_EXCEPTION_CATEGORY 1 #define SYCL_CTS_SUPPORT_HAS_MAKE_ERROR_CODE 0 +#elif SYCL_CTS_COMPILING_WITH_SIMSYCL +// Feature flags for SimSYCL + +#define SYCL_CTS_SUPPORT_HAS_EXCEPTION_CODE 1 +#define SYCL_CTS_SUPPORT_HAS_EXCEPTION_CATEGORY 1 +#define SYCL_CTS_SUPPORT_HAS_ERRC_FOR 0 +#define SYCL_CTS_SUPPORT_HAS_ERROR_CATEGORY_FOR 0 +#define SYCL_CTS_SUPPORT_HAS_MAKE_ERROR_CODE 1 + #else #define SYCL_CTS_SUPPORT_HAS_EXCEPTION_CODE 1