Skip to content

Commit 5b5b222

Browse files
[SYCL][NFCI] Remove unnecessary CG type argument in finalizeHandler (#13864)
The `finalizeHandler` function on queue_impl has a `CGType` argument, but the information in this argument could be queried directly from the handler instead. This commit removes the argument and makes the member function call `handler::getType()` instead. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 0c9a70f commit 5b5b222

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

sycl/source/detail/queue_impl.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,7 @@ class queue_impl {
778778

779779
// template is needed for proper unit testing
780780
template <typename HandlerType = handler>
781-
void finalizeHandler(HandlerType &Handler, const CG::CGTYPE &Type,
782-
event &EventRet) {
781+
void finalizeHandler(HandlerType &Handler, event &EventRet) {
783782
if (MIsInorder) {
784783
// Accessing and changing of an event isn't atomic operation.
785784
// Hence, here is the lock for thread-safety.
@@ -807,6 +806,8 @@ class queue_impl {
807806
EventRet = Handler.finalize();
808807
EventToBuildDeps = getSyclObjImpl(EventRet);
809808
} else {
809+
const CG::CGTYPE Type = Handler.getType();
810+
810811
// The following code supports barrier synchronization if host task is
811812
// involved in the scenario. Native barriers cannot handle host task
812813
// dependency so in the case where some commands were not enqueued
@@ -886,11 +887,11 @@ class queue_impl {
886887
KernelUsesAssert = !(Handler.MKernel && Handler.MKernel->isInterop()) &&
887888
ProgramManager::getInstance().kernelUsesAssert(
888889
Handler.MKernelName.c_str());
889-
finalizeHandler(Handler, Type, Event);
890+
finalizeHandler(Handler, Event);
890891

891892
(*PostProcess)(IsKernel, KernelUsesAssert, Event);
892893
} else
893-
finalizeHandler(Handler, Type, Event);
894+
finalizeHandler(Handler, Event);
894895

895896
addEvent(Event);
896897
return Event;

sycl/unittests/scheduler/InOrderQueueSyncCheck.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ using ::testing::An;
2222
// Define type with the only methods called by finalizeHandler
2323
class LimitedHandler {
2424
public:
25+
LimitedHandler(sycl::detail::CG::CGTYPE CGType) : MCGType(CGType) {}
26+
2527
virtual ~LimitedHandler() {}
2628
virtual void depends_on(const sycl::detail::EventImplPtr &) {}
2729
virtual void depends_on(const std::vector<detail::EventImplPtr> &Events) {}
@@ -32,12 +34,19 @@ class LimitedHandler {
3234
std::make_shared<detail::event_impl>();
3335
return sycl::detail::createSyclObjFromImpl<sycl::event>(NewEvent);
3436
}
37+
38+
sycl::detail::CG::CGTYPE getType() { return MCGType; }
39+
40+
sycl::detail::CG::CGTYPE MCGType;
3541
};
3642

3743
// Needed to use EXPECT_CALL to verify depends_on that originally appends lst
3844
// event as dependency to the new CG
3945
class LimitedHandlerSimulation : public LimitedHandler {
4046
public:
47+
LimitedHandlerSimulation(sycl::detail::CG::CGTYPE CGType)
48+
: LimitedHandler(CGType) {}
49+
4150
MOCK_METHOD1(depends_on, void(const sycl::detail::EventImplPtr &));
4251
MOCK_METHOD1(depends_on, void(event Event));
4352
MOCK_METHOD1(depends_on,
@@ -67,17 +76,15 @@ TEST_F(SchedulerTest, InOrderQueueSyncCheck) {
6776
// previous task, this is needed to properly sync blocking & blocked tasks.
6877
sycl::event Event;
6978
{
70-
LimitedHandlerSimulation MockCGH;
79+
LimitedHandlerSimulation MockCGH{detail::CG::CGTYPE::CodeplayHostTask};
7180
EXPECT_CALL(MockCGH, depends_on(An<const sycl::detail::EventImplPtr &>()))
7281
.Times(0);
73-
Queue->finalizeHandler<LimitedHandlerSimulation>(
74-
MockCGH, detail::CG::CGTYPE::CodeplayHostTask, Event);
82+
Queue->finalizeHandler<LimitedHandlerSimulation>(MockCGH, Event);
7583
}
7684
{
77-
LimitedHandlerSimulation MockCGH;
85+
LimitedHandlerSimulation MockCGH{detail::CG::CGTYPE::CodeplayHostTask};
7886
EXPECT_CALL(MockCGH, depends_on(An<const sycl::detail::EventImplPtr &>()))
7987
.Times(1);
80-
Queue->finalizeHandler<LimitedHandlerSimulation>(
81-
MockCGH, detail::CG::CGTYPE::CodeplayHostTask, Event);
88+
Queue->finalizeHandler<LimitedHandlerSimulation>(MockCGH, Event);
8289
}
8390
}

0 commit comments

Comments
 (0)