Skip to content

Commit 937c3f4

Browse files
committed
[SYCL] Simplify secondary queue usage
Following KhronosGroup/SYCL-Docs#811, the SYCL 2020 specification will not mandate the use nor exception checking of secondary queues. This allows us to relax the interfaces taking a secondary queue to fully ignore it. This commit drops the passing of the secondary queue throughout the pipeline. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 781b312 commit 937c3f4

File tree

9 files changed

+33
-330
lines changed

9 files changed

+33
-330
lines changed

sycl/include/sycl/ext/oneapi/experimental/enqueue_functions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ event submit_with_event_impl(queue &Q, PropertiesT Props,
108108
CommandGroupFunc &&CGF,
109109
const sycl::detail::code_location &CodeLoc) {
110110
return Q.submit_with_event<__SYCL_USE_FALLBACK_ASSERT>(
111-
Props, detail::type_erased_cgfo_ty{CGF}, nullptr, CodeLoc);
111+
Props, detail::type_erased_cgfo_ty{CGF}, CodeLoc);
112112
}
113113
} // namespace detail
114114

sycl/include/sycl/handler.hpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@ class __SYCL_EXPORT handler {
434434
handler(std::shared_ptr<detail::queue_impl> Queue, bool CallerNeedsEvent);
435435
#endif
436436

437-
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
438437
/// Constructs SYCL handler from the pre-constructed handler_impl and the
439438
/// associated queue. Inside of Graph implementation, the Queue value is not
440439
/// used, for those cases it can be initialized with an empty shared_ptr.
@@ -443,7 +442,8 @@ class __SYCL_EXPORT handler {
443442
/// \param Queue is a SYCL queue.
444443
handler(detail::handler_impl *HandlerImpl,
445444
const std::shared_ptr<detail::queue_impl> &Queue);
446-
#else
445+
446+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
447447
/// Constructs SYCL handler from the associated queue and the submission's
448448
/// primary and secondary queue.
449449
///
@@ -454,20 +454,16 @@ class __SYCL_EXPORT handler {
454454
/// is null if no secondary queue is associated with the submission.
455455
/// \param CallerNeedsEvent indicates if the event resulting from this handler
456456
/// is needed by the caller.
457-
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
458457
// TODO: This function is not used anymore, remove it in the next
459458
// ABI-breaking window.
460459
handler(std::shared_ptr<detail::queue_impl> Queue,
461460
std::shared_ptr<detail::queue_impl> PrimaryQueue,
462461
std::shared_ptr<detail::queue_impl> SecondaryQueue,
463462
bool CallerNeedsEvent);
464-
#endif
465463
__SYCL_DLL_LOCAL handler(std::shared_ptr<detail::queue_impl> Queue,
466464
detail::queue_impl *SecondaryQueue,
467465
bool CallerNeedsEvent);
468-
#endif
469466

470-
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
471467
/// Constructs SYCL handler from Graph.
472468
///
473469
/// The handler will add the command-group as a node to the graph rather than

sycl/include/sycl/queue.hpp

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ auto get_native(const SyclObjectT &Obj)
6666
namespace detail {
6767
class queue_impl;
6868

69-
inline event submitAssertCapture(queue &, event &, queue *,
69+
inline event submitAssertCapture(queue &, event &,
7070
const detail::code_location &);
7171

7272
// Function to postprocess submitted command
@@ -87,8 +87,10 @@ class __SYCL_EXPORT SubmissionInfo {
8787
sycl::detail::optional<SubmitPostProcessF> &PostProcessorFunc();
8888
const sycl::detail::optional<SubmitPostProcessF> &PostProcessorFunc() const;
8989

90+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
9091
std::shared_ptr<detail::queue_impl> &SecondaryQueue();
9192
const std::shared_ptr<detail::queue_impl> &SecondaryQueue() const;
93+
#endif
9294

9395
ext::oneapi::experimental::event_mode_enum &EventMode();
9496
const ext::oneapi::experimental::event_mode_enum &EventMode() const;
@@ -438,17 +440,16 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
438440
/// for execution on a secondary queue.
439441
///
440442
/// \param CGF is a function object containing command group.
441-
/// \param SecondaryQueue is a fallback SYCL queue.
442443
/// \param CodeLoc is the code location of the submit call (default argument)
443444
/// \return a SYCL event object, which corresponds to the queue the command
444445
/// group is being enqueued on.
445446
template <typename T>
446447
std::enable_if_t<std::is_invocable_r_v<void, T, handler &>, event> submit(
447-
T CGF, queue &SecondaryQueue,
448+
T CGF, queue &,
448449
const detail::code_location &CodeLoc = detail::code_location::current()) {
449450
return submit_with_event<__SYCL_USE_FALLBACK_ASSERT>(
450451
sycl::ext::oneapi::experimental::empty_properties_t{},
451-
detail::type_erased_cgfo_ty{CGF}, &SecondaryQueue, CodeLoc);
452+
detail::type_erased_cgfo_ty{CGF}, CodeLoc);
452453
}
453454

454455
/// Prevents any commands submitted afterward to this queue from executing
@@ -3582,7 +3583,7 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
35823583
-> backend_return_t<BackendName, SyclObjectT>;
35833584

35843585
#if __SYCL_USE_FALLBACK_ASSERT
3585-
friend event detail::submitAssertCapture(queue &, event &, queue *,
3586+
friend event detail::submitAssertCapture(queue &, event &,
35863587
const detail::code_location &);
35873588
#endif
35883589

@@ -3675,46 +3676,6 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
36753676
const detail::code_location &CodeLoc,
36763677
bool IsTopCodeLoc);
36773678

3678-
/// Submits a command group function object to the queue, in order to be
3679-
/// scheduled for execution on the device.
3680-
///
3681-
/// \param Props is a property list with submission properties.
3682-
/// \param CGF is a function object containing command group.
3683-
/// \param SecondaryQueuePtr is a pointer to the secondary queue.
3684-
/// \param CodeLoc is the code location of the submit call (default argument)
3685-
/// \return a SYCL event object for the submitted command group.
3686-
//
3687-
// UseFallBackAssert as template param vs `#if` in function body is necessary
3688-
// to prevent ODR-violation between TUs built with different fallback assert
3689-
// modes.
3690-
template <bool UseFallbackAssert, typename PropertiesT>
3691-
event submit_with_event(
3692-
PropertiesT Props, const detail::type_erased_cgfo_ty &CGF,
3693-
queue *SecondaryQueuePtr,
3694-
const detail::code_location &CodeLoc = detail::code_location::current()) {
3695-
detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
3696-
detail::v1::SubmissionInfo SI{};
3697-
ProcessSubmitProperties(Props, SI);
3698-
if (SecondaryQueuePtr)
3699-
SI.SecondaryQueue() = detail::getSyclObjImpl(*SecondaryQueuePtr);
3700-
if constexpr (UseFallbackAssert)
3701-
SI.PostProcessorFunc() =
3702-
[this, &SecondaryQueuePtr,
3703-
&TlsCodeLocCapture](bool IsKernel, bool KernelUsesAssert, event &E) {
3704-
if (IsKernel && !device_has(aspect::ext_oneapi_native_assert) &&
3705-
KernelUsesAssert && !device_has(aspect::accelerator)) {
3706-
// __devicelib_assert_fail isn't supported by Device-side Runtime
3707-
// Linking against fallback impl of __devicelib_assert_fail is
3708-
// performed by program manager class
3709-
// Fallback assert isn't supported for FPGA
3710-
submitAssertCapture(*this, E, SecondaryQueuePtr,
3711-
TlsCodeLocCapture.query());
3712-
}
3713-
};
3714-
return submit_with_event_impl(CGF, SI, TlsCodeLocCapture.query(),
3715-
TlsCodeLocCapture.isToplevel());
3716-
}
3717-
37183679
/// Submits a command group function object to the queue, in order to be
37193680
/// scheduled for execution on the device.
37203681
///
@@ -3743,7 +3704,7 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
37433704
// Linking against fallback impl of __devicelib_assert_fail is
37443705
// performed by program manager class
37453706
// Fallback assert isn't supported for FPGA
3746-
submitAssertCapture(*this, E, nullptr, TlsCodeLocCapture.query());
3707+
submitAssertCapture(*this, E, TlsCodeLocCapture.query());
37473708
}
37483709
};
37493710
return submit_with_event_impl(CGF, SI, TlsCodeLocCapture.query(),
@@ -3942,14 +3903,13 @@ class AssertInfoCopier;
39423903
* Submit copy task for assert failure flag and host-task to check the flag
39433904
* \param Event kernel's event to depend on i.e. the event represents the
39443905
* kernel to check for assertion failure
3945-
* \param SecondaryQueue secondary queue for submit process, null if not used
39463906
* \returns host tasks event
39473907
*
39483908
* This method doesn't belong to queue class to overcome msvc behaviour due to
39493909
* which it gets compiled and exported without any integration header and, thus,
39503910
* with no proper KernelInfo instance.
39513911
*/
3952-
event submitAssertCapture(queue &Self, event &Event, queue *SecondaryQueue,
3912+
event submitAssertCapture(queue &Self, event &Event,
39533913
const detail::code_location &CodeLoc) {
39543914
buffer<detail::AssertHappened, 1> Buffer{1};
39553915

@@ -4005,10 +3965,10 @@ event submitAssertCapture(queue &Self, event &Event, queue *SecondaryQueue,
40053965

40063966
CopierEv = Self.submit_with_event<true>(
40073967
sycl::ext::oneapi::experimental::empty_properties_t{}, CopierCGF,
4008-
SecondaryQueue, CodeLoc);
3968+
CodeLoc);
40093969
CheckerEv = Self.submit_with_event<true>(
40103970
sycl::ext::oneapi::experimental::empty_properties_t{}, CheckerCGF,
4011-
SecondaryQueue, CodeLoc);
3971+
CodeLoc);
40123972

40133973
return CheckerEv;
40143974
}

sycl/source/detail/handler_impl.hpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ enum class HandlerSubmissionState : std::uint8_t {
3131

3232
class handler_impl {
3333
public:
34-
handler_impl(queue_impl *SubmissionSecondaryQueue, bool EventNeeded)
35-
: MSubmissionSecondaryQueue(SubmissionSecondaryQueue),
36-
MEventNeeded(EventNeeded) {};
34+
handler_impl(bool EventNeeded) : MEventNeeded(EventNeeded) {};
3735

3836
handler_impl(
3937
std::shared_ptr<ext::oneapi::experimental::detail::graph_impl> Graph)
@@ -67,10 +65,6 @@ class handler_impl {
6765
/// Registers mutually exclusive submission states.
6866
HandlerSubmissionState MSubmissionState = HandlerSubmissionState::NO_STATE;
6967

70-
/// Pointer to the secondary queue implementation. Nullptr if no
71-
/// secondary queue fallback was given in the associated submission.
72-
queue_impl *MSubmissionSecondaryQueue = nullptr;
73-
7468
/// Bool stores information about whether the event resulting from the
7569
/// corresponding work is required.
7670
bool MEventNeeded = true;

sycl/source/detail/queue_impl.cpp

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,16 @@ void queue_impl::addEvent(const event &Event) {
315315

316316
event queue_impl::submit_impl(const detail::type_erased_cgfo_ty &CGF,
317317
const std::shared_ptr<queue_impl> &Self,
318-
queue_impl *SecondaryQueue, bool CallerNeedsEvent,
318+
bool CallerNeedsEvent,
319319
const detail::code_location &Loc,
320320
bool IsTopCodeLoc,
321321
const v1::SubmissionInfo &SubmitInfo) {
322322
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
323-
detail::handler_impl HandlerImplVal(SecondaryQueue, CallerNeedsEvent);
323+
detail::handler_impl HandlerImplVal(CallerNeedsEvent);
324324
detail::handler_impl *HandlerImpl = &HandlerImplVal;
325325
handler Handler(HandlerImpl, Self);
326326
#else
327-
handler Handler(Self, SecondaryQueue, CallerNeedsEvent);
327+
handler Handler(Self, CallerNeedsEvent);
328328
auto &HandlerImpl = detail::getSyclObjImpl(Handler);
329329
#endif
330330

@@ -402,30 +402,15 @@ event queue_impl::submit_impl(const detail::type_erased_cgfo_ty &CGF,
402402
Stream->generateFlushCommand(ServiceCGH);
403403
};
404404
detail::type_erased_cgfo_ty CGF{L};
405-
event FlushEvent =
406-
submit_impl(CGF, Self, SecondaryQueue, /*CallerNeedsEvent*/ true, Loc,
407-
IsTopCodeLoc, {});
405+
event FlushEvent = submit_impl(CGF, Self, /*CallerNeedsEvent*/ true, Loc,
406+
IsTopCodeLoc, {});
408407
EventImpl->attachEventToCompleteWeak(detail::getSyclObjImpl(FlushEvent));
409408
registerStreamServiceEvent(detail::getSyclObjImpl(FlushEvent));
410409
}
411410

412411
return Event;
413412
}
414413

415-
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
416-
event queue_impl::submit_impl(const detail::type_erased_cgfo_ty &CGF,
417-
const std::shared_ptr<queue_impl> &Self,
418-
const std::shared_ptr<queue_impl> &,
419-
const std::shared_ptr<queue_impl> &SecondaryQueue,
420-
bool CallerNeedsEvent,
421-
const detail::code_location &Loc,
422-
bool IsTopCodeLoc,
423-
const SubmissionInfo &SubmitInfo) {
424-
return submit_impl(CGF, Self, SecondaryQueue.get(), CallerNeedsEvent, Loc,
425-
IsTopCodeLoc, SubmitInfo);
426-
}
427-
#endif
428-
429414
template <typename HandlerFuncT>
430415
event queue_impl::submitWithHandler(const std::shared_ptr<queue_impl> &Self,
431416
const std::vector<event> &DepEvents,

sycl/source/detail/queue_impl.hpp

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -319,19 +319,16 @@ class queue_impl {
319319
///
320320
/// \param CGF is a function object containing command group.
321321
/// \param Self is a shared_ptr to this queue.
322-
/// \param SecondQueue is a shared_ptr to the secondary queue.
323322
/// \param Loc is the code location of the submit call (default argument)
324323
/// \param StoreAdditionalInfo makes additional info be stored in event_impl
325324
/// \return a SYCL event object, which corresponds to the queue the command
326325
/// group is being enqueued on.
327326
event submit(const detail::type_erased_cgfo_ty &CGF,
328327
const std::shared_ptr<queue_impl> &Self,
329-
const std::shared_ptr<queue_impl> &SecondQueue,
330328
const detail::code_location &Loc, bool IsTopCodeLoc,
331329
const SubmitPostProcessF *PostProcess = nullptr) {
332330
event ResEvent;
333331
v1::SubmissionInfo SI{};
334-
SI.SecondaryQueue() = SecondQueue;
335332
if (PostProcess)
336333
SI.PostProcessorFunc() = *PostProcess;
337334
return submit_with_event(CGF, Self, SI, Loc, IsTopCodeLoc);
@@ -350,20 +347,17 @@ class queue_impl {
350347
const std::shared_ptr<queue_impl> &Self,
351348
const v1::SubmissionInfo &SubmitInfo,
352349
const detail::code_location &Loc, bool IsTopCodeLoc) {
353-
354-
event ResEvent =
355-
submit_impl(CGF, Self, SubmitInfo.SecondaryQueue().get(),
356-
/*CallerNeedsEvent=*/true, Loc, IsTopCodeLoc, SubmitInfo);
357-
return ResEvent;
350+
return submit_impl(CGF, Self, /*CallerNeedsEvent=*/true, Loc, IsTopCodeLoc,
351+
SubmitInfo);
358352
}
359353

360354
void submit_without_event(const detail::type_erased_cgfo_ty &CGF,
361355
const std::shared_ptr<queue_impl> &Self,
362356
const v1::SubmissionInfo &SubmitInfo,
363357
const detail::code_location &Loc,
364358
bool IsTopCodeLoc) {
365-
submit_impl(CGF, Self, SubmitInfo.SecondaryQueue().get(),
366-
/*CallerNeedsEvent=*/false, Loc, IsTopCodeLoc, SubmitInfo);
359+
submit_impl(CGF, Self, /*CallerNeedsEvent=*/false, Loc, IsTopCodeLoc,
360+
SubmitInfo);
367361
}
368362

369363
/// Performs a blocking wait for the completion of all enqueued tasks in the
@@ -879,43 +873,19 @@ class queue_impl {
879873
PostProcess(IsKernel, KernelUsesAssert, Event);
880874
}
881875

882-
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
883876
/// Performs command group submission to the queue.
884877
///
885878
/// \param CGF is a function object containing command group.
886879
/// \param Self is a pointer to this queue.
887-
/// \param PrimaryQueue is a pointer to the primary queue. This may be the
888-
/// same as Self.
889-
/// \param SecondaryQueue is a pointer to the secondary queue. This may be the
890-
/// same as Self.
891880
/// \param CallerNeedsEvent is a boolean indicating whether the event is
892881
/// required by the user after the call.
893882
/// \param Loc is the code location of the submit call (default argument)
894883
/// \param SubmitInfo is additional optional information for the submission.
895884
/// \return a SYCL event representing submitted command group.
896885
event submit_impl(const detail::type_erased_cgfo_ty &CGF,
897886
const std::shared_ptr<queue_impl> &Self,
898-
const std::shared_ptr<queue_impl> &PrimaryQueue,
899-
const std::shared_ptr<queue_impl> &SecondaryQueue,
900887
bool CallerNeedsEvent, const detail::code_location &Loc,
901-
bool IsTopCodeLoc, const SubmissionInfo &SubmitInfo);
902-
#endif
903-
904-
/// Performs command group submission to the queue.
905-
///
906-
/// \param CGF is a function object containing command group.
907-
/// \param Self is a pointer to this queue.
908-
/// \param SecondaryQueue is a pointer to the secondary queue.
909-
/// \param CallerNeedsEvent is a boolean indicating whether the event is
910-
/// required by the user after the call.
911-
/// \param Loc is the code location of the submit call (default argument)
912-
/// \param SubmitInfo is additional optional information for the submission.
913-
/// \return a SYCL event representing submitted command group.
914-
event submit_impl(const detail::type_erased_cgfo_ty &CGF,
915-
const std::shared_ptr<queue_impl> &Self,
916-
queue_impl *SecondaryQueue, bool CallerNeedsEvent,
917-
const detail::code_location &Loc, bool IsTopCodeLoc,
918-
const v1::SubmissionInfo &SubmitInfo);
888+
bool IsTopCodeLoc, const v1::SubmissionInfo &SubmitInfo);
919889

920890
/// Helper function for submitting a memory operation with a handler.
921891
/// \param Self is a shared_ptr to this queue.

sycl/source/detail/scheduler/scheduler.hpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -591,14 +591,6 @@ class Scheduler {
591591

592592
void cleanupCommand(Command *Cmd, bool AllowUnsubmitted = false);
593593

594-
/// Reschedules the command passed using Queue provided.
595-
///
596-
/// This can lead to rescheduling of all dependent commands. This can be
597-
/// used when the user provides a "secondary" queue to the submit method
598-
/// which may be used when the command fails to enqueue/execute in the
599-
/// primary queue.
600-
void rescheduleCommand(Command *Cmd, const QueueImplPtr &Queue);
601-
602594
/// \return a pointer to the corresponding memory object record for the
603595
/// SYCL memory object provided, or nullptr if it does not exist.
604596
MemObjRecord *getMemObjRecord(SYCLMemObjI *MemObject);

0 commit comments

Comments
 (0)