Skip to content

Commit d0b8cf7

Browse files
author
Alexander Batashev
committed
Address comments
Signed-off-by: Alexander Batashev <[email protected]>
1 parent 7e1a82f commit d0b8cf7

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

sycl/include/CL/sycl/detail/queue_impl.hpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class queue_impl {
3838
/// Constructs a SYCL queue from a device using an async_handler and
3939
/// property_list provided.
4040
///
41-
/// @param Device is a pointer to device_impl.
41+
/// @param Device is a SYCL device that is used to dispatch tasks submitted to
42+
/// the queue.
4243
/// @param AsyncHandler is a SYCL asynchronous exception handler.
4344
/// @param Order specifies whether the queue being constructed as in-order or
4445
/// out-of-order.
@@ -53,8 +54,10 @@ class queue_impl {
5354
/// Constructs a SYCL queue with an async_handler and property_list provided
5455
/// form a device and a context.
5556
///
56-
/// @param Device is a pointer to device_impl.
57-
/// @param Context is a pointer to context_impl.
57+
/// @param Device is a SYCL device that is used to dispatch tasks submitted to
58+
/// the queue.
59+
/// @param Context is a SYCL context to associate with the queue being
60+
/// constructed.
5861
/// @param AsyncHandler is a SYCL asynchronous exception handler.
5962
/// @param Order specifies whether the queue being constructed as in-order or
6063
/// out-of-order.
@@ -73,7 +76,8 @@ class queue_impl {
7376
/// Constructs a SYCL queue from plugin interoperability handle.
7477
///
7578
/// @param PiQueue is a raw PI queue handle.
76-
/// @param Context is a pointer to context_impl.
79+
/// @param Context is a SYCL context to associate with the queue being
80+
/// constructed.
7781
/// @param AsyncHandler is a SYCL asynchronous exception handler.
7882
queue_impl(RT::PiQueue PiQueue, ContextImplPtr Context,
7983
const async_handler &AsyncHandler)
@@ -114,8 +118,7 @@ class queue_impl {
114118
return createSyclObjFromImpl<context>(MContext);
115119
}
116120

117-
/// @return a pointer to a context_impl.
118-
ContextImplPtr getContextImpl() const { return MContext; }
121+
ContextImplPtr getContextImplPtr() const { return MContext; }
119122

120123
/// @return an associated SYCL device.
121124
device get_device() const { return createSyclObjFromImpl<device>(MDevice); }

sycl/source/detail/scheduler/graph_builder.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Scheduler::GraphBuilder::getOrInsertMemObjRecord(const QueueImplPtr &Queue,
123123
MemObject->MRecord.reset(new MemObjRecord{/*MAllocaCommands*/ {},
124124
/*MReadLeaves*/ {},
125125
/*MWriteLeaves*/ {},
126-
Queue->getContextImpl(),
126+
Queue->getContextImplPtr(),
127127
/*MMemModified*/ false});
128128

129129
MMemObjs.push_back(MemObject);
@@ -162,7 +162,7 @@ void Scheduler::GraphBuilder::AddNodeToLeaves(MemObjRecord *Record,
162162
UpdateHostRequirementCommand *Scheduler::GraphBuilder::insertUpdateHostReqCmd(
163163
MemObjRecord *Record, Requirement *Req, const QueueImplPtr &Queue) {
164164
AllocaCommandBase *AllocaCmd =
165-
findAllocaForReq(Record, Req, Queue->getContextImpl());
165+
findAllocaForReq(Record, Req, Queue->getContextImplPtr());
166166
assert(AllocaCmd && "There must be alloca for requirement!");
167167
UpdateHostRequirementCommand *UpdateCommand =
168168
new UpdateHostRequirementCommand(Queue, *Req, AllocaCmd, &Req->MData);
@@ -171,7 +171,7 @@ UpdateHostRequirementCommand *Scheduler::GraphBuilder::insertUpdateHostReqCmd(
171171
const Requirement *StoredReq = UpdateCommand->getRequirement();
172172

173173
std::set<Command *> Deps =
174-
findDepsForReq(Record, Req, Queue->getContextImpl());
174+
findDepsForReq(Record, Req, Queue->getContextImplPtr());
175175
for (Command *Dep : Deps) {
176176
UpdateCommand->addDep(DepDesc{Dep, StoredReq, AllocaCmd});
177177
Dep->addUser(UpdateCommand);
@@ -218,7 +218,7 @@ Command *Scheduler::GraphBuilder::insertMemoryMove(MemObjRecord *Record,
218218
throw runtime_error("Out of host memory");
219219

220220
std::set<Command *> Deps =
221-
findDepsForReq(Record, Req, Queue->getContextImpl());
221+
findDepsForReq(Record, Req, Queue->getContextImplPtr());
222222
Deps.insert(AllocaCmdDst);
223223
// Get parent allocation of sub buffer to perform full copy of whole buffer
224224
if (IsSuitableSubReq(Req)) {
@@ -237,7 +237,7 @@ Command *Scheduler::GraphBuilder::insertMemoryMove(MemObjRecord *Record,
237237
// current context, need to find a parent alloca command for it (it must be
238238
// there)
239239
auto IsSuitableAlloca = [Record, Req](AllocaCommandBase *AllocaCmd) {
240-
bool Res = sameCtx(AllocaCmd->getQueue()->getContextImpl(),
240+
bool Res = sameCtx(AllocaCmd->getQueue()->getContextImplPtr(),
241241
Record->MCurContext) &&
242242
// Looking for a parent buffer alloca command
243243
AllocaCmd->getType() == Command::CommandType::ALLOCA;
@@ -279,7 +279,7 @@ Command *Scheduler::GraphBuilder::insertMemoryMove(MemObjRecord *Record,
279279
}
280280
UpdateLeaves(Deps, Record, access::mode::read_write);
281281
AddNodeToLeaves(Record, NewCmd, access::mode::read_write);
282-
Record->MCurContext = Queue->getContextImpl();
282+
Record->MCurContext = Queue->getContextImplPtr();
283283
return NewCmd;
284284
}
285285

@@ -298,7 +298,7 @@ Command *Scheduler::GraphBuilder::addCopyBack(Requirement *Req) {
298298
return nullptr;
299299

300300
std::set<Command *> Deps =
301-
findDepsForReq(Record, Req, HostQueue->getContextImpl());
301+
findDepsForReq(Record, Req, HostQueue->getContextImplPtr());
302302
AllocaCommandBase *SrcAllocaCmd =
303303
findAllocaForReq(Record, Req, Record->MCurContext);
304304

@@ -336,7 +336,7 @@ Command *Scheduler::GraphBuilder::addHostAccessor(Requirement *Req) {
336336
AllocaCommandBase *HostAllocaCmd =
337337
getOrCreateAllocaForReq(Record, Req, HostQueue);
338338

339-
if (!sameCtx(HostAllocaCmd->getQueue()->getContextImpl(),
339+
if (!sameCtx(HostAllocaCmd->getQueue()->getContextImplPtr(),
340340
Record->MCurContext))
341341
insertMemoryMove(Record, Req, HostQueue);
342342

@@ -418,7 +418,7 @@ Scheduler::GraphBuilder::findDepsForReq(MemObjRecord *Record, Requirement *Req,
418418
// Going through copying memory between contexts is not supported.
419419
if (Dep.MDepCommand)
420420
CanBypassDep &=
421-
sameCtx(Context, Dep.MDepCommand->getQueue()->getContextImpl());
421+
sameCtx(Context, Dep.MDepCommand->getQueue()->getContextImplPtr());
422422

423423
if (!CanBypassDep) {
424424
RetDeps.insert(DepCmd);
@@ -441,7 +441,7 @@ Scheduler::GraphBuilder::findDepsForReq(MemObjRecord *Record, Requirement *Req,
441441
AllocaCommandBase *Scheduler::GraphBuilder::findAllocaForReq(
442442
MemObjRecord *Record, Requirement *Req, const ContextImplPtr &Context) {
443443
auto IsSuitableAlloca = [&Context, Req](AllocaCommandBase *AllocaCmd) {
444-
bool Res = sameCtx(AllocaCmd->getQueue()->getContextImpl(), Context);
444+
bool Res = sameCtx(AllocaCmd->getQueue()->getContextImplPtr(), Context);
445445
if (IsSuitableSubReq(Req)) {
446446
const Requirement *TmpReq = AllocaCmd->getRequirement();
447447
Res &= TmpReq->MOffsetInBytes == Req->MOffsetInBytes;
@@ -462,7 +462,7 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
462462
MemObjRecord *Record, Requirement *Req, QueueImplPtr Queue) {
463463

464464
AllocaCommandBase *AllocaCmd =
465-
findAllocaForReq(Record, Req, Queue->getContextImpl());
465+
findAllocaForReq(Record, Req, Queue->getContextImplPtr());
466466

467467
if (!AllocaCmd) {
468468
if (IsSuitableSubReq(Req)) {
@@ -477,7 +477,7 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
477477
auto *ParentAlloca =
478478
getOrCreateAllocaForReq(Record, &ParentRequirement, Queue);
479479
AllocaCmd = new AllocaSubBufCommand(Queue, *Req, ParentAlloca);
480-
UpdateLeaves(findDepsForReq(Record, Req, Queue->getContextImpl()),
480+
UpdateLeaves(findDepsForReq(Record, Req, Queue->getContextImplPtr()),
481481
Record, access::mode::read_write);
482482
} else {
483483

@@ -530,7 +530,7 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
530530
AllocaCmd->MIsActive = false;
531531
} else {
532532
LinkedAllocaCmd->MIsActive = false;
533-
Record->MCurContext = Queue->getContextImpl();
533+
Record->MCurContext = Queue->getContextImplPtr();
534534
}
535535
}
536536
}
@@ -576,7 +576,7 @@ Scheduler::GraphBuilder::addCG(std::unique_ptr<detail::CG> CommandGroup,
576576
AllocaCommandBase *AllocaCmd = getOrCreateAllocaForReq(Record, Req, Queue);
577577
// If there is alloca command we need to check if the latest memory is in
578578
// required context.
579-
if (!sameCtx(Queue->getContextImpl(), Record->MCurContext)) {
579+
if (!sameCtx(Queue->getContextImplPtr(), Record->MCurContext)) {
580580
// Cannot directly copy memory from OpenCL device to OpenCL device -
581581
// create two copies: device->host and host->device.
582582
if (!Queue->is_host() && !Record->MCurContext->is_host())
@@ -585,7 +585,7 @@ Scheduler::GraphBuilder::addCG(std::unique_ptr<detail::CG> CommandGroup,
585585
insertMemoryMove(Record, Req, Queue);
586586
}
587587
std::set<Command *> Deps =
588-
findDepsForReq(Record, Req, Queue->getContextImpl());
588+
findDepsForReq(Record, Req, Queue->getContextImplPtr());
589589

590590
for (Command *Dep : Deps)
591591
NewCmd->addDep(DepDesc{Dep, Req, AllocaCmd});

0 commit comments

Comments
 (0)