Skip to content

[WIP][SYCL] update event profiling support with the new APIs. #2251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
29 changes: 15 additions & 14 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2359,29 +2359,30 @@ pi_result piEventGetProfilingInfo(pi_event Event, pi_profiling_info ParamName,
size_t *ParamValueSizeRet) {

assert(Event);
uint64_t ZeTimerResolution =
Event->Queue->Context->Device->ZeDeviceProperties.timerResolution;

ReturnHelper ReturnValue(ParamValueSize, ParamValue, ParamValueSizeRet);

switch (ParamName) {
case PI_PROFILING_INFO_COMMAND_START: {
uint64_t ContextStart;
ZE_CALL(zeEventGetTimestamp(
Event->ZeEvent, ZE_EVENT_TIMESTAMP_CONTEXT_START, &ContextStart));
ContextStart *= ZeTimerResolution;
return ReturnValue(uint64_t{ContextStart});
ze_kernel_timestamp_result_t* tsResult = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this not allocated memory?

ZE_CALL(zeCommandListAppendQueryKernelTimestamps(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec says https://spec.oneapi.com/level-zero/latest/core/api.html?highlight=zecommandlistappendquerykerneltimestamps#_CPPv440zeCommandListAppendQueryKernelTimestamps24ze_command_list_handle_t8uint32_tP17ze_event_handle_tPvPK6size_t17ze_event_handle_t8uint32_tP17ze_event_handle_t:

Appends a query of an events’ timestamp value(s) into a command list.

I don't see how this is going to achieve what's needed. It looks like these timestamp query should be appended around the command being profiled. Could you explain how this is working?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are requesting here in the host for the timestamp after execution has completed. We need to use zeEventQueryKernelTimestamp

Event->ZeCommandList, 1, &(Event->ZeEvent), tsResult, nullptr, nullptr,
1, &(Event->ZeEvent)));
return ReturnValue(*tsResult);
}
case PI_PROFILING_INFO_COMMAND_END: {
uint64_t ContextEnd;
ZE_CALL(zeEventGetTimestamp(Event->ZeEvent, ZE_EVENT_TIMESTAMP_CONTEXT_END,
&ContextEnd));
ContextEnd *= ZeTimerResolution;
return ReturnValue(uint64_t{ContextEnd});
ze_kernel_timestamp_result_t* tsResult = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be allocated, and different from the "start" memory, right?

ZE_CALL(zeCommandListAppendQueryKernelTimestamps(
Event->ZeCommandList, 1, &(Event->ZeEvent), tsResult, nullptr, nullptr,
1, &(Event->ZeEvent)));
return ReturnValue(*tsResult);
}
case PI_PROFILING_INFO_COMMAND_QUEUED:
case PI_PROFILING_INFO_COMMAND_SUBMIT:
// TODO: Support these when Level Zero supported is added.
return ReturnValue(uint64_t{0});
uint64_t *tsResult;
ZE_CALL(zeCommandListAppendWriteGlobalTimestamp(
Event->ZeCommandList, tsResult, nullptr, 1, &(Event->ZeEvent)));
return ReturnValue(*tsResult);
default:
zePrint("piEventGetProfilingInfo: not supported ParamName\n");
return PI_INVALID_VALUE;
Expand Down