Skip to content

Commit

Permalink
Add support for SimSYCL as a SYCL implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
fknorr committed Dec 17, 2024
1 parent 321b3d4 commit 7d5f825
Show file tree
Hide file tree
Showing 19 changed files with 157 additions and 20 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
2 changes: 1 addition & 1 deletion ci/generate_exclude_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', 'AdaptiveCpp'], type=str,
choices=['DPCPP', 'AdaptiveCpp', '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")
Expand Down
15 changes: 15 additions & 0 deletions ci/simsycl.filter
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
accessor_legacy
atomic
atomic_ref_stress
exception_handling
image
image_accessor
kernel
kernel_args
kernel_bundle
math_builtin_api
multi_ptr
reduction
sampler
spec_constants
stream
45 changes: 45 additions & 0 deletions cmake/AdaptSimSYCL.cmake
Original file line number Diff line number Diff line change
@@ -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} $<TARGET_OBJECTS:${object_lib_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 $<TARGET_PROPERTY:${exe_name},INCLUDE_DIRECTORIES>
COMPILE_DEFINITIONS $<TARGET_PROPERTY:${exe_name},COMPILE_DEFINITIONS>
COMPILE_OPTIONS $<TARGET_PROPERTY:${exe_name},COMPILE_OPTIONS>
COMPILE_FEATURES $<TARGET_PROPERTY:${exe_name},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()
4 changes: 2 additions & 2 deletions cmake/AddSYCLExecutable.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
set (KNOWN_SYCL_IMPLEMENTATIONS "DPCPP;AdaptiveCpp")
set (KNOWN_SYCL_IMPLEMENTATIONS "DPCPP;AdaptiveCpp;SimSYCL")
if ("${SYCL_IMPLEMENTATION}" STREQUAL "" OR NOT ${SYCL_IMPLEMENTATION} IN_LIST KNOWN_SYCL_IMPLEMENTATIONS)
message(FATAL_ERROR
"The SYCL CTS requires specifying a SYCL implementation with "
"-DSYCL_IMPLEMENTATION=[DPCPP;AdaptiveCpp]")
"-DSYCL_IMPLEMENTATION=[${KNOWN_SYCL_IMPLEMENTATIONS}]")
endif()

if(NOT TARGET OpenCL_Proxy)
Expand Down
8 changes: 8 additions & 0 deletions tests/buffer/buffer_api_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ void test_buffer(util::logger& log, sycl::range<dims>& r, sycl::id<dims>& i) {
allocator.deallocate(ptr, 1);
}

