-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement tests for SYCL_KHR_DEFAULT_CONTEXT
extension
#960
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8866c74
Implement tests for `sycl_ext_oneapi_default_context` extension
0x12CC 313a284
Change tests to test KHR extension
0x12CC cfbd17a
Run clang-format
0x12CC 7325477
Remove EXT prefix and fix test tag
0x12CC cffbf6e
Remove EXT prefix
0x12CC 8f39ce4
Remove `SKIP` macro
0x12CC 0f660ea
Merge branch 'main' into default_context_tests
bader 16a3bcb
Merge branch 'main' into default_context_tests
bader File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: This could be pulled out into it's own test case IMO. |
||
|
||
// 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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good solution!