Skip to content

[SYCL][NFC] Fixed typos in variable names #912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions sycl/include/CL/sycl/detail/scheduler/scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ struct MemObjRecord {
std::vector<AllocaCommandBase *> MAllocaCommands;

// Contains latest read only commands working with memory object.
std::vector<Command *> MReadLeafs;
std::vector<Command *> MReadLeaves;

// Contains latest write commands working with memory object.
std::vector<Command *> MWriteLeafs;
std::vector<Command *> MWriteLeaves;

// The context which has the latest state of the memory object.
ContextImplPtr MCurContext;
Expand Down Expand Up @@ -140,13 +140,13 @@ class Scheduler {
// Removes MemObjRecord for memory object passed.
void removeRecordForMemObj(SYCLMemObjI *MemObject);

// Add new command to leafs if needed.
void AddNodeToLeafs(MemObjRecord *Record, Command *Cmd,
access::mode AccessMode);
// Add new command to leaves if needed.
void AddNodeToLeaves(MemObjRecord *Record, Command *Cmd,
access::mode AccessMode);

// Removes commands from leafs.
void UpdateLeafs(const std::set<Command *> &Cmds, MemObjRecord *Record,
access::mode AccessMode);
// Removes commands from leaves.
void UpdateLeaves(const std::set<Command *> &Cmds, MemObjRecord *Record,
access::mode AccessMode);

std::vector<SYCLMemObjI *> MMemObjs;

Expand Down
67 changes: 34 additions & 33 deletions sycl/source/detail/scheduler/graph_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,41 +121,42 @@ Scheduler::GraphBuilder::getOrInsertMemObjRecord(const QueueImplPtr &Queue,
return Record;

MemObject->MRecord.reset(new MemObjRecord{/*MAllocaCommands*/ {},
/*MReadLeafs*/ {},
/*MWriteLeafs*/ {},
/*MReadLeaves*/ {},
/*MWriteLeaves*/ {},
Queue->get_context_impl(),
/*MMemModified*/ false});

MMemObjs.push_back(MemObject);
return MemObject->MRecord.get();
}

// Helper function which removes all values in Cmds from Leafs
void Scheduler::GraphBuilder::UpdateLeafs(const std::set<Command *> &Cmds,
MemObjRecord *Record,
access::mode AccessMode) {
// Helper function which removes all values in Cmds from Leaves
void Scheduler::GraphBuilder::UpdateLeaves(const std::set<Command *> &Cmds,
MemObjRecord *Record,
access::mode AccessMode) {

const bool ReadOnlyReq = AccessMode == access::mode::read;
if (ReadOnlyReq)
return;

for (const Command *Cmd : Cmds) {
auto NewEnd =
std::remove(Record->MReadLeafs.begin(), Record->MReadLeafs.end(), Cmd);
Record->MReadLeafs.erase(NewEnd, Record->MReadLeafs.end());
auto NewEnd = std::remove(Record->MReadLeaves.begin(),
Record->MReadLeaves.end(), Cmd);
Record->MReadLeaves.erase(NewEnd, Record->MReadLeaves.end());

NewEnd = std::remove(Record->MWriteLeafs.begin(), Record->MWriteLeafs.end(),
Cmd);
Record->MWriteLeafs.erase(NewEnd, Record->MWriteLeafs.end());
NewEnd = std::remove(Record->MWriteLeaves.begin(),
Record->MWriteLeaves.end(), Cmd);
Record->MWriteLeaves.erase(NewEnd, Record->MWriteLeaves.end());
}
}

void Scheduler::GraphBuilder::AddNodeToLeafs(MemObjRecord *Record, Command *Cmd,
access::mode AccessMode) {
void Scheduler::GraphBuilder::AddNodeToLeaves(MemObjRecord *Record,
Command *Cmd,
access::mode AccessMode) {
if (AccessMode == access::mode::read)
Record->MReadLeafs.push_back(Cmd);
Record->MReadLeaves.push_back(Cmd);
else
Record->MWriteLeafs.push_back(Cmd);
Record->MWriteLeaves.push_back(Cmd);
}

UpdateHostRequirementCommand *Scheduler::GraphBuilder::insertUpdateHostReqCmd(
Expand All @@ -175,8 +176,8 @@ UpdateHostRequirementCommand *Scheduler::GraphBuilder::insertUpdateHostReqCmd(
UpdateCommand->addDep(DepDesc{Dep, StoredReq, AllocaCmd});
Dep->addUser(UpdateCommand);
}
UpdateLeafs(Deps, Record, Req->MAccessMode);
AddNodeToLeafs(Record, UpdateCommand, Req->MAccessMode);
UpdateLeaves(Deps, Record, Req->MAccessMode);
AddNodeToLeaves(Record, UpdateCommand, Req->MAccessMode);
return UpdateCommand;
}

Expand Down Expand Up @@ -261,8 +262,8 @@ Command *Scheduler::GraphBuilder::insertMemoryMove(MemObjRecord *Record,
NewCmd->addDep(DepDesc{Dep, NewCmd->getRequirement(), AllocaCmdDst});
Dep->addUser(NewCmd);
}
UpdateLeafs(Deps, Record, access::mode::read_write);
AddNodeToLeafs(Record, NewCmd, access::mode::read_write);
UpdateLeaves(Deps, Record, access::mode::read_write);
AddNodeToLeaves(Record, NewCmd, access::mode::read_write);
Record->MCurContext = Queue->get_context_impl();
return NewCmd;
}
Expand Down Expand Up @@ -299,8 +300,8 @@ Command *Scheduler::GraphBuilder::addCopyBack(Requirement *Req) {
Dep->addUser(MemCpyCmd);
}

UpdateLeafs(Deps, Record, Req->MAccessMode);
AddNodeToLeafs(Record, MemCpyCmd, Req->MAccessMode);
UpdateLeaves(Deps, Record, Req->MAccessMode);
AddNodeToLeaves(Record, MemCpyCmd, Req->MAccessMode);
if (MPrintOptionsArray[AfterAddCopyBack])
printGraphAsDot("after_addCopyBack");
return MemCpyCmd;
Expand Down Expand Up @@ -339,8 +340,8 @@ Command *Scheduler::GraphBuilder::addHostAccessor(Requirement *Req) {
EmptyCmd->MCanEnqueue = false;
EmptyCmd->MBlockReason = "A Buffer is locked by the host accessor";

UpdateLeafs({UpdateHostAccCmd}, Record, Req->MAccessMode);
AddNodeToLeafs(Record, EmptyCmd, Req->MAccessMode);
UpdateLeaves({UpdateHostAccCmd}, Record, Req->MAccessMode);
AddNodeToLeaves(Record, EmptyCmd, Req->MAccessMode);

Req->MBlockedCmd = EmptyCmd;

Expand Down Expand Up @@ -378,11 +379,11 @@ Scheduler::GraphBuilder::findDepsForReq(MemObjRecord *Record, Requirement *Req,

std::vector<Command *> ToAnalyze;

ToAnalyze = Record->MWriteLeafs;
ToAnalyze = Record->MWriteLeaves;

if (!ReadOnlyReq)
ToAnalyze.insert(ToAnalyze.begin(), Record->MReadLeafs.begin(),
Record->MReadLeafs.end());
ToAnalyze.insert(ToAnalyze.begin(), Record->MReadLeaves.begin(),
Record->MReadLeaves.end());

while (!ToAnalyze.empty()) {
Command *DepCmd = ToAnalyze.back();
Expand Down Expand Up @@ -464,8 +465,8 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
auto *ParentAlloca =
getOrCreateAllocaForReq(Record, &ParentRequirement, Queue);
AllocaCmd = new AllocaSubBufCommand(Queue, *Req, ParentAlloca);
UpdateLeafs(findDepsForReq(Record, Req, Queue->get_context_impl()),
Record, access::mode::read_write);
UpdateLeaves(findDepsForReq(Record, Req, Queue->get_context_impl()),
Record, access::mode::read_write);
} else {

const Requirement FullReq(/*Offset*/ {0, 0, 0}, Req->MMemoryRange,
Expand Down Expand Up @@ -523,7 +524,7 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq(
}

Record->MAllocaCommands.push_back(AllocaCmd);
Record->MWriteLeafs.push_back(AllocaCmd);
Record->MWriteLeaves.push_back(AllocaCmd);
}
return AllocaCmd;
}
Expand Down Expand Up @@ -578,13 +579,13 @@ Scheduler::GraphBuilder::addCG(std::unique_ptr<detail::CG> CommandGroup,
NewCmd->addDep(DepDesc{Dep, Req, AllocaCmd});
}

// Set new command as user for dependencies and update leafs.
// Set new command as user for dependencies and update leaves.
for (DepDesc &Dep : NewCmd->MDeps) {
Dep.MDepCommand->addUser(NewCmd.get());
const Requirement *Req = Dep.MDepRequirement;
MemObjRecord *Record = getMemObjRecord(Req->MSYCLMemObj);
UpdateLeafs({Dep.MDepCommand}, Record, Req->MAccessMode);
AddNodeToLeafs(Record, NewCmd.get(), Req->MAccessMode);
UpdateLeaves({Dep.MDepCommand}, Record, Req->MAccessMode);
AddNodeToLeaves(Record, NewCmd.get(), Req->MAccessMode);
}

// Register all the events as dependencies
Expand Down
4 changes: 2 additions & 2 deletions sycl/source/detail/scheduler/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ namespace sycl {
namespace detail {

void Scheduler::waitForRecordToFinish(MemObjRecord *Record) {
for (Command *Cmd : Record->MReadLeafs) {
for (Command *Cmd : Record->MReadLeaves) {
EnqueueResultT Res;
bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res);
if (!Enqueued && EnqueueResultT::FAILED == Res.MResult)
throw runtime_error("Enqueue process failed.");
GraphProcessor::waitForEvent(Cmd->getEvent());
}
for (Command *Cmd : Record->MWriteLeafs) {
for (Command *Cmd : Record->MWriteLeaves) {
EnqueueResultT Res;
bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res);
if (!Enqueued && EnqueueResultT::FAILED == Res.MResult)
Expand Down