|
13 | 13 | #include <mutex>
|
14 | 14 | #include <string.h>
|
15 | 15 |
|
| 16 | +#include "command_buffer.hpp" |
16 | 17 | #include "common.hpp"
|
17 | 18 | #include "event.hpp"
|
18 | 19 | #include "ur_level_zero.hpp"
|
@@ -454,6 +455,17 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventGetProfilingInfo(
|
454 | 455 | ///< bytes returned in propValue
|
455 | 456 | ) {
|
456 | 457 | std::shared_lock<ur_shared_mutex> EventLock(Event->Mutex);
|
| 458 | + |
| 459 | + // A Command-buffer consists of three command-lists. |
| 460 | + // The start time should therefore be taken from an event associated |
| 461 | + // to the first command-list. |
| 462 | + if ((Event->CommandType == UR_COMMAND_COMMAND_BUFFER_ENQUEUE_EXP) && |
| 463 | + (PropName == UR_PROFILING_INFO_COMMAND_START) && (Event->CommandData)) { |
| 464 | + auto StartEvent = static_cast<ur_event_handle_t>(Event->CommandData); |
| 465 | + return urEventGetProfilingInfo(StartEvent, UR_PROFILING_INFO_COMMAND_END, |
| 466 | + PropValueSize, PropValue, PropValueSizeRet); |
| 467 | + } |
| 468 | + |
457 | 469 | if (Event->UrQueue &&
|
458 | 470 | (Event->UrQueue->Properties & UR_QUEUE_FLAG_PROFILING_ENABLE) == 0) {
|
459 | 471 | return UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE;
|
@@ -763,6 +775,13 @@ ur_result_t urEventReleaseInternal(ur_event_handle_t Event) {
|
763 | 775 | return Res;
|
764 | 776 | Event->CommandData = nullptr;
|
765 | 777 | }
|
| 778 | + if (Event->CommandType == UR_COMMAND_COMMAND_BUFFER_ENQUEUE_EXP && |
| 779 | + Event->CommandData) { |
| 780 | + // Free the memory extra event allocated for profiling purposed. |
| 781 | + auto AssociateEvent = static_cast<ur_event_handle_t>(Event->CommandData); |
| 782 | + urEventRelease(AssociateEvent); |
| 783 | + Event->CommandData = nullptr; |
| 784 | + } |
766 | 785 | if (Event->OwnNativeHandle) {
|
767 | 786 | if (DisableEventsCaching) {
|
768 | 787 | auto ZeResult = ZE_CALL_NOCHECK(zeEventDestroy, (Event->ZeEvent));
|
|
0 commit comments