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
2 changes: 1 addition & 1 deletion unified-runtime/source/adapters/level_zero/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ template <> ze_structure_type_t getZeStructureType<ze_driver_properties_t>() {
return ZE_STRUCTURE_TYPE_DRIVER_PROPERTIES;
}
template <> ze_structure_type_t getZeStructureType<ze_device_properties_t>() {
return ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES;
return ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES_1_2;
}
template <>
ze_structure_type_t getZeStructureType<ze_device_p2p_properties_t>() {
Expand Down
6 changes: 2 additions & 4 deletions unified-runtime/source/adapters/level_zero/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,7 @@ ur_result_t urDeviceGetInfo(
return ReturnValue(static_cast<ur_bool_t>(
Device->ZeDeviceProperties->flags & ZE_DEVICE_PROPERTY_FLAG_ECC));
case UR_DEVICE_INFO_PROFILING_TIMER_RESOLUTION:
return ReturnValue(
static_cast<size_t>(Device->ZeDeviceProperties->timerResolution));
return ReturnValue(static_cast<size_t>(Device->getTimerResolution()));
case UR_DEVICE_INFO_LOCAL_MEM_TYPE:
return ReturnValue(UR_DEVICE_LOCAL_MEM_TYPE_LOCAL);
case UR_DEVICE_INFO_MAX_CONSTANT_ARGS:
Expand Down Expand Up @@ -1772,8 +1771,7 @@ ur_result_t urDeviceGetGlobalTimestamps(
#endif
}

const uint64_t &ZeTimerResolution =
Device->ZeDeviceProperties->timerResolution;
const double ZeTimerResolution = Device->getTimerResolution();
const uint64_t TimestampMaxCount = Device->getTimestampMask();
uint64_t DeviceClockCount, Dummy;

Expand Down
7 changes: 7 additions & 0 deletions unified-runtime/source/adapters/level_zero/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ struct ur_device_handle_t_ : ur_object {
return ValidBits == 64 ? ~0ULL : (1ULL << ValidBits) - 1ULL;
}

// Get timer resolution in nanoseconds.
// With ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES_1_2, timerResolution is in
// cycles/sec, so we convert to nanoseconds.
double getTimerResolution() {
return 1000000000.0 / ZeDeviceProperties->timerResolution;
}

// Cache of the immutable device properties.
ZeCache<ZeStruct<ze_device_properties_t>> ZeDeviceProperties;
ZeCache<ZeStruct<ze_device_compute_properties_t>> ZeDeviceComputeProperties;
Expand Down
2 changes: 1 addition & 1 deletion unified-runtime/source/adapters/level_zero/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ ur_result_t urEventGetProfilingInfo(
ur_device_handle_t Device =
Event->UrQueue ? Event->UrQueue->Device : Event->Context->Devices[0];

uint64_t ZeTimerResolution = Device->ZeDeviceProperties->timerResolution;
const double ZeTimerResolution = Device->getTimerResolution();
const uint64_t TimestampMaxValue = Device->getTimestampMask();

UrReturnHelper ReturnValue(PropValueSize, PropValue, PropValueSizeRet);
Expand Down
2 changes: 1 addition & 1 deletion unified-runtime/source/adapters/level_zero/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,7 @@ ur_result_t ur_queue_handle_t_::active_barriers::clear() {
}

void ur_queue_handle_t_::clearEndTimeRecordings() {
uint64_t ZeTimerResolution = Device->ZeDeviceProperties->timerResolution;
const double ZeTimerResolution = Device->getTimerResolution();
const uint64_t TimestampMaxValue = Device->getTimestampMask();

for (auto Entry : EndTimeRecordings) {
Expand Down
6 changes: 3 additions & 3 deletions unified-runtime/source/adapters/level_zero/v2/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
static uint64_t adjustEndEventTimestamp(uint64_t adjustedStartTimestamp,
uint64_t endTimestamp,
uint64_t timestampMaxValue,
uint64_t timerResolution) {
double timerResolution) {
// End time needs to be adjusted for resolution and valid bits.
uint64_t adjustedTimestamp =
(endTimestamp & timestampMaxValue) * timerResolution;
Expand Down Expand Up @@ -78,7 +78,7 @@ void event_profiling_data_t::reset() {
}

void event_profiling_data_t::recordStartTimestamp(ur_device_handle_t hDevice) {
zeTimerResolution = hDevice->ZeDeviceProperties->timerResolution;
zeTimerResolution = hDevice->getTimerResolution();
timestampMaxValue = hDevice->getTimestampMask();

uint64_t deviceStartTimestamp = 0;
Expand Down Expand Up @@ -349,7 +349,7 @@ ur_result_t urEventGetProfilingInfo(

ze_kernel_timestamp_result_t tsResult;

auto zeTimerResolution = hDevice->ZeDeviceProperties->timerResolution;
auto zeTimerResolution = hDevice->getTimerResolution();
auto timestampMaxValue = hDevice->getTimestampMask();

switch (propName) {
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 @@ -48,7 +48,8 @@ struct event_profiling_data_t {
uint64_t recordEventEndTimestamp = 0;
uint64_t adjustedEventEndTimestamp = 0;

uint64_t zeTimerResolution = 0;
// Timer resolution in nanoseconds (converted from cycles/sec)
double zeTimerResolution = 0;
uint64_t timestampMaxValue = 0;

bool timestampRecorded = false;
Expand Down