Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
RossBrunton committed Jan 28, 2025
1 parent b632b43 commit 6d5ad1c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 18 additions & 2 deletions source/adapters/level_zero/v2/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ ur_event_handle_t_::ur_event_handle_t_(
ur_context_handle_t hContext, ur_event_handle_t_::event_variant hZeEvent,
v2::event_flags_t flags)
: hContext(hContext), hZeEvent(std::move(hZeEvent)), flags(flags),
profilingData(getZeEvent()) {}
profilingData(getZeEvent()) {
std::cout << "!! CONSTRUCTED !! #" << this << "\n";
constructed = 1234;
}

void ur_event_handle_t_::resetQueueAndCommand(ur_queue_handle_t hQueue,
ur_command_t commandType) {
Expand Down Expand Up @@ -129,8 +132,12 @@ void ur_event_handle_t_::reset() {

ze_event_handle_t ur_event_handle_t_::getZeEvent() const {
if (event_pool) {
std::cout << "@" << __LINE__ << " in " << __FILE__ << " #" << this << "\n";
assert(constructed == 1234);
return std::get<v2::raii::cache_borrowed_event>(hZeEvent).get();
} else {
std::cout << "@" << __LINE__ << " in " << __FILE__ << " #" << this << "\n";
assert(constructed == 1234);
return std::get<v2::raii::ze_event_handle_t>(hZeEvent).get();
}
}
Expand Down Expand Up @@ -194,20 +201,28 @@ ur_event_handle_t_::ur_event_handle_t_(
: ur_event_handle_t_(hContext, std::move(eventAllocation),
pool->getFlags()) {
event_pool = pool;
std::cout << "Constructing pooled variant #" << this << "\n";
std::get<v2::raii::cache_borrowed_event>(hZeEvent);
}

ur_event_handle_t_::ur_event_handle_t_(
ur_context_handle_t hContext,ur_native_handle_t hNativeEvent,
ur_context_handle_t hContext, ur_native_handle_t hNativeEvent,
const ur_event_native_properties_t *pProperties)
: ur_event_handle_t_(
hContext,
v2::raii::ze_event_handle_t{reinterpret_cast<ze_event_handle_t>(hNativeEvent), pProperties ? pProperties->isNativeHandleOwned : false}, v2::EVENT_FLAGS_PROFILING_ENABLED /* TODO: this follows legacy adapter logic, we could check this with zeEventGetPool */) {

std::cout << "Constructing native variant #" << this << "\n";
std::get<v2::raii::ze_event_handle_t>(hZeEvent);
assert(!event_pool);
}

ur_result_t ur_event_handle_t_::forceRelease() {
if (event_pool) {
std::cout << "@" << __LINE__ << " in " << __FILE__ << " #" << this << "\n";
event_pool->free(this);
} else {
std::cout << "@" << __LINE__ << " in " << __FILE__ << " #" << this << "\n";
std::get<v2::raii::ze_event_handle_t>(hZeEvent).release();
delete this;
}
Expand Down Expand Up @@ -392,6 +407,7 @@ urEventCreateWithNativeHandle(ur_native_handle_t hNativeEvent,
*phEvent = hContext->nativeEventsPool.allocate();
ZE2UR_CALL(zeEventHostSignal, ((*phEvent)->getZeEvent()));
} else {
std::cout << "Creating new native event handle...\n";
*phEvent = new ur_event_handle_t_(hContext, hNativeEvent, pProperties);
}
return UR_RESULT_SUCCESS;
Expand Down
2 changes: 2 additions & 0 deletions source/adapters/level_zero/v2/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ struct ur_event_handle_t_ : _ur_object {
protected:
ur_context_handle_t hContext;

int constructed = 0;

// Pool is used iff this is a pooled event
v2::event_pool *event_pool = nullptr;
event_variant hZeEvent;
Expand Down

0 comments on commit 6d5ad1c

Please sign in to comment.