2020-03-06 11:09:57 +01:00
|
|
|
/*
|
2025-01-09 12:42:27 +00:00
|
|
|
* Copyright (C) 2020-2025 Intel Corporation
|
2020-03-06 11:09:57 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2024-04-25 17:45:21 +00:00
|
|
|
#include "shared/source/helpers/common_types.h"
|
2025-01-09 15:34:25 +00:00
|
|
|
#include "shared/source/helpers/constants.h"
|
2025-01-20 11:25:34 +00:00
|
|
|
#include "shared/source/helpers/ptr_math.h"
|
2023-05-30 09:12:10 +00:00
|
|
|
#include "shared/source/helpers/timestamp_packet_constants.h"
|
2023-05-24 15:23:48 +00:00
|
|
|
#include "shared/source/helpers/timestamp_packet_container.h"
|
2023-01-19 12:57:43 +00:00
|
|
|
#include "shared/source/memory_manager/multi_graphics_allocation.h"
|
2023-06-09 15:07:24 +00:00
|
|
|
#include "shared/source/os_interface/os_time.h"
|
2025-04-01 19:52:25 +00:00
|
|
|
#include "shared/source/utilities/timestamp_pool_allocator.h"
|
2020-09-15 09:33:12 +02:00
|
|
|
|
2024-08-28 12:23:22 +00:00
|
|
|
#include "level_zero/core/source/helpers/api_handle_helper.h"
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2023-01-19 12:57:43 +00:00
|
|
|
#include <atomic>
|
2022-05-21 18:53:47 +00:00
|
|
|
#include <bitset>
|
2023-01-19 12:57:43 +00:00
|
|
|
#include <chrono>
|
2021-12-03 19:46:19 +00:00
|
|
|
#include <limits>
|
2023-01-19 12:57:43 +00:00
|
|
|
#include <memory>
|
2023-08-25 18:23:19 +00:00
|
|
|
#include <mutex>
|
2023-01-19 12:57:43 +00:00
|
|
|
#include <vector>
|
2021-12-03 19:46:19 +00:00
|
|
|
|
2025-03-28 09:32:57 +00:00
|
|
|
struct _ze_event_handle_t : BaseHandleWithLoaderTranslation<ZEL_HANDLE_EVENT> {};
|
|
|
|
|
static_assert(IsCompliantWithDdiHandlesExt<_ze_event_handle_t>);
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2025-03-28 09:32:57 +00:00
|
|
|
struct _ze_event_pool_handle_t : BaseHandle {};
|
|
|
|
|
static_assert(IsCompliantWithDdiHandlesExt<_ze_event_pool_handle_t>);
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2022-12-20 04:30:24 +00:00
|
|
|
namespace NEO {
|
2023-01-19 12:57:43 +00:00
|
|
|
class CommandStreamReceiver;
|
|
|
|
|
class GraphicsAllocation;
|
|
|
|
|
class MultiGraphicsAllocation;
|
2022-12-20 04:30:24 +00:00
|
|
|
struct RootDeviceEnvironment;
|
2023-12-11 12:10:56 +00:00
|
|
|
class InOrderExecInfo;
|
2023-01-19 12:57:43 +00:00
|
|
|
} // namespace NEO
|
2022-12-20 04:30:24 +00:00
|
|
|
|
2020-03-06 11:09:57 +01:00
|
|
|
namespace L0 {
|
|
|
|
|
typedef uint64_t FlushStamp;
|
|
|
|
|
struct EventPool;
|
2023-12-06 14:48:12 +00:00
|
|
|
struct MetricCollectorEventNotify;
|
2022-06-03 08:50:35 +00:00
|
|
|
struct ContextImp;
|
|
|
|
|
struct Context;
|
2023-06-22 16:38:44 +00:00
|
|
|
struct CommandQueue;
|
2022-06-03 08:50:35 +00:00
|
|
|
struct DriverHandle;
|
2022-10-27 11:40:44 +00:00
|
|
|
struct DriverHandleImp;
|
2022-06-03 08:50:35 +00:00
|
|
|
struct Device;
|
2023-02-21 23:17:05 +00:00
|
|
|
struct Kernel;
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2023-01-16 16:53:05 +00:00
|
|
|
#pragma pack(1)
|
|
|
|
|
struct IpcEventPoolData {
|
|
|
|
|
uint64_t handle = 0;
|
|
|
|
|
size_t numEvents = 0;
|
|
|
|
|
uint32_t rootDeviceIndex = 0;
|
2023-01-18 12:06:03 +00:00
|
|
|
uint32_t maxEventPackets = 0;
|
2023-02-08 02:24:29 +00:00
|
|
|
uint32_t numDevices = 0;
|
2023-01-16 16:53:05 +00:00
|
|
|
bool isDeviceEventPoolAllocation = false;
|
|
|
|
|
bool isHostVisibleEventPoolAllocation = false;
|
2023-03-24 21:26:48 +00:00
|
|
|
bool isImplicitScalingCapable = false;
|
2025-01-20 11:25:34 +00:00
|
|
|
bool isEventPoolKernelMappedTsFlagSet = false;
|
2023-01-16 16:53:05 +00:00
|
|
|
};
|
2024-10-15 16:32:10 +00:00
|
|
|
|
|
|
|
|
struct IpcCounterBasedEventData {
|
|
|
|
|
uint64_t deviceHandle = 0;
|
|
|
|
|
uint64_t hostHandle = 0;
|
|
|
|
|
uint64_t counterValue = 0;
|
|
|
|
|
uint32_t rootDeviceIndex = 0;
|
|
|
|
|
uint32_t counterOffset = 0;
|
|
|
|
|
uint32_t devicePartitions = 0;
|
|
|
|
|
uint32_t hostPartitions = 0;
|
|
|
|
|
uint32_t counterBasedFlags = 0;
|
|
|
|
|
uint32_t signalScopeFlags = 0;
|
|
|
|
|
uint32_t waitScopeFlags = 0;
|
|
|
|
|
};
|
2023-01-16 16:53:05 +00:00
|
|
|
#pragma pack()
|
|
|
|
|
static_assert(sizeof(IpcEventPoolData) <= ZE_MAX_IPC_HANDLE_SIZE, "IpcEventPoolData is bigger than ZE_MAX_IPC_HANDLE_SIZE");
|
2024-10-15 16:32:10 +00:00
|
|
|
static_assert(sizeof(IpcCounterBasedEventData) <= ZE_MAX_IPC_HANDLE_SIZE, "IpcCounterBasedEventData is bigger than ZE_MAX_IPC_HANDLE_SIZE");
|
2023-01-16 16:53:05 +00:00
|
|
|
|
2021-04-14 18:13:17 +00:00
|
|
|
namespace EventPacketsCount {
|
2022-12-08 14:23:49 +00:00
|
|
|
inline constexpr uint32_t maxKernelSplit = 3;
|
2023-05-30 09:12:10 +00:00
|
|
|
inline constexpr uint32_t eventPackets = maxKernelSplit * NEO ::TimestampPacketConstants::preferredPacketCount;
|
2021-04-14 18:13:17 +00:00
|
|
|
} // namespace EventPacketsCount
|
|
|
|
|
|
2024-01-11 17:18:16 +00:00
|
|
|
struct EventDescriptor {
|
|
|
|
|
NEO::MultiGraphicsAllocation *eventPoolAllocation = nullptr;
|
2024-11-06 11:23:46 +00:00
|
|
|
const void *extensions = nullptr;
|
2025-04-01 19:52:25 +00:00
|
|
|
size_t offsetInSharedAlloc = 0;
|
2024-01-11 17:18:16 +00:00
|
|
|
uint32_t totalEventSize = 0;
|
|
|
|
|
uint32_t maxKernelCount = 0;
|
|
|
|
|
uint32_t maxPacketsCount = 0;
|
|
|
|
|
uint32_t counterBasedFlags = 0;
|
2024-11-06 11:23:46 +00:00
|
|
|
uint32_t index = 0;
|
|
|
|
|
uint32_t signalScope = 0;
|
|
|
|
|
uint32_t waitScope = 0;
|
2024-01-11 17:18:16 +00:00
|
|
|
bool timestampPool = false;
|
2025-01-20 11:25:34 +00:00
|
|
|
bool kernelMappedTsPoolFlag = false;
|
2024-01-11 17:18:16 +00:00
|
|
|
bool importedIpcPool = false;
|
|
|
|
|
bool ipcPool = false;
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-06 11:09:57 +01:00
|
|
|
struct Event : _ze_event_handle_t {
|
2024-08-06 10:59:07 +00:00
|
|
|
virtual ~Event() = default;
|
2020-03-06 11:09:57 +01:00
|
|
|
virtual ze_result_t destroy();
|
2024-05-10 09:22:13 +00:00
|
|
|
virtual ze_result_t hostSignal(bool allowCounterBased) = 0;
|
2020-07-29 02:45:54 -07:00
|
|
|
virtual ze_result_t hostSynchronize(uint64_t timeout) = 0;
|
2020-03-06 11:09:57 +01:00
|
|
|
virtual ze_result_t queryStatus() = 0;
|
|
|
|
|
virtual ze_result_t reset() = 0;
|
2020-07-29 14:25:20 +02:00
|
|
|
virtual ze_result_t queryKernelTimestamp(ze_kernel_timestamp_result_t *dstptr) = 0;
|
2023-01-16 17:12:02 +00:00
|
|
|
virtual ze_result_t queryTimestampsExp(Device *device, uint32_t *count, ze_kernel_timestamp_result_t *timestamps) = 0;
|
2023-06-09 15:07:24 +00:00
|
|
|
virtual ze_result_t queryKernelTimestampsExt(Device *device, uint32_t *pCount, ze_event_query_kernel_timestamps_results_ext_properties_t *pResults) = 0;
|
2024-02-07 00:42:24 +00:00
|
|
|
virtual ze_result_t getEventPool(ze_event_pool_handle_t *phEventPool) = 0;
|
|
|
|
|
virtual ze_result_t getSignalScope(ze_event_scope_flags_t *pSignalScope) = 0;
|
|
|
|
|
virtual ze_result_t getWaitScope(ze_event_scope_flags_t *pWaitScope) = 0;
|
2023-06-09 15:07:24 +00:00
|
|
|
|
2020-04-08 12:44:14 -07:00
|
|
|
enum State : uint32_t {
|
2024-02-22 14:16:24 +00:00
|
|
|
STATE_SIGNALED = 2u,
|
2022-12-07 15:49:14 +00:00
|
|
|
HOST_CACHING_DISABLED_PERMANENT = std::numeric_limits<uint32_t>::max() - 2,
|
2022-11-22 15:12:44 +00:00
|
|
|
HOST_CACHING_DISABLED = std::numeric_limits<uint32_t>::max() - 1,
|
2021-12-03 19:46:19 +00:00
|
|
|
STATE_CLEARED = std::numeric_limits<uint32_t>::max(),
|
2020-03-06 11:09:57 +01:00
|
|
|
STATE_INITIAL = STATE_CLEARED
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-06 14:48:24 +00:00
|
|
|
enum class CounterBasedMode : uint32_t {
|
|
|
|
|
// For default flow (API)
|
2023-12-19 10:42:58 +00:00
|
|
|
initiallyDisabled,
|
|
|
|
|
explicitlyEnabled,
|
2023-11-06 14:48:24 +00:00
|
|
|
// For internal convertion (Immediate CL)
|
2023-12-19 10:42:58 +00:00
|
|
|
implicitlyEnabled,
|
|
|
|
|
implicitlyDisabled
|
2023-11-06 14:48:24 +00:00
|
|
|
};
|
|
|
|
|
|
2021-05-18 11:31:17 +00:00
|
|
|
template <typename TagSizeT>
|
2020-03-06 11:09:57 +01:00
|
|
|
static Event *create(EventPool *eventPool, const ze_event_desc_t *desc, Device *device);
|
|
|
|
|
|
2024-01-11 17:18:16 +00:00
|
|
|
template <typename TagSizeT>
|
2024-11-06 11:23:46 +00:00
|
|
|
static Event *create(const EventDescriptor &eventDescriptor, Device *device, ze_result_t &result);
|
2024-01-11 17:18:16 +00:00
|
|
|
|
2020-03-06 11:09:57 +01:00
|
|
|
static Event *fromHandle(ze_event_handle_t handle) { return static_cast<Event *>(handle); }
|
|
|
|
|
|
2024-10-15 16:32:10 +00:00
|
|
|
static ze_result_t openCounterBasedIpcHandle(const IpcCounterBasedEventData &ipcData, ze_event_handle_t *eventHandle,
|
|
|
|
|
DriverHandleImp *driver, ContextImp *context, uint32_t numDevices, ze_device_handle_t *deviceHandles);
|
|
|
|
|
|
|
|
|
|
ze_result_t getCounterBasedIpcHandle(IpcCounterBasedEventData &ipcData);
|
|
|
|
|
|
2020-03-06 11:09:57 +01:00
|
|
|
inline ze_event_handle_t toHandle() { return this; }
|
|
|
|
|
|
2024-09-20 12:30:17 +00:00
|
|
|
MOCKABLE_VIRTUAL NEO::GraphicsAllocation *getAllocation(Device *device) const;
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2024-02-07 00:42:24 +00:00
|
|
|
void setEventPool(EventPool *eventPool) { this->eventPool = eventPool; }
|
2024-06-27 15:27:00 +00:00
|
|
|
EventPool *peekEventPool() { return this->eventPool; }
|
2024-02-07 00:42:24 +00:00
|
|
|
|
2023-01-12 09:24:14 +00:00
|
|
|
MOCKABLE_VIRTUAL uint64_t getGpuAddress(Device *device) const;
|
2022-10-27 11:40:44 +00:00
|
|
|
virtual uint32_t getPacketsInUse() const = 0;
|
2022-04-17 01:13:30 +00:00
|
|
|
virtual uint32_t getPacketsUsedInLastKernel() = 0;
|
2021-05-18 11:31:17 +00:00
|
|
|
virtual uint64_t getPacketAddress(Device *device) = 0;
|
2023-01-12 09:24:14 +00:00
|
|
|
MOCKABLE_VIRTUAL void resetPackets(bool resetAllPackets);
|
2022-10-27 22:14:39 +00:00
|
|
|
virtual void resetKernelCountAndPacketUsedCount() = 0;
|
2024-09-23 13:25:40 +00:00
|
|
|
void *getHostAddress() const;
|
2021-05-18 11:31:17 +00:00
|
|
|
virtual void setPacketsInUse(uint32_t value) = 0;
|
2021-04-14 18:13:17 +00:00
|
|
|
uint32_t getCurrKernelDataIndex() const { return kernelCount - 1; }
|
2023-01-12 09:24:14 +00:00
|
|
|
MOCKABLE_VIRTUAL void setGpuStartTimestamp();
|
|
|
|
|
MOCKABLE_VIRTUAL void setGpuEndTimestamp();
|
|
|
|
|
size_t getCompletionFieldOffset() const {
|
2023-01-11 18:16:20 +00:00
|
|
|
return this->isUsingContextEndOffset() ? this->getContextEndOffset() : 0;
|
|
|
|
|
}
|
2023-01-12 09:24:14 +00:00
|
|
|
uint64_t getCompletionFieldGpuAddress(Device *device) const {
|
2023-01-11 18:16:20 +00:00
|
|
|
return this->getGpuAddress(device) + getCompletionFieldOffset();
|
|
|
|
|
}
|
2023-01-19 12:57:43 +00:00
|
|
|
void *getCompletionFieldHostAddress() const;
|
2021-12-08 11:12:14 +00:00
|
|
|
size_t getContextStartOffset() const {
|
|
|
|
|
return contextStartOffset;
|
|
|
|
|
}
|
|
|
|
|
size_t getContextEndOffset() const {
|
|
|
|
|
return contextEndOffset;
|
|
|
|
|
}
|
|
|
|
|
size_t getGlobalStartOffset() const {
|
|
|
|
|
return globalStartOffset;
|
|
|
|
|
}
|
|
|
|
|
size_t getGlobalEndOffset() const {
|
|
|
|
|
return globalEndOffset;
|
|
|
|
|
}
|
|
|
|
|
size_t getSinglePacketSize() const {
|
|
|
|
|
return singlePacketSize;
|
|
|
|
|
}
|
2023-06-07 15:06:16 +00:00
|
|
|
void setSinglePacketSize(size_t size) {
|
|
|
|
|
singlePacketSize = size;
|
|
|
|
|
}
|
2021-12-08 11:12:14 +00:00
|
|
|
size_t getTimestampSizeInDw() const {
|
|
|
|
|
return timestampSizeInDw;
|
|
|
|
|
}
|
|
|
|
|
void setEventTimestampFlag(bool timestampFlag) {
|
|
|
|
|
isTimestampEvent = timestampFlag;
|
|
|
|
|
}
|
2022-03-29 14:46:15 +00:00
|
|
|
bool isEventTimestampFlagSet() const {
|
|
|
|
|
return isTimestampEvent;
|
|
|
|
|
}
|
2022-04-04 19:07:08 +00:00
|
|
|
void setUsingContextEndOffset(bool usingContextEndOffset) {
|
|
|
|
|
this->usingContextEndOffset = usingContextEndOffset;
|
2022-03-29 14:46:15 +00:00
|
|
|
}
|
2022-04-04 19:07:08 +00:00
|
|
|
bool isUsingContextEndOffset() const {
|
|
|
|
|
return isTimestampEvent || usingContextEndOffset;
|
2022-03-29 14:46:15 +00:00
|
|
|
}
|
2023-07-21 15:27:34 +00:00
|
|
|
void setCsr(NEO::CommandStreamReceiver *csr, bool clearPreviousCsrs) {
|
|
|
|
|
if (clearPreviousCsrs) {
|
|
|
|
|
this->csrs.clear();
|
|
|
|
|
this->csrs.resize(1);
|
|
|
|
|
}
|
2023-04-27 14:11:10 +00:00
|
|
|
this->csrs[0] = csr;
|
|
|
|
|
}
|
|
|
|
|
void appendAdditionalCsr(NEO::CommandStreamReceiver *additonalCsr) {
|
|
|
|
|
for (const auto &csr : csrs) {
|
|
|
|
|
if (csr == additonalCsr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
csrs.push_back(additonalCsr);
|
2022-09-29 17:12:22 +00:00
|
|
|
}
|
2021-12-08 11:12:14 +00:00
|
|
|
|
2023-01-19 12:57:43 +00:00
|
|
|
void increaseKernelCount();
|
2022-04-08 18:48:45 +00:00
|
|
|
uint32_t getKernelCount() const {
|
|
|
|
|
return kernelCount;
|
|
|
|
|
}
|
|
|
|
|
void zeroKernelCount() {
|
|
|
|
|
kernelCount = 0;
|
|
|
|
|
}
|
2024-02-26 17:44:07 +00:00
|
|
|
void setKernelCount(uint32_t newKernelCount) {
|
|
|
|
|
kernelCount = newKernelCount;
|
|
|
|
|
}
|
2022-05-21 18:53:47 +00:00
|
|
|
bool getL3FlushForCurrenKernel() {
|
|
|
|
|
return l3FlushAppliedOnKernel.test(kernelCount - 1);
|
|
|
|
|
}
|
|
|
|
|
void setL3FlushForCurrentKernel() {
|
|
|
|
|
l3FlushAppliedOnKernel.set(kernelCount - 1);
|
|
|
|
|
}
|
2022-04-08 18:48:45 +00:00
|
|
|
|
2022-12-07 15:49:14 +00:00
|
|
|
void resetCompletionStatus() {
|
|
|
|
|
if (this->isCompleted.load() != HOST_CACHING_DISABLED_PERMANENT) {
|
|
|
|
|
this->isCompleted.store(STATE_CLEARED);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void disableHostCaching(bool disableFromRegularList) {
|
|
|
|
|
this->isCompleted.store(disableFromRegularList ? HOST_CACHING_DISABLED_PERMANENT : HOST_CACHING_DISABLED);
|
2022-11-22 15:12:44 +00:00
|
|
|
}
|
|
|
|
|
|
2023-04-26 16:43:07 +00:00
|
|
|
void setIsCompleted();
|
2022-11-22 15:12:44 +00:00
|
|
|
|
|
|
|
|
bool isAlreadyCompleted() {
|
|
|
|
|
return this->isCompleted == STATE_SIGNALED;
|
2022-09-12 13:37:02 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-27 11:40:44 +00:00
|
|
|
uint32_t getMaxPacketsCount() const {
|
|
|
|
|
return maxPacketCount;
|
|
|
|
|
}
|
|
|
|
|
void setMaxKernelCount(uint32_t value) {
|
|
|
|
|
maxKernelCount = value;
|
|
|
|
|
}
|
|
|
|
|
uint32_t getMaxKernelCount() const {
|
|
|
|
|
return maxKernelCount;
|
|
|
|
|
}
|
2023-08-25 18:23:19 +00:00
|
|
|
void setKernelForPrintf(std::weak_ptr<Kernel> inputKernelWeakPtr) {
|
|
|
|
|
kernelWithPrintf = inputKernelWeakPtr;
|
2023-02-21 23:17:05 +00:00
|
|
|
}
|
2023-08-25 18:23:19 +00:00
|
|
|
std::weak_ptr<Kernel> getKernelForPrintf() {
|
2023-02-21 23:17:05 +00:00
|
|
|
return kernelWithPrintf;
|
|
|
|
|
}
|
2023-08-25 18:23:19 +00:00
|
|
|
void resetKernelForPrintf() {
|
|
|
|
|
kernelWithPrintf.reset();
|
|
|
|
|
}
|
|
|
|
|
void setKernelWithPrintfDeviceMutex(std::mutex *mutexPtr) {
|
|
|
|
|
kernelWithPrintfDeviceMutex = mutexPtr;
|
|
|
|
|
}
|
|
|
|
|
std::mutex *getKernelWithPrintfDeviceMutex() {
|
|
|
|
|
return kernelWithPrintfDeviceMutex;
|
|
|
|
|
}
|
|
|
|
|
void resetKernelWithPrintfDeviceMutex() {
|
|
|
|
|
kernelWithPrintfDeviceMutex = nullptr;
|
|
|
|
|
}
|
2022-10-27 11:40:44 +00:00
|
|
|
|
2023-01-19 18:33:55 +00:00
|
|
|
bool isSignalScope() const {
|
|
|
|
|
return !!signalScope;
|
|
|
|
|
}
|
|
|
|
|
bool isSignalScope(ze_event_scope_flags_t flag) const {
|
|
|
|
|
return !!(signalScope & flag);
|
|
|
|
|
}
|
|
|
|
|
bool isWaitScope() const {
|
|
|
|
|
return !!waitScope;
|
|
|
|
|
}
|
2023-12-06 14:48:12 +00:00
|
|
|
void setMetricNotification(MetricCollectorEventNotify *metricNotification) {
|
|
|
|
|
this->metricNotification = metricNotification;
|
2023-01-19 18:33:55 +00:00
|
|
|
}
|
2023-12-11 12:10:56 +00:00
|
|
|
void updateInOrderExecState(std::shared_ptr<NEO::InOrderExecInfo> &newInOrderExecInfo, uint64_t signalValue, uint32_t allocationOffset);
|
2023-12-19 10:42:58 +00:00
|
|
|
bool isCounterBased() const { return ((counterBasedMode == CounterBasedMode::explicitlyEnabled) || (counterBasedMode == CounterBasedMode::implicitlyEnabled)); }
|
|
|
|
|
bool isCounterBasedExplicitlyEnabled() const { return (counterBasedMode == CounterBasedMode::explicitlyEnabled); }
|
2024-01-03 08:55:03 +00:00
|
|
|
void enableCounterBasedMode(bool apiRequest, uint32_t flags);
|
2023-11-06 14:48:24 +00:00
|
|
|
void disableImplicitCounterBasedMode();
|
2023-10-03 09:34:45 +00:00
|
|
|
uint64_t getInOrderExecSignalValueWithSubmissionCounter() const;
|
|
|
|
|
uint64_t getInOrderExecBaseSignalValue() const { return inOrderExecSignalValue; }
|
2023-07-04 10:43:51 +00:00
|
|
|
uint32_t getInOrderAllocationOffset() const { return inOrderAllocationOffset; }
|
2025-02-07 14:50:28 +00:00
|
|
|
uint64_t getInOrderIncrementValue() const { return inOrderIncrementValue; }
|
2023-06-22 16:38:44 +00:00
|
|
|
void setLatestUsedCmdQueue(CommandQueue *newCmdQ);
|
2023-07-06 08:35:07 +00:00
|
|
|
NEO::TimeStampData *peekReferenceTs() {
|
2025-01-20 11:25:34 +00:00
|
|
|
return static_cast<NEO::TimeStampData *>(ptrOffset(getHostAddress(), getMaxPacketsCount() * getSinglePacketSize()));
|
2023-06-09 15:07:24 +00:00
|
|
|
}
|
2023-07-06 08:35:07 +00:00
|
|
|
void setReferenceTs(uint64_t currentCpuTimeStamp);
|
2023-10-02 09:09:37 +00:00
|
|
|
const CommandQueue *getLatestUsedCmdQueue() const { return latestUsedCmdQueue; }
|
2025-01-20 11:25:34 +00:00
|
|
|
bool hasKernelMappedTsCapability = false;
|
2023-12-11 12:10:56 +00:00
|
|
|
std::shared_ptr<NEO::InOrderExecInfo> &getInOrderExecInfo() { return inOrderExecInfo; }
|
2023-11-22 15:11:49 +00:00
|
|
|
void enableKmdWaitMode() { kmdWaitMode = true; }
|
2023-12-11 17:19:26 +00:00
|
|
|
void enableInterruptMode() { interruptMode = true; }
|
2023-11-22 15:11:49 +00:00
|
|
|
bool isKmdWaitModeEnabled() const { return kmdWaitMode; }
|
2023-12-11 17:19:26 +00:00
|
|
|
bool isInterruptModeEnabled() const { return interruptMode; }
|
2023-11-28 18:07:06 +00:00
|
|
|
void unsetInOrderExecInfo();
|
2024-01-04 08:04:27 +00:00
|
|
|
uint32_t getCounterBasedFlags() const { return counterBasedFlags; }
|
2023-04-26 11:48:10 +00:00
|
|
|
|
2024-02-28 15:31:47 +00:00
|
|
|
uint32_t getPacketsToWait() const {
|
|
|
|
|
return this->signalAllEventPackets ? getMaxPacketsCount() : getPacketsInUse();
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-17 12:02:39 +00:00
|
|
|
void setExternalInterruptId(uint32_t interruptId) { externalInterruptId = interruptId; }
|
|
|
|
|
|
2025-02-20 14:09:17 +00:00
|
|
|
void resetInOrderTimestampNode(NEO::TagNodeBase *newNode, uint32_t partitionCount);
|
2024-07-19 15:15:04 +00:00
|
|
|
|
2025-02-18 08:35:02 +00:00
|
|
|
bool hasInOrderTimestampNode() const { return !inOrderTimestampNode.empty(); }
|
2024-09-26 15:22:08 +00:00
|
|
|
|
2024-10-25 11:54:02 +00:00
|
|
|
bool isIpcImported() const { return isFromIpcPool; }
|
|
|
|
|
|
2024-12-24 10:50:33 +00:00
|
|
|
void setMitigateHostVisibleSignal() {
|
|
|
|
|
this->mitigateHostVisibleSignal = true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-11 10:34:14 +00:00
|
|
|
virtual ze_result_t hostEventSetValue(State eventState) = 0;
|
|
|
|
|
|
2025-04-01 19:52:25 +00:00
|
|
|
size_t getOffsetInSharedAlloc() const { return offsetInSharedAlloc; }
|
|
|
|
|
|
2023-01-19 18:33:55 +00:00
|
|
|
protected:
|
2024-01-11 17:18:16 +00:00
|
|
|
Event(int index, Device *device) : device(device), index(index) {}
|
2023-01-19 18:33:55 +00:00
|
|
|
|
2024-11-06 11:23:46 +00:00
|
|
|
ze_result_t enableExtensions(const EventDescriptor &eventDescriptor);
|
2025-02-07 15:37:04 +00:00
|
|
|
NEO::GraphicsAllocation *getExternalCounterAllocationFromAddress(uint64_t *address) const;
|
2024-11-06 11:23:46 +00:00
|
|
|
|
2023-08-29 20:31:16 +00:00
|
|
|
void unsetCmdQueue();
|
2024-10-02 11:47:19 +00:00
|
|
|
void releaseTempInOrderTimestampNodes();
|
2025-02-20 14:09:17 +00:00
|
|
|
virtual void clearLatestInOrderTimestampData(uint32_t partitionCount) = 0;
|
2023-06-22 16:38:44 +00:00
|
|
|
|
2024-02-07 00:42:24 +00:00
|
|
|
EventPool *eventPool = nullptr;
|
|
|
|
|
|
2023-01-12 14:21:51 +00:00
|
|
|
uint64_t globalStartTS = 1;
|
|
|
|
|
uint64_t globalEndTS = 1;
|
|
|
|
|
uint64_t contextStartTS = 1;
|
|
|
|
|
uint64_t contextEndTS = 1;
|
2021-06-09 20:15:59 +00:00
|
|
|
|
2023-09-19 11:40:49 +00:00
|
|
|
uint64_t inOrderExecSignalValue = 0;
|
2025-02-07 14:50:28 +00:00
|
|
|
uint64_t inOrderIncrementValue = 0;
|
2023-07-04 10:43:51 +00:00
|
|
|
uint32_t inOrderAllocationOffset = 0;
|
2023-06-07 18:44:13 +00:00
|
|
|
|
2025-01-09 15:34:25 +00:00
|
|
|
std::chrono::microseconds gpuHangCheckPeriod{CommonConstants::gpuHangCheckTimeInUS};
|
2022-05-21 18:53:47 +00:00
|
|
|
std::bitset<EventPacketsCount::maxKernelSplit> l3FlushAppliedOnKernel;
|
|
|
|
|
|
2021-12-08 11:12:14 +00:00
|
|
|
size_t contextStartOffset = 0u;
|
|
|
|
|
size_t contextEndOffset = 0u;
|
|
|
|
|
size_t globalStartOffset = 0u;
|
|
|
|
|
size_t globalEndOffset = 0u;
|
|
|
|
|
size_t timestampSizeInDw = 0u;
|
|
|
|
|
size_t singlePacketSize = 0u;
|
2022-04-04 19:07:08 +00:00
|
|
|
size_t eventPoolOffset = 0u;
|
2025-04-01 19:52:25 +00:00
|
|
|
size_t offsetInSharedAlloc = 0u;
|
2022-04-08 18:48:45 +00:00
|
|
|
|
2022-09-20 09:32:33 +00:00
|
|
|
size_t cpuStartTimestamp = 0u;
|
|
|
|
|
size_t gpuStartTimestamp = 0u;
|
|
|
|
|
size_t gpuEndTimestamp = 0u;
|
|
|
|
|
|
2023-12-06 14:48:12 +00:00
|
|
|
// Metric instance associated with the event.
|
|
|
|
|
MetricCollectorEventNotify *metricNotification = nullptr;
|
2024-01-11 17:18:16 +00:00
|
|
|
NEO::MultiGraphicsAllocation *eventPoolAllocation = nullptr;
|
2023-04-27 14:11:10 +00:00
|
|
|
StackVec<NEO::CommandStreamReceiver *, 1> csrs;
|
2024-09-23 13:25:40 +00:00
|
|
|
void *hostAddressFromPool = nullptr;
|
2023-01-19 18:33:55 +00:00
|
|
|
Device *device = nullptr;
|
2023-08-25 18:23:19 +00:00
|
|
|
std::weak_ptr<Kernel> kernelWithPrintf = std::weak_ptr<Kernel>{};
|
|
|
|
|
std::mutex *kernelWithPrintfDeviceMutex = nullptr;
|
2023-12-11 12:10:56 +00:00
|
|
|
std::shared_ptr<NEO::InOrderExecInfo> inOrderExecInfo;
|
2023-06-22 16:38:44 +00:00
|
|
|
CommandQueue *latestUsedCmdQueue = nullptr;
|
2025-02-18 08:35:02 +00:00
|
|
|
std::vector<NEO::TagNodeBase *> inOrderTimestampNode;
|
2023-01-19 18:33:55 +00:00
|
|
|
|
2022-10-27 11:40:44 +00:00
|
|
|
uint32_t maxKernelCount = 0;
|
2022-04-08 18:48:45 +00:00
|
|
|
uint32_t kernelCount = 1u;
|
2022-10-27 11:40:44 +00:00
|
|
|
uint32_t maxPacketCount = 0;
|
2022-10-27 11:40:44 +00:00
|
|
|
uint32_t totalEventSize = 0;
|
2024-01-03 08:55:03 +00:00
|
|
|
uint32_t counterBasedFlags = 0;
|
2024-04-25 17:45:21 +00:00
|
|
|
uint32_t externalInterruptId = NEO::InterruptId::notUsed;
|
2024-04-17 12:02:39 +00:00
|
|
|
|
2023-12-19 10:42:58 +00:00
|
|
|
CounterBasedMode counterBasedMode = CounterBasedMode::initiallyDisabled;
|
2022-04-08 18:48:45 +00:00
|
|
|
|
2023-01-19 18:33:55 +00:00
|
|
|
ze_event_scope_flags_t signalScope = 0u;
|
|
|
|
|
ze_event_scope_flags_t waitScope = 0u;
|
|
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
2023-01-12 14:21:51 +00:00
|
|
|
std::atomic<State> isCompleted{STATE_INITIAL};
|
|
|
|
|
|
2021-06-09 20:15:59 +00:00
|
|
|
bool isTimestampEvent = false;
|
2022-04-04 19:07:08 +00:00
|
|
|
bool usingContextEndOffset = false;
|
2022-10-27 11:40:44 +00:00
|
|
|
bool signalAllEventPackets = false;
|
2023-01-17 12:40:06 +00:00
|
|
|
bool isFromIpcPool = false;
|
2023-11-22 15:11:49 +00:00
|
|
|
bool kmdWaitMode = false;
|
2023-12-11 17:19:26 +00:00
|
|
|
bool interruptMode = false;
|
2025-01-09 12:42:27 +00:00
|
|
|
bool isSharableCounterBased = false;
|
2024-12-24 10:50:33 +00:00
|
|
|
bool mitigateHostVisibleSignal = false;
|
2023-07-06 08:35:07 +00:00
|
|
|
uint64_t timestampRefreshIntervalInNanoSec = 0;
|
2020-03-06 11:09:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct EventPool : _ze_event_pool_handle_t {
|
2023-01-16 17:12:02 +00:00
|
|
|
static EventPool *create(DriverHandle *driver, Context *context, uint32_t numDevices, ze_device_handle_t *deviceHandles, const ze_event_pool_desc_t *desc, ze_result_t &result);
|
2023-01-19 18:33:55 +00:00
|
|
|
static ze_result_t openEventPoolIpcHandle(const ze_ipc_event_pool_handle_t &ipcEventPoolHandle, ze_event_pool_handle_t *eventPoolHandle,
|
|
|
|
|
DriverHandleImp *driver, ContextImp *context, uint32_t numDevices, ze_device_handle_t *deviceHandles);
|
2023-01-16 17:12:02 +00:00
|
|
|
EventPool(const ze_event_pool_desc_t *desc) : EventPool(desc->count) {
|
2023-10-31 17:56:27 +00:00
|
|
|
setupDescriptorFlags(desc);
|
2023-01-16 17:12:02 +00:00
|
|
|
}
|
|
|
|
|
virtual ~EventPool();
|
|
|
|
|
MOCKABLE_VIRTUAL ze_result_t destroy();
|
|
|
|
|
MOCKABLE_VIRTUAL ze_result_t getIpcHandle(ze_ipc_event_pool_handle_t *ipcHandle);
|
|
|
|
|
MOCKABLE_VIRTUAL ze_result_t closeIpcHandle();
|
|
|
|
|
MOCKABLE_VIRTUAL ze_result_t createEvent(const ze_event_desc_t *desc, ze_event_handle_t *eventHandle);
|
2024-02-07 00:42:24 +00:00
|
|
|
ze_result_t getContextHandle(ze_context_handle_t *phContext);
|
|
|
|
|
ze_result_t getFlags(ze_event_pool_flags_t *pFlags);
|
2020-03-06 11:09:57 +01:00
|
|
|
|
|
|
|
|
static EventPool *fromHandle(ze_event_pool_handle_t handle) {
|
|
|
|
|
return static_cast<EventPool *>(handle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline ze_event_pool_handle_t toHandle() { return this; }
|
|
|
|
|
|
2023-01-16 17:12:02 +00:00
|
|
|
MOCKABLE_VIRTUAL NEO::MultiGraphicsAllocation &getAllocation() { return *eventPoolAllocations; }
|
2025-04-01 19:52:25 +00:00
|
|
|
std::unique_ptr<NEO::SharedTimestampAllocation> &getSharedTimestampAllocation() {
|
|
|
|
|
return sharedTimestampAllocation;
|
|
|
|
|
}
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2022-10-27 11:40:44 +00:00
|
|
|
uint32_t getEventSize() const { return eventSize; }
|
|
|
|
|
void setEventSize(uint32_t size) { eventSize = size; }
|
|
|
|
|
void setEventAlignment(uint32_t alignment) { eventAlignment = alignment; }
|
|
|
|
|
size_t getNumEvents() const { return numEvents; }
|
|
|
|
|
uint32_t getEventMaxPackets() const { return eventPackets; }
|
|
|
|
|
size_t getEventPoolSize() const { return eventPoolSize; }
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2023-01-16 17:12:02 +00:00
|
|
|
bool isEventPoolTimestampFlagSet() const;
|
2021-06-09 20:15:59 +00:00
|
|
|
|
2023-01-16 17:12:02 +00:00
|
|
|
bool isEventPoolDeviceAllocationFlagSet() const {
|
2021-06-09 20:15:59 +00:00
|
|
|
if (!(eventPoolFlags & ZE_EVENT_POOL_FLAG_HOST_VISIBLE)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2025-01-20 11:25:34 +00:00
|
|
|
bool isEventPoolKernelMappedTsFlagSet() const {
|
2023-06-09 15:07:24 +00:00
|
|
|
if (eventPoolFlags & ZE_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-13 18:50:36 +00:00
|
|
|
uint32_t getMaxKernelCount() const {
|
|
|
|
|
return maxKernelCount;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-16 17:12:02 +00:00
|
|
|
ze_result_t initialize(DriverHandle *driver, Context *context, uint32_t numDevices, ze_device_handle_t *deviceHandles);
|
|
|
|
|
|
|
|
|
|
void initializeSizeParameters(uint32_t numDevices, ze_device_handle_t *deviceHandles, DriverHandleImp &driver, const NEO::RootDeviceEnvironment &rootDeviceEnvironment);
|
|
|
|
|
|
|
|
|
|
Device *getDevice() const { return devices[0]; }
|
|
|
|
|
|
2023-01-19 18:33:55 +00:00
|
|
|
bool getImportedIpcPool() const {
|
|
|
|
|
return isImportedIpcPool;
|
|
|
|
|
}
|
2022-10-27 11:40:44 +00:00
|
|
|
|
2023-03-24 21:26:48 +00:00
|
|
|
bool isImplicitScalingCapableFlagSet() const {
|
|
|
|
|
return isImplicitScalingCapable;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-03 08:55:03 +00:00
|
|
|
uint32_t getCounterBasedFlags() const { return counterBasedFlags; }
|
2023-11-23 11:09:21 +00:00
|
|
|
bool isIpcPoolFlagSet() const { return isIpcPoolFlag; }
|
2023-10-31 17:56:27 +00:00
|
|
|
|
2022-10-27 11:40:44 +00:00
|
|
|
protected:
|
|
|
|
|
EventPool() = default;
|
|
|
|
|
EventPool(size_t numEvents) : numEvents(numEvents) {}
|
2023-10-31 17:56:27 +00:00
|
|
|
void setupDescriptorFlags(const ze_event_pool_desc_t *desc);
|
2022-10-27 11:40:44 +00:00
|
|
|
|
2023-01-19 18:33:55 +00:00
|
|
|
std::vector<Device *> devices;
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<NEO::MultiGraphicsAllocation> eventPoolAllocations;
|
2025-04-01 19:52:25 +00:00
|
|
|
std::unique_ptr<NEO::SharedTimestampAllocation> sharedTimestampAllocation;
|
|
|
|
|
|
2023-01-19 18:33:55 +00:00
|
|
|
void *eventPoolPtr = nullptr;
|
|
|
|
|
ContextImp *context = nullptr;
|
|
|
|
|
|
2022-10-27 11:40:44 +00:00
|
|
|
size_t numEvents = 1;
|
|
|
|
|
size_t eventPoolSize = 0;
|
2023-01-19 18:33:55 +00:00
|
|
|
|
2022-10-27 11:40:44 +00:00
|
|
|
uint32_t eventAlignment = 0;
|
|
|
|
|
uint32_t eventSize = 0;
|
|
|
|
|
uint32_t eventPackets = 0;
|
2022-12-13 18:50:36 +00:00
|
|
|
uint32_t maxKernelCount = 0;
|
2023-01-19 18:33:55 +00:00
|
|
|
|
2024-01-03 08:55:03 +00:00
|
|
|
uint32_t counterBasedFlags = 0;
|
|
|
|
|
|
2023-10-02 10:34:36 +00:00
|
|
|
ze_event_pool_flags_t eventPoolFlags{};
|
2023-01-19 18:33:55 +00:00
|
|
|
|
|
|
|
|
bool isDeviceEventPoolAllocation = false;
|
|
|
|
|
bool isHostVisibleEventPoolAllocation = false;
|
|
|
|
|
bool isImportedIpcPool = false;
|
2023-11-23 11:09:21 +00:00
|
|
|
bool isIpcPoolFlag = false;
|
2023-01-19 18:33:55 +00:00
|
|
|
bool isShareableEventMemory = false;
|
2023-03-24 21:26:48 +00:00
|
|
|
bool isImplicitScalingCapable = false;
|
2020-10-13 17:23:09 -07:00
|
|
|
};
|
|
|
|
|
|
2020-03-06 11:09:57 +01:00
|
|
|
} // namespace L0
|