@@ -117,11 +117,11 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
117
117
// / constructed.
118
118
// / \param AsyncHandler is a SYCL asynchronous exception handler.
119
119
// / \param PropList is a list of properties to use for queue construction.
120
- queue_impl (device_impl &Device, const ContextImplPtr &Context,
120
+ queue_impl (device_impl &Device, std::shared_ptr<context_impl> & &Context,
121
121
const async_handler &AsyncHandler, const property_list &PropList,
122
122
private_tag)
123
- : MDevice(Device), MContext(Context), MAsyncHandler(AsyncHandler ),
124
- MPropList (PropList),
123
+ : MDevice(Device), MContext(std::move( Context)),
124
+ MAsyncHandler (AsyncHandler), MPropList(PropList),
125
125
MIsInorder(has_property<property::queue::in_order>()),
126
126
MIsProfilingEnabled(has_property<property::queue::enable_profiling>()),
127
127
MQueueID{
@@ -146,8 +146,8 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
146
146
" Queue compute index must be a non-negative number less than "
147
147
" device's number of available compute queue indices." );
148
148
}
149
- if (!Context ->isDeviceValid (Device)) {
150
- if (Context ->getBackend () == backend::opencl)
149
+ if (!MContext ->isDeviceValid (Device)) {
150
+ if (MContext ->getBackend () == backend::opencl)
151
151
throw sycl::exception (
152
152
make_error_code (errc::invalid),
153
153
" 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> {
177
177
trySwitchingToNoEventsMode ();
178
178
}
179
179
180
- sycl::detail::optional<event> getLastEvent ();
180
+ queue_impl (device_impl &Device, context_impl &Context,
181
+ const async_handler &AsyncHandler, const property_list &PropList,
182
+ private_tag Tag)
183
+ : queue_impl(Device, Context.shared_from_this(), AsyncHandler, PropList,
184
+ Tag) {}
181
185
182
- // / Constructs a SYCL queue from adapter interoperability handle.
183
- // /
184
- // / \param UrQueue is a raw UR queue handle.
185
- // / \param Context is a SYCL context to associate with the queue being
186
- // / constructed.
187
- // / \param AsyncHandler is a SYCL asynchronous exception handler.
188
- queue_impl (ur_queue_handle_t UrQueue, const ContextImplPtr &Context,
189
- const async_handler &AsyncHandler, private_tag tag)
190
- : queue_impl(UrQueue, Context, AsyncHandler, {}, tag) {}
186
+ sycl::detail::optional<event> getLastEvent ();
191
187
192
188
// / Constructs a SYCL queue from adapter interoperability handle.
193
189
// /
@@ -196,27 +192,28 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
196
192
// / constructed.
197
193
// / \param AsyncHandler is a SYCL asynchronous exception handler.
198
194
// / \param PropList is the queue properties.
199
- queue_impl (ur_queue_handle_t UrQueue, const ContextImplPtr &Context,
195
+ queue_impl (ur_queue_handle_t UrQueue, context_impl &Context,
200
196
const async_handler &AsyncHandler, const property_list &PropList,
201
197
private_tag)
202
198
: MDevice([&]() -> device_impl & {
203
199
ur_device_handle_t DeviceUr{};
204
- const AdapterPtr &Adapter = Context-> getAdapter ();
200
+ const AdapterPtr &Adapter = Context. getAdapter ();
205
201
// TODO catch an exception and put it to list of asynchronous
206
202
// exceptions
207
203
Adapter->call <UrApiKind::urQueueGetInfo>(
208
204
UrQueue, UR_QUEUE_INFO_DEVICE, sizeof (DeviceUr), &DeviceUr,
209
205
nullptr );
210
- device_impl *Device = Context-> findMatchingDeviceImpl (DeviceUr);
206
+ device_impl *Device = Context. findMatchingDeviceImpl (DeviceUr);
211
207
if (Device == nullptr ) {
212
208
throw sycl::exception (
213
209
make_error_code (errc::invalid),
214
210
" Device provided by native Queue not found in Context." );
215
211
}
216
212
return *Device;
217
213
}()),
218
- MContext (Context), MAsyncHandler(AsyncHandler), MPropList(PropList),
219
- MQueue (UrQueue), MIsInorder(has_property<property::queue::in_order>()),
214
+ MContext (Context.shared_from_this()), MAsyncHandler(AsyncHandler),
215
+ MPropList (PropList), MQueue(UrQueue),
216
+ MIsInorder (has_property<property::queue::in_order>()),
220
217
MIsProfilingEnabled (has_property<property::queue::enable_profiling>()),
221
218
MQueueID{
222
219
MNextAvailableQueueID.fetch_add (1 , std::memory_order_relaxed)} {
@@ -988,7 +985,7 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
988
985
mutable std::mutex MMutex;
989
986
990
987
device_impl &MDevice;
991
- const ContextImplPtr MContext;
988
+ const std::shared_ptr<context_impl> MContext;
992
989
993
990
// / These events are tracked, but not owned, by the queue.
994
991
std::vector<std::weak_ptr<event_impl>> MEventsWeak;
0 commit comments