-
Notifications
You must be signed in to change notification settings - Fork 797
[NFC][SYCL] Raw context_impl
in getInteropContext
and queue_impl
ctor
#19126
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
Merged
aelovikov-intel
merged 1 commit into
intel:sycl
from
aelovikov-intel:context_impl-queue_impl-ctor
Jun 25, 2025
Merged
Changes from all commits
Commits
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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -117,11 +117,11 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> { | |
/// constructed. | ||
/// \param AsyncHandler is a SYCL asynchronous exception handler. | ||
/// \param PropList is a list of properties to use for queue construction. | ||
queue_impl(device_impl &Device, const ContextImplPtr &Context, | ||
queue_impl(device_impl &Device, std::shared_ptr<context_impl> &&Context, | ||
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. Need the rvalue-reference overload for the creation using |
||
const async_handler &AsyncHandler, const property_list &PropList, | ||
private_tag) | ||
: MDevice(Device), MContext(Context), MAsyncHandler(AsyncHandler), | ||
MPropList(PropList), | ||
: MDevice(Device), MContext(std::move(Context)), | ||
MAsyncHandler(AsyncHandler), MPropList(PropList), | ||
MIsInorder(has_property<property::queue::in_order>()), | ||
MIsProfilingEnabled(has_property<property::queue::enable_profiling>()), | ||
MQueueID{ | ||
|
@@ -146,8 +146,8 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> { | |
"Queue compute index must be a non-negative number less than " | ||
"device's number of available compute queue indices."); | ||
} | ||
if (!Context->isDeviceValid(Device)) { | ||
if (Context->getBackend() == backend::opencl) | ||
if (!MContext->isDeviceValid(Device)) { | ||
if (MContext->getBackend() == backend::opencl) | ||
throw sycl::exception( | ||
make_error_code(errc::invalid), | ||
"Queue cannot be constructed with the given context and device " | ||
|
@@ -177,17 +177,13 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> { | |
trySwitchingToNoEventsMode(); | ||
} | ||
|
||
sycl::detail::optional<event> getLastEvent(); | ||
queue_impl(device_impl &Device, context_impl &Context, | ||
const async_handler &AsyncHandler, const property_list &PropList, | ||
private_tag Tag) | ||
: queue_impl(Device, Context.shared_from_this(), AsyncHandler, PropList, | ||
Tag) {} | ||
|
||
/// Constructs a SYCL queue from adapter interoperability handle. | ||
/// | ||
/// \param UrQueue is a raw UR queue handle. | ||
/// \param Context is a SYCL context to associate with the queue being | ||
/// constructed. | ||
/// \param AsyncHandler is a SYCL asynchronous exception handler. | ||
queue_impl(ur_queue_handle_t UrQueue, const ContextImplPtr &Context, | ||
const async_handler &AsyncHandler, private_tag tag) | ||
: queue_impl(UrQueue, Context, AsyncHandler, {}, tag) {} | ||
sycl::detail::optional<event> getLastEvent(); | ||
|
||
/// Constructs a SYCL queue from adapter interoperability handle. | ||
/// | ||
|
@@ -196,27 +192,28 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> { | |
/// constructed. | ||
/// \param AsyncHandler is a SYCL asynchronous exception handler. | ||
/// \param PropList is the queue properties. | ||
queue_impl(ur_queue_handle_t UrQueue, const ContextImplPtr &Context, | ||
queue_impl(ur_queue_handle_t UrQueue, context_impl &Context, | ||
const async_handler &AsyncHandler, const property_list &PropList, | ||
private_tag) | ||
: MDevice([&]() -> device_impl & { | ||
ur_device_handle_t DeviceUr{}; | ||
const AdapterPtr &Adapter = Context->getAdapter(); | ||
const AdapterPtr &Adapter = Context.getAdapter(); | ||
// TODO catch an exception and put it to list of asynchronous | ||
// exceptions | ||
Adapter->call<UrApiKind::urQueueGetInfo>( | ||
UrQueue, UR_QUEUE_INFO_DEVICE, sizeof(DeviceUr), &DeviceUr, | ||
nullptr); | ||
device_impl *Device = Context->findMatchingDeviceImpl(DeviceUr); | ||
device_impl *Device = Context.findMatchingDeviceImpl(DeviceUr); | ||
if (Device == nullptr) { | ||
throw sycl::exception( | ||
make_error_code(errc::invalid), | ||
"Device provided by native Queue not found in Context."); | ||
} | ||
return *Device; | ||
}()), | ||
MContext(Context), MAsyncHandler(AsyncHandler), MPropList(PropList), | ||
MQueue(UrQueue), MIsInorder(has_property<property::queue::in_order>()), | ||
MContext(Context.shared_from_this()), MAsyncHandler(AsyncHandler), | ||
MPropList(PropList), MQueue(UrQueue), | ||
MIsInorder(has_property<property::queue::in_order>()), | ||
MIsProfilingEnabled(has_property<property::queue::enable_profiling>()), | ||
MQueueID{ | ||
MNextAvailableQueueID.fetch_add(1, std::memory_order_relaxed)} { | ||
|
@@ -988,7 +985,7 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> { | |
mutable std::mutex MMutex; | ||
|
||
device_impl &MDevice; | ||
const ContextImplPtr MContext; | ||
const std::shared_ptr<context_impl> MContext; | ||
|
||
/// These events are tracked, but not owned, by the queue. | ||
std::vector<std::weak_ptr<event_impl>> MEventsWeak; | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Changes in this file because of this
queue_impl
creation.