Skip to content

Commit

Permalink
Merge branch 'main' into local_memory_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bader authored Nov 14, 2024
2 parents 82b826b + ead7474 commit 2fcd5f3
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ add_cts_option(SYCL_CTS_ENABLE_DEPRECATED_FEATURES_TESTS
add_cts_option(SYCL_CTS_ENABLE_EXT_ONEAPI_TESTS
"Enable all extension oneAPI tests" OFF)

add_cts_option(SYCL_CTS_ENABLE_KHR_TESTS
"Enable all extension Khronos tests" OFF)

add_cts_option(SYCL_CTS_ENABLE_EXT_ONEAPI_PROPERTIES_TESTS
"Enable extension oneAPI compile-time property list tests" OFF
FORCE_ON ${SYCL_CTS_ENABLE_EXT_ONEAPI_TESTS})
Expand Down Expand Up @@ -107,6 +110,10 @@ add_cts_option(SYCL_CTS_ENABLE_EXT_ONEAPI_LOCAL_MEMORY_TESTS
"Enable extension oneAPI local_memory tests" OFF
FORCE_ON ${SYCL_CTS_ENABLE_EXT_ONEAPI_TESTS})

add_cts_option(SYCL_CTS_ENABLE_KHR_DEFAULT_CONTEXT_TESTS
"Enable extension Khronos default_context tests" OFF
FORCE_ON ${SYCL_CTS_ENABLE_KHR_TESTS})

# TODO: Deprecated - remove
add_cts_option(SYCL_CTS_ENABLE_VERBOSE_LOG
"Enable debug-level logs (deprecated)" OFF)
Expand Down
4 changes: 2 additions & 2 deletions cmake/FindDPCPP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ set_target_properties(DPCPP::Runtime PROPERTIES

set(CMAKE_CXX_COMPILER ${DPCPP_CXX_EXECUTABLE})
# Use DPC++ compiler instead of default linker for building SYCL application
set(CMAKE_CXX_LINK_EXECUTABLE "${DPCPP_CXX_EXECUTABLE} <FLAGS> \
<CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_CXX_LINK_EXECUTABLE "${DPCPP_CXX_EXECUTABLE} <FLAGS> <OBJECTS> -o <TARGET> \
<CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>")

function(add_sycl_to_target)
set(options)
Expand Down
5 changes: 5 additions & 0 deletions tests/extension/khr_default_context/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if(SYCL_CTS_ENABLE_KHR_DEFAULT_CONTEXT_TESTS)
file(GLOB test_cases_list *.cpp)

add_cts_test(${test_cases_list})
endif()
75 changes: 75 additions & 0 deletions tests/extension/khr_default_context/default_context.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*******************************************************************************
//
// SYCL 2020 Conformance Test Suite
//
// Copyright (c) 2024 The Khronos Group Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
*******************************************************************************/

#include "../../common/common.h"

namespace default_context::tests {

TEST_CASE(
"the default context extension defines the SYCL_KHR_DEFAULT_CONTEXT macro",
"[khr_default_context]") {
#ifndef SYCL_KHR_DEFAULT_CONTEXT
static_assert(false, "SYCL_KHR_DEFAULT_CONTEXT is not defined");
#endif
}

TEST_CASE("the default context contains all of the default platform's devices",
"[khr_default_context]") {
sycl::platform platform{};
sycl::context defaultContext = platform.khr_get_default_context();
CHECK(defaultContext.get_devices() == platform.get_devices());
}

TEST_CASE("queue constructors use the default context or the context parameter",
"[khr_default_context]") {
const sycl::property_list& propList = {};
cts_async_handler asyncHandler;
const auto& deviceSelector = sycl::default_selector_v;
sycl::device syclDevice;
sycl::context syclContext;
sycl::context defaultContext = sycl::platform{}.khr_get_default_context();

// Check that a default-constructed context is not the default context.
CHECK(syclContext != defaultContext);

// Default context constructors
CHECK(defaultContext == sycl::queue{propList}.get_context());
CHECK(defaultContext == sycl::queue{asyncHandler, propList}.get_context());
CHECK(defaultContext == sycl::queue{deviceSelector, propList}.get_context());
CHECK(defaultContext ==
sycl::queue{deviceSelector, asyncHandler, propList}.get_context());
CHECK(defaultContext == sycl::queue{syclDevice, propList}.get_context());
CHECK(defaultContext ==
sycl::queue{syclDevice, asyncHandler, propList}.get_context());

// Non-default context constructors
CHECK(syclContext ==
sycl::queue{syclContext, deviceSelector, propList}.get_context());
CHECK(syclContext ==
sycl::queue{syclContext, deviceSelector, asyncHandler, propList}
.get_context());
CHECK(syclContext ==
sycl::queue{syclContext, syclDevice, propList}.get_context());
CHECK(syclContext ==
sycl::queue{syclContext, syclDevice, asyncHandler, propList}
.get_context());
}

} // namespace default_context::tests

0 comments on commit 2fcd5f3

Please sign in to comment.