Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions unified-runtime/source/adapters/level_zero/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ ur_result_t urEventGetProfilingInfo(
std::shared_lock<ur_shared_mutex> EventLock(Event->Mutex);

// The event must either have profiling enabled or be recording timestamps.
bool isTimestampedEvent = Event->isTimestamped();
bool isTimestampedEvent = Event->IsTimestamped;
if (!Event->isProfilingEnabled() && !isTimestampedEvent) {
return UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE;
}
Expand Down Expand Up @@ -764,6 +764,9 @@ ur_result_t urEnqueueTimestampRecordingExp(
Device, &DeviceStartTimestamp, nullptr));
(*OutEvent)->RecordEventStartTimestamp = DeviceStartTimestamp;

// Mark this event as timestamped
(*OutEvent)->IsTimestamped = true;

// Create a new entry in the queue's recordings.
Queue->EndTimeRecordings[*OutEvent] = 0;

Expand Down Expand Up @@ -1141,7 +1144,7 @@ ur_result_t urEventReleaseInternal(ur_event_handle_t Event,

// If the event was a timestamp recording, we try to evict its entry in the
// queue.
if (Event->isTimestamped()) {
if (Event->IsTimestamped) {
auto Entry = Queue->EndTimeRecordings.find(Event);
if (Entry != Queue->EndTimeRecordings.end()) {
auto &EndTimeRecording = Entry->second;
Expand Down Expand Up @@ -1435,6 +1438,7 @@ ur_result_t ur_event_handle_t_::reset() {
CommandList = std::nullopt;
completionBatch = std::nullopt;
OriginAllocEvent = nullptr;
IsTimestamped = false;

if (!isHostVisible())
HostVisibleEvent = nullptr;
Expand Down Expand Up @@ -1767,12 +1771,3 @@ bool ur_event_handle_t_::isProfilingEnabled() const {
return !UrQueue || // tentatively assume user events are profiling enabled
(UrQueue->Properties & UR_QUEUE_FLAG_PROFILING_ENABLE) != 0;
}

// Tells if this event was created as a timestamp event, allowing profiling
// info even if profiling is not enabled.
bool ur_event_handle_t_::isTimestamped() const {
// If we are recording, the start time of the event will be non-zero. The
// end time might still be missing, depending on whether the corresponding
// enqueue is still running.
return RecordEventStartTimestamp != 0;
}
7 changes: 3 additions & 4 deletions unified-runtime/source/adapters/level_zero/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ struct ur_event_handle_t_ : ur_object {
// plugin.
bool IsDiscarded = {false};

// Indicates that this is a timestamped event.
bool IsTimestamped = {false};

// Indicates that this event is needed to be visible by multiple devices.
// When possible, allocate Event from single device pool for optimal
// performance
Expand Down Expand Up @@ -246,10 +249,6 @@ struct ur_event_handle_t_ : ur_object {
// Tells if this event is with profiling capabilities.
bool isProfilingEnabled() const;

// Tells if this event was created as a timestamp event, allowing profiling
// info even if profiling is not enabled.
bool isTimestamped() const;

// Get the host-visible event or create one and enqueue its signal.
ur_result_t getOrCreateHostVisibleEvent(ze_event_handle_t &HostVisibleEvent);

Expand Down
8 changes: 3 additions & 5 deletions unified-runtime/source/adapters/level_zero/v2/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void event_profiling_data_t::reset() {
// possible.
adjustedEventStartTimestamp = 0;
adjustedEventEndTimestamp = 0;
timestampRecorded = false;
}

void event_profiling_data_t::recordStartTimestamp(ur_device_handle_t hDevice) {
Expand All @@ -85,18 +86,15 @@ void event_profiling_data_t::recordStartTimestamp(ur_device_handle_t hDevice) {

assert(adjustedEventStartTimestamp == 0);
adjustedEventStartTimestamp = deviceStartTimestamp;
timestampRecorded = true;
}

uint64_t event_profiling_data_t::getEventStartTimestmap() const {
return adjustedEventStartTimestamp;
}

bool event_profiling_data_t::recordingEnded() const {
return adjustedEventEndTimestamp != 0;
}

bool event_profiling_data_t::recordingStarted() const {
return adjustedEventStartTimestamp != 0;
return timestampRecorded;
}

uint64_t *event_profiling_data_t::eventEndTimestampAddr() {
Expand Down
3 changes: 2 additions & 1 deletion unified-runtime/source/adapters/level_zero/v2/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ struct event_profiling_data_t {
uint64_t *eventEndTimestampAddr();

bool recordingStarted() const;
bool recordingEnded() const;

// clear the profiling data, allowing the event to be reused
// for a new command
Expand All @@ -49,6 +48,8 @@ struct event_profiling_data_t {

uint64_t zeTimerResolution = 0;
uint64_t timestampMaxValue = 0;

bool timestampRecorded = false;
};

struct ur_event_handle_t_ : ur_object {
Expand Down