17 #include <unordered_set>
30 #ifdef XPTI_ENABLE_INSTRUMENTATION
31 bool CurrentCodeLocationValid();
37 class DispatchHostTask;
39 using QueueImplPtr = std::shared_ptr<detail::queue_impl>;
40 using EventImplPtr = std::shared_ptr<detail::event_impl>;
63 : MResult(Result), MCmd(Cmd), MErrCode(ErrCode) {}
76 : MDepCommand(DepCommand), MDepRequirement(Req), MAllocaCmd(AllocaCmd) {}
121 std::vector<Command *> &ToCleanUp);
127 std::vector<Command *> &ToCleanUp);
142 std::vector<Command *> &ToCleanUp);
147 return MEnqueueStatus == EnqueueResultT::SyclEnqueueSuccess;
153 return MIsBlockable && MEnqueueStatus == EnqueueResultT::SyclEnqueueBlocked;
157 bool isBlocking()
const {
return isHostTask() && !MEvent->isCompleted(); }
160 if (std::find(MBlockedUsers.begin(), MBlockedUsers.end(), NewUser) !=
163 MBlockedUsers.push_back(NewUser);
173 void emitInstrumentationDataProxy();
175 virtual void emitInstrumentationData() = 0;
178 void resolveReleaseDependencies(std::set<Command *> &list);
180 void emitEdgeEventForCommandDependence(
181 Command *Cmd,
void *ObjAddr,
bool IsCommand,
182 std::optional<access::mode> AccMode = std::nullopt);
186 void emitEnqueuedEventSignal(
RT::PiEvent &PiEventAddr);
191 uint64_t makeTraceEventProlog(
void *MAddress);
194 void makeTraceEventEpilog();
196 void emitInstrumentation(uint16_t Type,
const char *Txt =
nullptr);
200 virtual void printDot(std::ostream &Stream)
const = 0;
203 assert(
false &&
"Internal Error. The command has no stored requirement");
207 virtual ~Command() { MEvent->cleanDepEventsThroughOneLevel(); }
209 const char *getBlockReason()
const;
220 virtual bool producesPiEvent()
const;
223 virtual bool supportsPostEnqueueCleanup()
const;
226 virtual bool readyForCleanup()
const;
230 std::vector<RT::PiEvent>
231 getPiEvents(
const std::vector<EventImplPtr> &EventImpls)
const;
235 std::vector<RT::PiEvent>
236 getPiEventsBlocking(
const std::vector<EventImplPtr> &EventImpls)
const;
238 bool isHostTask()
const;
253 void waitForPreparedHostEvents()
const;
268 std::vector<Command *> &ToCleanUp);
282 return MPreparedHostDepsEvents;
286 return MPreparedDepsEvents;
291 void copySubmissionCodeLocation();
299 MPreparedDepsEvents.clear();
300 MPreparedHostDepsEvents.clear();
309 bool MIsBlockable =
false;
311 unsigned MLeafCounter = 0;
315 bool MVisited =
false;
317 bool MToBeDeleted =
false;
336 void *MTraceEvent =
nullptr;
340 int32_t MStreamID = -1;
343 void *MAddress =
nullptr;
351 bool MTraceEventPrologComplete =
false;
353 bool MFirstInstance =
false;
355 uint64_t MInstanceID = 0;
371 bool MShouldCompleteEventIfPossible =
true;
376 bool MMarkedForCleanup =
false;
393 void printDot(std::ostream &Stream)
const final;
398 void emitInstrumentationData()
override;
400 bool producesPiEvent() const final;
417 void printDot(std::ostream &Stream)
const final;
418 void emitInstrumentationData()
override;
419 bool producesPiEvent()
const final;
420 bool supportsPostEnqueueCleanup()
const final;
421 bool readyForCleanup()
const final;
440 virtual void *getMemAllocation()
const = 0;
444 void emitInstrumentationData()
override;
446 bool producesPiEvent() const final;
448 bool supportsPostEnqueueCleanup() const final;
450 bool readyForCleanup() const final;
452 void *MMemAllocation =
nullptr;
461 bool MIsActive = true;
465 bool MIsLeaderAlloca = true;
467 bool MIsConst = false;
479 bool InitFromUserData =
true,
481 bool IsConst =
false);
484 void printDot(std::ostream &Stream)
const final;
485 void emitInstrumentationData()
override;
492 bool MInitFromUserData = false;
500 std::vector<Command *> &ToEnqueue,
501 std::vector<Command *> &ToCleanUp);
503 void *getMemAllocation()
const final;
504 void printDot(std::ostream &Stream)
const final;
506 void emitInstrumentationData()
override;
520 void printDot(std::ostream &Stream)
const final;
522 void emitInstrumentationData()
override;
529 void **MDstPtr =
nullptr;
530 access::
mode MMapMode;
539 void printDot(std::ostream &Stream)
const final;
541 void emitInstrumentationData()
override;
542 bool producesPiEvent() const final;
549 void **MSrcPtr =
nullptr;
560 void printDot(std::ostream &Stream)
const final;
562 void emitInstrumentationData() final;
564 bool producesPiEvent() const final;
584 void printDot(std::ostream &Stream)
const final;
586 void emitInstrumentationData() final;
596 void **MDstPtr =
nullptr;
600 const
std::
string &PipeName,
bool blocking,
601 void *ptr,
size_t size,
603 RT::
PiEvent *OutEvent,
bool read);
611 const
std::function<
void *(
Requirement *Req)> &getMemAllocationFunc,
622 std::vector<std::shared_ptr<const void>> getAuxiliaryResources()
const;
624 void clearAuxiliaryResources();
626 void printDot(std::ostream &Stream)
const final;
627 void emitInstrumentationData()
final;
642 bool producesPiEvent() const final;
644 bool supportsPostEnqueueCleanup() const final;
646 bool readyForCleanup() const final;
653 std::unique_ptr<detail::
CG> MCommandGroup;
673 void printDot(std::ostream &Stream)
const final;
675 void emitInstrumentationData() final;
682 void **MDstPtr =
nullptr;
693 void printDot(std::ostream &Stream)
const final;
694 void emitInstrumentationData() final;
695 bool producesPiEvent() const final;
706 void setFusionStatus(FusionStatus Status);
708 bool isActive()
const {
return MStatus == FusionStatus::ACTIVE; }
719 FusionStatus MStatus;