Skip to content

Commit c2b1ef2

Browse files
committed
[SYCL] Add empty task type of commands
The command does nothing during enqueue. The task can be used to implement locks in the graph, or to merge several nodes into one. Signed-off-by: Vlad Romanov <[email protected]>
1 parent 58ef151 commit c2b1ef2

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ class Command {
6666
RELEASE,
6767
MAP_MEM_OBJ,
6868
UNMAP_MEM_OBJ,
69-
UPDATE_REQUIREMENT
69+
UPDATE_REQUIREMENT,
70+
EMPTY_TASK
7071
};
7172

7273
Command(CommandType Type, QueueImplPtr Queue, bool UseExclusiveQueue = false);
@@ -123,6 +124,23 @@ class Command {
123124
std::atomic<bool> MEnqueued;
124125
};
125126

127+
// The command does nothing during enqueue. The task can be used to implement
128+
// lock in the graph, or to merge several nodes into one.
129+
class EmptyCommand : public Command {
130+
public:
131+
EmptyCommand(QueueImplPtr Queue, Requirement *Req)
132+
: Command(CommandType::EMPTY_TASK, std::move(Queue)),
133+
MStoredRequirement(*Req) {}
134+
135+
Requirement *getStoredRequirement() { return &MStoredRequirement; }
136+
137+
private:
138+
cl_int enqueueImp() override { return CL_SUCCESS; }
139+
void printDot(std::ostream &Stream) const override;
140+
141+
Requirement MStoredRequirement;
142+
};
143+
126144
// The command enqueues release instance of memory allocated on Host or
127145
// underlying framework.
128146
class ReleaseCommand : public Command {

sycl/source/detail/scheduler/commands.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,23 @@ cl_int MemCpyCommandHost::enqueueImp() {
467467
return CL_SUCCESS;
468468
}
469469

470+
void EmptyCommand::printDot(std::ostream &Stream) const {
471+
Stream << "\"" << this << "\" [style=filled, fillcolor=\"#8d8f29\", label=\"";
472+
473+
Stream << "ID = " << this << "\n";
474+
Stream << "EMPTY NODE"
475+
<< "\\n";
476+
477+
Stream << "\"];" << std::endl;
478+
479+
for (const auto &Dep : MDeps) {
480+
Stream << " \"" << this << "\" -> \"" << Dep.MDepCommand << "\""
481+
<< " [ label = \"Access mode: "
482+
<< accessModeToString(Dep.MReq->MAccessMode) << "\\n"
483+
<< "MemObj: " << Dep.MReq->MSYCLMemObj << " \" ]" << std::endl;
484+
}
485+
}
486+
470487
void MemCpyCommandHost::printDot(std::ostream &Stream) const {
471488
Stream << "\"" << this << "\" [style=filled, fillcolor=\"#B6A2EB\", label=\"";
472489

0 commit comments

Comments
 (0)