Skip to content

Commit 87ebd14

Browse files
Merge branch 'alignHandleWithProducesPiEvent' into HT_user_events_1
2 parents 4d1f62d + 803a2f5 commit 87ebd14

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
@@ -1091,6 +1091,14 @@ void AllocaCommand::emitInstrumentationData() {
10911091
#endif
10921092
}
10931093

1094+
bool AllocaCommand::producesPiEvent() const {
1095+
// for reference see enqueueImp()
1096+
auto TypedSyclMemObj = static_cast<detail::SYCLMemObjT *>(getSYCLMemObj());
1097+
// Event presence implies interop context esistence
1098+
return (TypedSyclMemObj->hasInteropEvent() &&
1099+
(getContext(MQueue) == TypedSyclMemObj->getInteropContext()));
1100+
}
1101+
10941102
ur_result_t AllocaCommand::enqueueImp() {
10951103
waitForPreparedHostEvents();
10961104
std::vector<EventImplPtr> EventImpls = MPreparedDepsEvents;
@@ -1119,9 +1127,9 @@ ur_result_t AllocaCommand::enqueueImp() {
11191127
Result != UR_RESULT_SUCCESS)
11201128
return Result;
11211129

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

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

sycl/source/detail/scheduler/commands.hpp

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

505506
private:
506507
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)