Skip to content

Commit 6b67aaf

Browse files
committed
Applying comment
Signed-off-by: Vlad Romanov <[email protected]>
1 parent 9d7850f commit 6b67aaf

File tree

7 files changed

+29
-25
lines changed

7 files changed

+29
-25
lines changed

sycl/include/CL/sycl/detail/buffer_impl.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,11 @@ class buffer_impl final : public SYCLMemObjT<AllocatorT> {
149149
"Cannot init from user data and reuse host ptr provided "
150150
"simultaneously");
151151

152-
void *UserPtr = HostPtr;
153-
UserPtr = InitFromUserData ? BaseT::getUserPtr() : UserPtr;
152+
void *UserPtr = InitFromUserData ? BaseT::getUserPtr() : HostPtr;
154153

155-
if (nullptr == UserPtr && BaseT::useHostPtr() && Context->is_host())
156-
throw sycl::runtime_error("Internal error. Allocating memory on the host "
157-
"while having use_host_ptr property");
154+
assert(!(nullptr == UserPtr && BaseT::useHostPtr() && Context->is_host()) &&
155+
"Internal error. Allocating memory on the host "
156+
"while having use_host_ptr property");
158157

159158
return MemoryManager::allocateMemBuffer(
160159
std::move(Context), this, UserPtr, BaseT::MHostPtrReadOnly,

sycl/include/CL/sycl/detail/image_impl.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ class image_impl final : public SYCLMemObjT<AllocatorT> {
286286
"Cannot init from user data and reuse host ptr provided "
287287
"simultaneously");
288288

289-
void *UserPtr = HostPtr;
290-
UserPtr = InitFromUserData ? BaseT::getUserPtr() : UserPtr;
289+
void *UserPtr = InitFromUserData ? BaseT::getUserPtr() : UserPtr;
291290

292291
RT::PiMemImageDesc Desc = getImageDesc(UserPtr != nullptr);
293292
assert(checkImageDesc(Desc, Context, UserPtr) &&

sycl/include/CL/sycl/detail/scheduler/commands.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class AllocaCommandBase : public Command {
198198
AllocaCommandBase(CommandType Type, QueueImplPtr Queue, Requirement Req,
199199
AllocaCommandBase *LinkedAllocaCmd)
200200
: Command(Type, Queue), MLinkedAllocaCmd(LinkedAllocaCmd),
201-
MLeaderAlloca(nullptr == LinkedAllocaCmd), MReleaseCmd(Queue, this),
201+
MIsLeaderAlloca(nullptr == LinkedAllocaCmd), MReleaseCmd(Queue, this),
202202
MRequirement(std::move(Req)) {
203203
MRequirement.MAccessMode = access::mode::read_write;
204204
}
@@ -216,15 +216,15 @@ class AllocaCommandBase : public Command {
216216
// Alloca command linked with current command.
217217
// Device and host alloca commands can be linked, so they may share the same
218218
// memory. Only one allocation from a pair can be accessed at a time. Alloca
219-
// commands associcated with such allocation is "active". In order to switch
219+
// commands associated with such allocation is "active". In order to switch
220220
// "active" status between alloca commands map/unmap operations are used.
221221
AllocaCommandBase *MLinkedAllocaCmd = nullptr;
222222
// Indicates that current alloca is active one.
223-
bool MActive = true;
223+
bool MIsActive = true;
224224

225225
// Indicates that the command owns memory allocation in case of connected
226226
// alloca command
227-
bool MLeaderAlloca = true;
227+
bool MIsLeaderAlloca = true;
228228

229229
protected:
230230
ReleaseCommand MReleaseCmd;

sycl/include/CL/sycl/detail/scheduler/scheduler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Scheduler {
7575
// memory which contains the latest data of the memory object. New operations
7676
// with the same memory object that have side effects are blocked until
7777
// releaseHostAccessor is called.
78-
// Returns an event which indicates when thsese nodes are completed and host
78+
// Returns an event which indicates when these nodes are completed and host
7979
// accessor is ready for using.
8080
EventImplPtr addHostAccessor(Requirement *Req);
8181

sycl/source/detail/accessor_impl.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
//==---------------- accessor_impl.cpp - SYCL standard source file ---------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
19
#include <CL/sycl/detail/accessor_impl.hpp>
210
#include <CL/sycl/detail/scheduler/scheduler.hpp>
311

sycl/source/detail/scheduler/commands.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ cl_int AllocaCommand::enqueueImp() {
191191
RT::PiEvent &Event = MEvent->getHandleRef();
192192

193193
void *HostPtr = nullptr;
194-
if (!MLeaderAlloca) {
194+
if (!MIsLeaderAlloca) {
195195

196196
if (MQueue->is_host()) {
197197
// Do not need make allocation if we have linked device allocation
@@ -286,10 +286,9 @@ cl_int ReleaseCommand::enqueueImp() {
286286

287287
// There is no actual memory allocation if a host alloca command is created
288288
// being linked to a device allocation.
289-
SkipRelease |= CurAllocaIsHost && !MAllocaCmd->MLeaderAlloca;
289+
SkipRelease |= CurAllocaIsHost && !MAllocaCmd->MIsLeaderAlloca;
290290

291-
NeedUnmap |= !CurAllocaIsHost && !MAllocaCmd->MActive;
292-
NeedUnmap |= CurAllocaIsHost && MAllocaCmd->MActive;
291+
NeedUnmap |= CurAllocaIsHost == MAllocaCmd->MIsActive;
293292
}
294293

295294
if (NeedUnmap) {
@@ -310,7 +309,7 @@ cl_int ReleaseCommand::enqueueImp() {
310309
std::move(RawEvents), /*MUseExclusiveQueue*/ false,
311310
MapEvent);
312311

313-
std::swap(MAllocaCmd->MActive, MAllocaCmd->MLinkedAllocaCmd->MActive);
312+
std::swap(MAllocaCmd->MIsActive, MAllocaCmd->MLinkedAllocaCmd->MIsActive);
314313
RawEvents.push_back(MapEvent);
315314
}
316315

sycl/source/detail/scheduler/graph_builder.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Command *insertMapUnmapForLinkedCmds(AllocaCommandBase *AllocaCmdSrc,
188188
AllocaCmdDst, *AllocaCmdDst->getRequirement(),
189189
&AllocaCmdSrc->MMemAllocation, AllocaCmdDst->getQueue()));
190190

191-
std::swap(AllocaCmdSrc->MActive, AllocaCmdDst->MActive);
191+
std::swap(AllocaCmdSrc->MIsActive, AllocaCmdDst->MIsActive);
192192

193193
return UnMapCmdUPtr.release();
194194
}
@@ -197,7 +197,7 @@ Command *insertMapUnmapForLinkedCmds(AllocaCommandBase *AllocaCmdSrc,
197197
AllocaCmdSrc, *AllocaCmdSrc->getRequirement(),
198198
&AllocaCmdDst->MMemAllocation, AllocaCmdSrc->getQueue()));
199199

200-
std::swap(AllocaCmdSrc->MActive, AllocaCmdDst->MActive);
200+
std::swap(AllocaCmdSrc->MIsActive, AllocaCmdDst->MIsActive);
201201

202202
return MapCmdUPtr.release();
203203
}
@@ -245,7 +245,7 @@ Command *Scheduler::GraphBuilder::insertMemoryMove(MemObjRecord *Record,
245245
NewCmd = insertMapUnmapForLinkedCmds(AllocaCmdSrc, AllocaCmdDst);
246246
} else {
247247

248-
if (AllocaCmdDst->MLinkedAllocaCmd && !AllocaCmdDst->MActive) {
248+
if (AllocaCmdDst->MLinkedAllocaCmd && !AllocaCmdDst->MIsActive) {
249249
NewCmd = insertMapUnmapForLinkedCmds(AllocaCmdSrc, AllocaCmdDst);
250250
const Requirement *NewReq = NewCmd->getRequirement();
251251
for (Command *Dep : Deps) {
@@ -259,7 +259,7 @@ Command *Scheduler::GraphBuilder::insertMemoryMove(MemObjRecord *Record,
259259
}
260260

261261
// Full copy of buffer is needed to avoid loss of data that may be caused
262-
// by copying specific range form host to device and backwards.
262+
// by copying specific range from host to device and backwards.
263263
NewCmd = new MemCpyCommand(*AllocaCmdSrc->getRequirement(), AllocaCmdSrc,
264264
*AllocaCmdDst->getRequirement(), AllocaCmdDst,
265265
AllocaCmdSrc->getQueue(),
@@ -339,8 +339,7 @@ Command *Scheduler::GraphBuilder::addHostAccessor(Requirement *Req) {
339339
Command *UpdateHostAccCmd = insertUpdateHostReqCmd(Record, Req, HostQueue);
340340

341341
// Need empty command to be blocked until host accessor is destructed
342-
std::unique_ptr<EmptyCommand> EmptyCmdUPtr(new EmptyCommand(HostQueue, *Req));
343-
EmptyCommand *EmptyCmd = EmptyCmdUPtr.release();
342+
EmptyCommand *EmptyCmd = new EmptyCommand(HostQueue, *Req);
344343
EmptyCmd->addDep(
345344
DepDesc{UpdateHostAccCmd, EmptyCmd->getRequirement(), SrcAllocaCmd});
346345
UpdateHostAccCmd->addUser(EmptyCmd);
@@ -524,9 +523,9 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
524523
// always be active here. Also if the "follower" command is a device one
525524
// we have to change current context to the device one.
526525
if (Queue->is_host()) {
527-
AllocaCmd->MActive = false;
526+
AllocaCmd->MIsActive = false;
528527
} else {
529-
LinkedAllocaCmd->MActive = false;
528+
LinkedAllocaCmd->MIsActive = false;
530529
Record->MCurContext = Queue->get_context_impl();
531530
}
532531
}

0 commit comments

Comments
 (0)