From 8866c74b04abbc2db24a46a78efc992b762632a6 Mon Sep 17 00:00:00 2001 From: Michael Aziz Date: Sun, 6 Oct 2024 19:57:35 -0700 Subject: [PATCH 1/6] Implement tests for `sycl_ext_oneapi_default_context` extension Signed-off-by: Michael Aziz --- CMakeLists.txt | 4 + .../oneapi_default_context/CMakeLists.txt | 5 ++ .../default_context.cpp | 80 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 tests/extension/oneapi_default_context/CMakeLists.txt create mode 100644 tests/extension/oneapi_default_context/default_context.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 971c6c10c..fa62b227b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,6 +103,10 @@ add_cts_option(SYCL_CTS_ENABLE_EXT_ONEAPI_ENQUEUE_FUNCTIONS_TESTS "Enable extension oneAPI enqueue_functions tests" OFF FORCE_ON ${SYCL_CTS_ENABLE_EXT_ONEAPI_TESTS}) +add_cts_option(SYCL_CTS_ENABLE_EXT_ONEAPI_DEFAULT_CONTEXT_TESTS + "Enable extension oneAPI default_context tests" OFF + FORCE_ON ${SYCL_CTS_ENABLE_EXT_ONEAPI_TESTS}) + # TODO: Deprecated - remove add_cts_option(SYCL_CTS_ENABLE_VERBOSE_LOG "Enable debug-level logs (deprecated)" OFF) diff --git a/tests/extension/oneapi_default_context/CMakeLists.txt b/tests/extension/oneapi_default_context/CMakeLists.txt new file mode 100644 index 000000000..ee005a726 --- /dev/null +++ b/tests/extension/oneapi_default_context/CMakeLists.txt @@ -0,0 +1,5 @@ +if(SYCL_CTS_ENABLE_EXT_ONEAPI_DEFAULT_CONTEXT_TESTS) + file(GLOB test_cases_list *.cpp) + + add_cts_test(${test_cases_list}) +endif() diff --git a/tests/extension/oneapi_default_context/default_context.cpp b/tests/extension/oneapi_default_context/default_context.cpp new file mode 100644 index 000000000..7f83f77bb --- /dev/null +++ b/tests/extension/oneapi_default_context/default_context.cpp @@ -0,0 +1,80 @@ +/******************************************************************************* +// +// 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 { + +#ifdef SYCL_EXT_ONEAPI_DEFAULT_CONTEXT + +static void testDefaultContext() { + sycl::platform platform{}; + sycl::context defaultContext = platform.ext_oneapi_get_default_context(); + CHECK(defaultContext.get_devices() == platform.get_devices()); +} + +static void testQueueConstructors() { + 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{}.ext_oneapi_get_default_context(); + + // Check that a default-constructed context is not the default context. + CHECK(syclContext != defaultContext); + + // Default context constructor + 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()); +} + +#endif + +TEST_CASE("Test case for \"Default Context\" extension", + "[oneapi_default_context") { +#ifndef SYCL_EXT_ONEAPI_DEFAULT_CONTEXT + SKIP("SYCL_EXT_ONEAPI_DEFAULT_CONTEXT is not defined"); +#else + testDefaultContext(); + testQueueConstructors(); +#endif +} + +} // namespace default_context::tests From 313a2847efc63246770b80209f2cb7b99bd3cf6e Mon Sep 17 00:00:00 2001 From: Michael Aziz Date: Sat, 12 Oct 2024 14:08:50 -0700 Subject: [PATCH 2/6] Change tests to test KHR extension Signed-off-by: Michael Aziz --- CMakeLists.txt | 9 ++++++--- .../CMakeLists.txt | 2 +- .../default_context.cpp | 14 +++++++------- 3 files changed, 14 insertions(+), 11 deletions(-) rename tests/extension/{oneapi_default_context => khr_default_context}/CMakeLists.txt (61%) rename tests/extension/{oneapi_default_context => khr_default_context}/default_context.cpp (88%) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa62b227b..f8cf5aeaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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_EXT_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}) @@ -103,9 +106,9 @@ add_cts_option(SYCL_CTS_ENABLE_EXT_ONEAPI_ENQUEUE_FUNCTIONS_TESTS "Enable extension oneAPI enqueue_functions tests" OFF FORCE_ON ${SYCL_CTS_ENABLE_EXT_ONEAPI_TESTS}) -add_cts_option(SYCL_CTS_ENABLE_EXT_ONEAPI_DEFAULT_CONTEXT_TESTS - "Enable extension oneAPI default_context tests" OFF - FORCE_ON ${SYCL_CTS_ENABLE_EXT_ONEAPI_TESTS}) +add_cts_option(SYCL_CTS_ENABLE_EXT_KHR_DEFAULT_CONTEXT_TESTS + "Enable extension Khronos default_context tests" OFF + FORCE_ON ${SYCL_CTS_ENABLE_EXT_KHR_TESTS}) # TODO: Deprecated - remove add_cts_option(SYCL_CTS_ENABLE_VERBOSE_LOG diff --git a/tests/extension/oneapi_default_context/CMakeLists.txt b/tests/extension/khr_default_context/CMakeLists.txt similarity index 61% rename from tests/extension/oneapi_default_context/CMakeLists.txt rename to tests/extension/khr_default_context/CMakeLists.txt index ee005a726..abffcf950 100644 --- a/tests/extension/oneapi_default_context/CMakeLists.txt +++ b/tests/extension/khr_default_context/CMakeLists.txt @@ -1,4 +1,4 @@ -if(SYCL_CTS_ENABLE_EXT_ONEAPI_DEFAULT_CONTEXT_TESTS) +if(SYCL_CTS_ENABLE_EXT_KHR_DEFAULT_CONTEXT_TESTS) file(GLOB test_cases_list *.cpp) add_cts_test(${test_cases_list}) diff --git a/tests/extension/oneapi_default_context/default_context.cpp b/tests/extension/khr_default_context/default_context.cpp similarity index 88% rename from tests/extension/oneapi_default_context/default_context.cpp rename to tests/extension/khr_default_context/default_context.cpp index 7f83f77bb..4aabf2973 100644 --- a/tests/extension/oneapi_default_context/default_context.cpp +++ b/tests/extension/khr_default_context/default_context.cpp @@ -22,11 +22,11 @@ namespace default_context::tests { -#ifdef SYCL_EXT_ONEAPI_DEFAULT_CONTEXT +#ifdef SYCL_KHR_DEFAULT_CONTEXT static void testDefaultContext() { sycl::platform platform{}; - sycl::context defaultContext = platform.ext_oneapi_get_default_context(); + sycl::context defaultContext = platform.khr_get_default_context(); CHECK(defaultContext.get_devices() == platform.get_devices()); } @@ -37,12 +37,12 @@ static void testQueueConstructors() { sycl::device syclDevice; sycl::context syclContext; sycl::context defaultContext = - sycl::platform{}.ext_oneapi_get_default_context(); + sycl::platform{}.khr_get_default_context(); // Check that a default-constructed context is not the default context. CHECK(syclContext != defaultContext); - // Default context constructor + // 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()); @@ -68,9 +68,9 @@ static void testQueueConstructors() { #endif TEST_CASE("Test case for \"Default Context\" extension", - "[oneapi_default_context") { -#ifndef SYCL_EXT_ONEAPI_DEFAULT_CONTEXT - SKIP("SYCL_EXT_ONEAPI_DEFAULT_CONTEXT is not defined"); + "[khr_default_context") { +#ifndef SYCL_KHR_DEFAULT_CONTEXT + SKIP("SYCL_KHR_DEFAULT_CONTEXT is not defined"); #else testDefaultContext(); testQueueConstructors(); From cfbd17ac08d0083a627da183434464bb3ee7a00a Mon Sep 17 00:00:00 2001 From: Michael Aziz Date: Sat, 12 Oct 2024 14:12:16 -0700 Subject: [PATCH 3/6] Run clang-format Signed-off-by: Michael Aziz --- tests/extension/khr_default_context/default_context.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/extension/khr_default_context/default_context.cpp b/tests/extension/khr_default_context/default_context.cpp index 4aabf2973..26e1fff3c 100644 --- a/tests/extension/khr_default_context/default_context.cpp +++ b/tests/extension/khr_default_context/default_context.cpp @@ -36,8 +36,7 @@ static void testQueueConstructors() { const auto& deviceSelector = sycl::default_selector_v; sycl::device syclDevice; sycl::context syclContext; - sycl::context defaultContext = - sycl::platform{}.khr_get_default_context(); + sycl::context defaultContext = sycl::platform{}.khr_get_default_context(); // Check that a default-constructed context is not the default context. CHECK(syclContext != defaultContext); From 7325477beb9d722fbb6862022c9ce43e8148d97b Mon Sep 17 00:00:00 2001 From: Michael Aziz Date: Tue, 15 Oct 2024 19:20:05 -0700 Subject: [PATCH 4/6] Remove EXT prefix and fix test tag Signed-off-by: Michael Aziz --- CMakeLists.txt | 6 +++--- tests/extension/khr_default_context/default_context.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8cf5aeaf..8795bd677 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ 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_EXT_KHR_TESTS +add_cts_option(SYCL_CTS_ENABLE_KHR_TESTS "Enable all extension Khronos tests" OFF) add_cts_option(SYCL_CTS_ENABLE_EXT_ONEAPI_PROPERTIES_TESTS @@ -106,9 +106,9 @@ add_cts_option(SYCL_CTS_ENABLE_EXT_ONEAPI_ENQUEUE_FUNCTIONS_TESTS "Enable extension oneAPI enqueue_functions tests" OFF FORCE_ON ${SYCL_CTS_ENABLE_EXT_ONEAPI_TESTS}) -add_cts_option(SYCL_CTS_ENABLE_EXT_KHR_DEFAULT_CONTEXT_TESTS +add_cts_option(SYCL_CTS_ENABLE_KHR_DEFAULT_CONTEXT_TESTS "Enable extension Khronos default_context tests" OFF - FORCE_ON ${SYCL_CTS_ENABLE_EXT_KHR_TESTS}) + FORCE_ON ${SYCL_CTS_ENABLE_KHR_TESTS}) # TODO: Deprecated - remove add_cts_option(SYCL_CTS_ENABLE_VERBOSE_LOG diff --git a/tests/extension/khr_default_context/default_context.cpp b/tests/extension/khr_default_context/default_context.cpp index 26e1fff3c..a3f7ed221 100644 --- a/tests/extension/khr_default_context/default_context.cpp +++ b/tests/extension/khr_default_context/default_context.cpp @@ -67,7 +67,7 @@ static void testQueueConstructors() { #endif TEST_CASE("Test case for \"Default Context\" extension", - "[khr_default_context") { + "[khr_default_context]") { #ifndef SYCL_KHR_DEFAULT_CONTEXT SKIP("SYCL_KHR_DEFAULT_CONTEXT is not defined"); #else From cffbf6e25c0e359741fd068a46918b598d93675a Mon Sep 17 00:00:00 2001 From: Michael Aziz Date: Tue, 15 Oct 2024 19:33:52 -0700 Subject: [PATCH 5/6] Remove EXT prefix Signed-off-by: Michael Aziz --- tests/extension/khr_default_context/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/extension/khr_default_context/CMakeLists.txt b/tests/extension/khr_default_context/CMakeLists.txt index abffcf950..e7d855de5 100644 --- a/tests/extension/khr_default_context/CMakeLists.txt +++ b/tests/extension/khr_default_context/CMakeLists.txt @@ -1,4 +1,4 @@ -if(SYCL_CTS_ENABLE_EXT_KHR_DEFAULT_CONTEXT_TESTS) +if(SYCL_CTS_ENABLE_KHR_DEFAULT_CONTEXT_TESTS) file(GLOB test_cases_list *.cpp) add_cts_test(${test_cases_list}) From 8f39ce41233504c54a05a0752c820597d415866c Mon Sep 17 00:00:00 2001 From: Michael Aziz Date: Thu, 17 Oct 2024 05:03:57 -0700 Subject: [PATCH 6/6] Remove `SKIP` macro Signed-off-by: Michael Aziz --- .../khr_default_context/default_context.cpp | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/tests/extension/khr_default_context/default_context.cpp b/tests/extension/khr_default_context/default_context.cpp index a3f7ed221..137333e1a 100644 --- a/tests/extension/khr_default_context/default_context.cpp +++ b/tests/extension/khr_default_context/default_context.cpp @@ -22,15 +22,23 @@ namespace default_context::tests { -#ifdef SYCL_KHR_DEFAULT_CONTEXT +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 +} -static void testDefaultContext() { +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()); } -static void testQueueConstructors() { +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; @@ -64,16 +72,4 @@ static void testQueueConstructors() { .get_context()); } -#endif - -TEST_CASE("Test case for \"Default Context\" extension", - "[khr_default_context]") { -#ifndef SYCL_KHR_DEFAULT_CONTEXT - SKIP("SYCL_KHR_DEFAULT_CONTEXT is not defined"); -#else - testDefaultContext(); - testQueueConstructors(); -#endif -} - } // namespace default_context::tests