#if !SYCL_CTS_COMPILING_WITH_SIMSYCL
/* check is_sub_buffer() */
{
sycl::buffer<T, dims> buf(r);
Expand All @@ -405,6 +406,9 @@ void test_buffer(util::logger& log, sycl::range<dims>& r, sycl::id<dims>& i) {
CHECK(isSubBuffer);
CHECK_FALSE(isOrigSubBuffer);
}
#else
FAIL_CHECK("SimSYCL does not implement sub-buffers yet");
#endif

/* check buffer properties */
{
Expand Down Expand Up @@ -540,10 +544,14 @@ class check_buffer_api_for_type {
test_buffer<T, size * size, 2, alloc>(log, range2d, id2d);
test_buffer<T, size * size * size, 3, alloc>(log, range3d, id3d);

#if !SYCL_CTS_COMPILING_WITH_SIMSYCL
/* check reinterpret() */
test_type_reinterpret<T, 1>(log);
test_type_reinterpret<T, 2>(log);
test_type_reinterpret<T, 3>(log);
#else
FAIL("SimSYCL does not implement buffer::reinterpret() yet")
#endif
}

public:
Expand Down
9 changes: 9 additions & 0 deletions tests/buffer/buffer_constructors_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ class buffer_ctors {
CHECK(check_buffer_constructor(buf_iter1, r_exp, data_verify));
}

#if !SYCL_CTS_COMPILING_WITH_SIMSYCL
{
INFO("Check subBuffer (buffer, id, range) constructor");
auto r_sub = r;
Expand All @@ -244,6 +245,10 @@ class buffer_ctors {
CHECK(buf_sub.is_sub_buffer());
CHECK(check_buffer_constructor(buf_sub, r_sub));
}
#else
FAIL_CHECK("SimSYCL does not implement sub-buffers yet");
#endif

/* Check range constructor */
{
sycl::buffer<T, dims, std::allocator<T>> buf(r, propList);
Expand Down Expand Up @@ -312,6 +317,7 @@ class buffer_ctors {
CHECK(check_buffer_constructor(buf_iter1, r_exp, data_verify));
}

#if !SYCL_CTS_COMPILING_WITH_SIMSYCL
{
INFO(
"Check subBuffer (buffer, id, range) constructor with allocator "
Expand All @@ -323,6 +329,9 @@ class buffer_ctors {
CHECK(buf_sub.is_sub_buffer());
CHECK(check_buffer_constructor(buf_sub, r_sub));
}
#else
FAIL_CHECK("SimSYCL does not implement sub-buffers yet");
#endif

{
INFO("Check (range, allocator) constructor");
Expand Down
6 changes: 3 additions & 3 deletions tests/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ bool check_equal_values(const T& lhs, const T& rhs) {
}

/**
* @brief Instantiation for vectors with the same API as for scalar values.
* @brief Instantiation for vectors with the same API as for scalar values.
* Deprecated. Use \c value_operations::are_equal instead
*/
template <typename T, int numElements>
Expand Down Expand Up @@ -416,8 +416,8 @@ namespace pixel_tag {
struct upper: generic {};
};

// AdaptiveCpp does not yet support images
#if !SYCL_CTS_COMPILING_WITH_ADAPTIVECPP
// AdaptiveCpp 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
Expand Down
4 changes: 3 additions & 1 deletion tests/common/disabled_for_test_case.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* currently does not compile for a given implementation, while other test cases
* in the same translation unit would otherwise compile.
*
* The following implementations can be specified: DPCPP, AdaptiveCpp.
* The following implementations can be specified: DPCPP, AdaptiveCpp, SimSYCL.
* A disabled test case will fail automatically at runtime.
*
* Usage example:
Expand Down Expand Up @@ -53,6 +53,8 @@
#define INTERNAL_CTS_SYCL_IMPL_DPCPP ()
#elif SYCL_CTS_COMPILING_WITH_ADAPTIVECPP
#define INTERNAL_CTS_SYCL_IMPL_AdaptiveCpp ()
#elif SYCL_CTS_COMPILING_WITH_SIMSYCL
#define INTERNAL_CTS_SYCL_IMPL_SimSYCL ()
#else
#error Unknown SYCL implementation
#endif
Expand Down
4 changes: 4 additions & 0 deletions tests/device/device_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class TEST_NAME : public util::test_base {
"device::has(sycl::aspect)");
}

#if !SYCL_CTS_COMPILING_WITH_SIMSYCL
/** check
* create_sub_devices<info::partition_property::partition_equally>(size_t)
* member function
Expand Down Expand Up @@ -180,6 +181,9 @@ class TEST_NAME : public util::test_base {
}
}
}
#else
FAIL_CHECK("SimSYCL does not implement sub-devices yet");
#endif

/** check get_devices() static member function
*/
Expand Down
6 changes: 6 additions & 0 deletions tests/device/device_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ TEST_CASE("device info", "[device]") {
check_get_info_param<sycl::info::device::printf_buffer_size, size_t>(dev);
check_get_info_param<sycl::info::device::preferred_interop_user_sync, bool>(
dev);

#if !SYCL_CTS_COMPILING_WITH_SIMSYCL
auto SupportedProperties =
dev.get_info<sycl::info::device::partition_properties>();
if (std::find(SupportedProperties.begin(), SupportedProperties.end(),
Expand All @@ -243,6 +245,10 @@ TEST_CASE("device info", "[device]") {
check_get_info_param<sycl::info::device::parent_device, sycl::device>(
sub_device_partition_equal[0]);
}
#else
FAIL_CHECK("SimSYCL does not implement sub-devices yet");
#endif

check_get_info_param<sycl::info::device::partition_max_sub_devices,
uint32_t>(dev);
check_get_info_param<sycl::info::device::partition_properties,
Expand Down
16 changes: 16 additions & 0 deletions tests/event/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -122,6 +126,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)};

Expand All @@ -143,6 +151,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)};
Expand Down Expand Up @@ -307,6 +319,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();

Expand Down
4 changes: 4 additions & 0 deletions tests/event/event_semantics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()}};

Expand Down
15 changes: 10 additions & 5 deletions tests/handler/handler_copy_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
*******************************************************************************/

#include "../common/disabled_for_test_case.h"
#include "../common/string_makers.h"
#include "../common/type_coverage.h"
#include "catch2/catch_test_macros.hpp"
Expand All @@ -14,7 +15,10 @@
namespace handler_copy_core {
using namespace handler_copy_common;

TEST_CASE("Tests the API for sycl::handler::copy", "[handler]") {
// Disabled: SimSYCL does not implement copies between accessors of different dimensionality
DISABLED_FOR_TEST_CASE(SimSYCL)(
"Tests the API for sycl::handler::copy",
"[handler]")({
auto queue = util::get_cts_object::queue();

log_helper lh;
Expand All @@ -33,12 +37,13 @@ TEST_CASE("Tests the API for sycl::handler::copy", "[handler]") {
test_all_variants<sycl::long8>(lh, queue);
test_all_variants<sycl::float8>(lh, queue);
#endif
}
});

TEST_CASE(
// Disabled: SimSYCL does not implement copies between accessors of different dimensionality
DISABLED_FOR_TEST_CASE(SimSYCL)(
"Check exception on copy(accessor, accessor) in case of invalid "
"destination accessor size",
"[handler]") {
"[handler]")({
auto queue = util::get_cts_object::queue();

const auto types =
Expand Down Expand Up @@ -72,6 +77,6 @@ TEST_CASE(

for_all_combinations<CheckCopyAccToAccException>(types, dims, dims, src_modes,
dst_modes, queue);
}
});

} // namespace handler_copy_core
6 changes: 4 additions & 2 deletions tests/handler/handler_copy_fp64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
*******************************************************************************/

#include "handler_copy_common.h"
#include "../common/disabled_for_test_case.h"

#include "catch2/catch_test_macros.hpp"

namespace handler_copy_fp64 {
using namespace handler_copy_common;

TEST_CASE("Tests the API for sycl::handler::copy for double", "[handler]") {
// Disabled: SimSYCL does not implement copies between accessors of different dimensionality
DISABLED_FOR_TEST_CASE(SimSYCL)("Tests the API for sycl::handler::copy for double", "[handler]")({
auto queue = util::get_cts_object::queue();
if (!queue.get_device().has(sycl::aspect::fp64)) {
WARN(
Expand All @@ -25,6 +27,6 @@ TEST_CASE("Tests the API for sycl::handler::copy for double", "[handler]") {
log_helper lh;
test_all_variants<double>(lh, queue);
test_all_variants<sycl::double16>(lh, queue);
}
});

} // namespace handler_copy_fp64
3 changes: 2 additions & 1 deletion tests/invoke/execution_and_memory_models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ TEST_CASE(
}
}

DISABLED_FOR_TEST_CASE(AdaptiveCpp)
// Disabled: SimSYCL does not implement sub-buffers yet
DISABLED_FOR_TEST_CASE(AdaptiveCpp, SimSYCL)
("Requirements on overlapping sub-buffers", "[invoke]")({
auto device = sycl_cts::util::get_cts_object::device();
auto queue = sycl_cts::util::get_cts_object::queue();
Expand Down
8 changes: 4 additions & 4 deletions tests/invoke/parallel_for_simplifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ DISABLED_FOR_TEST_CASE(AdaptiveCpp)
check<N>(action);
});

// FIXME: re-enable when parallel_for simplifications implemented in AdaptiveCpp
DISABLED_FOR_TEST_CASE(AdaptiveCpp)
// FIXME: re-enable when parallel_for simplifications implemented in AdaptiveCpp / SimSYCL
DISABLED_FOR_TEST_CASE(AdaptiveCpp, SimSYCL)
("Check parallel_for({N1, N2}, some_kernel)",
"[parallel_for_simplifications]")({
constexpr int N1 = 2;
Expand All @@ -95,8 +95,8 @@ DISABLED_FOR_TEST_CASE(AdaptiveCpp)
check<N>(action);
});

// FIXME: re-enable when parallel_for simplifications implemented in AdaptiveCpp
DISABLED_FOR_TEST_CASE(AdaptiveCpp)
// FIXME: re-enable when parallel_for simplifications implemented in AdaptiveCpp / SimSYCL
DISABLED_FOR_TEST_CASE(AdaptiveCpp, SimSYCL)
("Check parallel_for({N1, N2, N3}, some_kernel)",
"[parallel_for_simplifications]")({
constexpr int N1 = 2;
Expand Down
Loading

0 comments on commit 7d5f825

Please sign in to comment.