Skip to content

Commit 9a29376

Browse files
fix
Signed-off-by: Tikhomirova, Kseniya <[email protected]>
1 parent 4797df6 commit 9a29376

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

sycl/source/detail/scheduler/commands.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,14 @@ void AllocaCommand::emitInstrumentationData() {
10901090
#endif
10911091
}
10921092

1093+
bool AllocaCommand::producesPiEvent() const {
1094+
// for reference see enqueueImp()
1095+
auto TypedSyclMemObj = static_cast<detail::SYCLMemObjT *>(getSYCLMemObj());
1096+
// Event presence implies interop context esistence
1097+
return TypedSyclMemObj->hasInteropEvent() && !MIsLeaderAlloca &&
1098+
(MLinkedAllocaCmd->getMemAllocation() != nullptr);
1099+
}
1100+
10931101
ur_result_t AllocaCommand::enqueueImp() {
10941102
waitForPreparedHostEvents();
10951103
std::vector<EventImplPtr> EventImpls = MPreparedDepsEvents;
@@ -1118,9 +1126,9 @@ ur_result_t AllocaCommand::enqueueImp() {
11181126
Result != UR_RESULT_SUCCESS)
11191127
return Result;
11201128

1121-
// MemoryManager::allocate doesn't always provide native event, it is returned
1122-
// only for interop case with presence of host pointer and interop event. Not
1123-
// feasible to check it from command.
1129+
assert((!!UREvent == producesPiEvent()) &&
1130+
"AllocaCommand: native event is expected only when it is for interop "
1131+
"memory object with native event provided.");
11241132

11251133
MEvent->setHandle(UREvent);
11261134
return UR_RESULT_SUCCESS;

sycl/source/detail/scheduler/commands.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ class AllocaCommand : public AllocaCommandBase {
499499
void *getMemAllocation() const final { return MMemAllocation; }
500500
void printDot(std::ostream &Stream) const final;
501501
void emitInstrumentationData() override;
502+
bool producesPiEvent() const final;
502503

503504
private:
504505
ur_result_t enqueueImp() final;

sycl/source/detail/sycl_mem_obj_t.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ void SYCLMemObjT::handleWriteAccessorCreation() {
244244
}
245245
}
246246

247+
bool SYCLMemObjT::hasInteropEvent() const {
248+
return MInteropEvent && MInteropEvent->getHandle();
249+
}
250+
247251
} // namespace detail
248252
} // namespace _V1
249253
} // namespace sycl

sycl/source/detail/sycl_mem_obj_t.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ class SYCLMemObjT : public SYCLMemObjI {
159159
MHostPtrProvided = true;
160160
}
161161

162+
bool hasInteropEvent() const;
163+
162164
protected:
163165
void updateHostMemory(void *const Ptr);
164166

0 commit comments

Comments
 (0)