2020-03-06 11:09:57 +01:00
|
|
|
/*
|
2025-01-16 22:08:53 +00:00
|
|
|
* Copyright (C) 2020-2025 Intel Corporation
|
2020-03-06 11:09:57 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-02-06 09:05:43 +00:00
|
|
|
#include "shared/source/command_stream/preemption_mode.h"
|
2023-03-10 12:28:11 +00:00
|
|
|
#include "shared/source/os_interface/product_helper.h"
|
2024-02-28 12:46:21 +00:00
|
|
|
#include "shared/source/utilities/tag_allocator.h"
|
2022-06-14 21:24:58 +00: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-09 17:14:18 +00:00
|
|
|
#include <memory>
|
2024-02-28 12:46:21 +00:00
|
|
|
#include <mutex>
|
2023-01-09 17:14:18 +00:00
|
|
|
|
2022-12-12 16:43:41 +00:00
|
|
|
static_assert(NEO::ProductHelper::uuidSize == ZE_MAX_DEVICE_UUID_SIZE);
|
2021-12-16 12:57:10 +00:00
|
|
|
|
2025-03-28 09:32:57 +00:00
|
|
|
struct _ze_device_handle_t : BaseHandleWithLoaderTranslation<ZEL_HANDLE_DEVICE> {};
|
|
|
|
|
static_assert(IsCompliantWithDdiHandlesExt<_ze_device_handle_t>);
|
|
|
|
|
|
2020-03-06 11:09:57 +01:00
|
|
|
namespace NEO {
|
2022-07-06 13:23:03 +00:00
|
|
|
class CommandStreamReceiver;
|
|
|
|
|
class DebuggerL0;
|
2020-03-06 11:09:57 +01:00
|
|
|
class Device;
|
2022-12-08 12:22:35 +00:00
|
|
|
class GfxCoreHelper;
|
2020-03-06 11:09:57 +01:00
|
|
|
class MemoryManager;
|
2020-03-18 11:36:17 +01:00
|
|
|
struct DeviceInfo;
|
2023-01-20 16:09:58 +00:00
|
|
|
class CompilerProductHelper;
|
2024-02-28 12:46:21 +00:00
|
|
|
class TagAllocatorBase;
|
2023-08-22 10:55:41 +00:00
|
|
|
enum class AllocationType;
|
2020-03-06 11:09:57 +01:00
|
|
|
} // namespace NEO
|
|
|
|
|
|
|
|
|
|
namespace L0 {
|
|
|
|
|
struct DriverHandle;
|
|
|
|
|
struct BuiltinFunctionsLib;
|
|
|
|
|
struct ExecutionEnvironment;
|
2022-01-12 08:24:41 +00:00
|
|
|
class MetricDeviceContext;
|
2020-07-03 20:05:35 +05:30
|
|
|
struct SysmanDevice;
|
2021-02-23 17:57:27 +00:00
|
|
|
struct DebugSession;
|
2023-01-02 13:06:10 +00:00
|
|
|
class L0GfxCoreHelper;
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2020-11-12 19:53:30 +01:00
|
|
|
enum class ModuleType;
|
|
|
|
|
|
2020-03-06 11:09:57 +01:00
|
|
|
struct Device : _ze_device_handle_t {
|
2023-01-09 17:14:18 +00:00
|
|
|
uint32_t getRootDeviceIndex() const;
|
|
|
|
|
|
2021-12-16 12:29:09 +00:00
|
|
|
NEO::Device *getNEODevice() const {
|
|
|
|
|
return this->neoDevice;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-06 11:09:57 +01:00
|
|
|
virtual ze_result_t canAccessPeer(ze_device_handle_t hPeerDevice, ze_bool_t *value) = 0;
|
|
|
|
|
virtual ze_result_t createCommandList(const ze_command_list_desc_t *desc,
|
|
|
|
|
ze_command_list_handle_t *commandList) = 0;
|
|
|
|
|
|
|
|
|
|
virtual ze_result_t createCommandListImmediate(const ze_command_queue_desc_t *desc,
|
|
|
|
|
ze_command_list_handle_t *commandList) = 0;
|
|
|
|
|
|
|
|
|
|
virtual ze_result_t createCommandQueue(const ze_command_queue_desc_t *desc,
|
|
|
|
|
ze_command_queue_handle_t *commandQueue) = 0;
|
|
|
|
|
|
|
|
|
|
virtual ze_result_t createImage(const ze_image_desc_t *desc, ze_image_handle_t *phImage) = 0;
|
|
|
|
|
|
2022-12-21 04:39:44 +01:00
|
|
|
virtual ze_result_t createModule(const ze_module_desc_t *desc, ze_module_handle_t *module,
|
2020-11-12 19:53:30 +01:00
|
|
|
ze_module_build_log_handle_t *buildLog, ModuleType type) = 0;
|
2020-03-06 11:09:57 +01:00
|
|
|
virtual ze_result_t createSampler(const ze_sampler_desc_t *pDesc,
|
|
|
|
|
ze_sampler_handle_t *phSampler) = 0;
|
2020-07-15 02:47:57 -07:00
|
|
|
virtual ze_result_t getComputeProperties(ze_device_compute_properties_t *pComputeProperties) = 0;
|
2020-03-06 11:09:57 +01:00
|
|
|
virtual ze_result_t getP2PProperties(ze_device_handle_t hPeerDevice,
|
|
|
|
|
ze_device_p2p_properties_t *pP2PProperties) = 0;
|
2020-07-29 02:45:54 -07:00
|
|
|
virtual ze_result_t getKernelProperties(ze_device_module_properties_t *pKernelProperties) = 0;
|
2021-12-21 08:55:09 +00:00
|
|
|
virtual ze_result_t getPciProperties(ze_pci_ext_properties_t *pPciProperties) = 0;
|
2023-07-12 02:14:09 +00:00
|
|
|
virtual ze_result_t getRootDevice(ze_device_handle_t *phRootDevice) = 0;
|
2020-03-06 11:09:57 +01:00
|
|
|
virtual ze_result_t getMemoryProperties(uint32_t *pCount, ze_device_memory_properties_t *pMemProperties) = 0;
|
|
|
|
|
virtual ze_result_t getMemoryAccessProperties(ze_device_memory_access_properties_t *pMemAccessProperties) = 0;
|
|
|
|
|
virtual ze_result_t getProperties(ze_device_properties_t *pDeviceProperties) = 0;
|
|
|
|
|
virtual ze_result_t getSubDevices(uint32_t *pCount, ze_device_handle_t *phSubdevices) = 0;
|
2020-08-05 15:11:34 -07:00
|
|
|
virtual ze_result_t getCacheProperties(uint32_t *pCount, ze_device_cache_properties_t *pCacheProperties) = 0;
|
2023-06-06 23:44:26 +00:00
|
|
|
virtual ze_result_t getStatus() = 0;
|
2021-06-23 14:53:34 +00:00
|
|
|
virtual ze_result_t reserveCache(size_t cacheLevel, size_t cacheReservationSize) = 0;
|
|
|
|
|
virtual ze_result_t setCacheAdvice(void *ptr, size_t regionSize, ze_cache_ext_region_t cacheRegion) = 0;
|
2020-03-06 11:09:57 +01:00
|
|
|
virtual ze_result_t imageGetProperties(const ze_image_desc_t *desc, ze_image_properties_t *pImageProperties) = 0;
|
|
|
|
|
virtual ze_result_t getDeviceImageProperties(ze_device_image_properties_t *pDeviceImageProperties) = 0;
|
2020-11-02 17:47:58 -08:00
|
|
|
virtual ze_result_t getExternalMemoryProperties(ze_device_external_memory_properties_t *pExternalMemoryProperties) = 0;
|
2025-01-24 09:53:43 +01:00
|
|
|
virtual ze_result_t getGlobalTimestamps(uint64_t *hostTimestamp, uint64_t *deviceTimestamp) = 0;
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2020-07-15 02:47:57 -07:00
|
|
|
virtual ze_result_t getCommandQueueGroupProperties(uint32_t *pCount,
|
|
|
|
|
ze_command_queue_group_properties_t *pCommandQueueGroupProperties) = 0;
|
2021-02-23 17:57:27 +00:00
|
|
|
virtual ze_result_t getDebugProperties(zet_device_debug_properties_t *pDebugProperties) = 0;
|
|
|
|
|
|
2020-03-06 11:09:57 +01:00
|
|
|
virtual ze_result_t systemBarrier() = 0;
|
2025-05-14 10:15:56 +00:00
|
|
|
virtual ze_result_t synchronize() = 0;
|
2020-03-06 11:09:57 +01:00
|
|
|
|
|
|
|
|
virtual ~Device() = default;
|
|
|
|
|
|
|
|
|
|
virtual BuiltinFunctionsLib *getBuiltinFunctionsLib() = 0;
|
|
|
|
|
virtual uint32_t getMOCS(bool l3enabled, bool l1enabled) = 0;
|
|
|
|
|
virtual uint32_t getMaxNumHwThreads() const = 0;
|
|
|
|
|
|
2022-12-12 13:21:09 +00:00
|
|
|
virtual const NEO::GfxCoreHelper &getGfxCoreHelper() = 0;
|
2023-01-02 13:06:10 +00:00
|
|
|
virtual const L0GfxCoreHelper &getL0GfxCoreHelper() = 0;
|
2022-12-20 15:13:56 +00:00
|
|
|
virtual const NEO::ProductHelper &getProductHelper() = 0;
|
2023-04-18 08:54:04 +00:00
|
|
|
virtual const NEO::CompilerProductHelper &getCompilerProductHelper() = 0;
|
2023-01-20 16:09:58 +00:00
|
|
|
|
2021-12-09 10:38:06 +00:00
|
|
|
bool isImplicitScalingCapable() const {
|
|
|
|
|
return implicitScalingCapable;
|
2021-11-25 13:04:28 +00:00
|
|
|
}
|
2020-03-06 11:09:57 +01:00
|
|
|
virtual const NEO::HardwareInfo &getHwInfo() const = 0;
|
2025-01-21 11:07:44 +00:00
|
|
|
virtual NEO::OSInterface *getOsInterface() = 0;
|
2020-03-06 11:09:57 +01:00
|
|
|
virtual uint32_t getPlatformInfo() const = 0;
|
2022-01-12 08:24:41 +00:00
|
|
|
virtual MetricDeviceContext &getMetricDeviceContext() = 0;
|
2021-02-23 17:57:27 +00:00
|
|
|
virtual DebugSession *getDebugSession(const zet_debug_config_t &config) = 0;
|
2022-09-23 14:56:32 +00:00
|
|
|
virtual DebugSession *createDebugSession(const zet_debug_config_t &config, ze_result_t &result, bool isRootAttach) = 0;
|
2021-03-03 12:09:39 +00:00
|
|
|
virtual void removeDebugSession() = 0;
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2021-11-16 18:37:15 +00:00
|
|
|
virtual ze_result_t activateMetricGroupsDeferred(uint32_t count,
|
|
|
|
|
zet_metric_group_handle_t *phMetricGroups) = 0;
|
2020-03-06 11:09:57 +01:00
|
|
|
virtual void activateMetricGroups() = 0;
|
|
|
|
|
|
|
|
|
|
virtual DriverHandle *getDriverHandle() = 0;
|
|
|
|
|
virtual void setDriverHandle(DriverHandle *driverHandle) = 0;
|
|
|
|
|
|
|
|
|
|
static Device *fromHandle(ze_device_handle_t handle) { return static_cast<Device *>(handle); }
|
|
|
|
|
|
|
|
|
|
inline ze_device_handle_t toHandle() { return this; }
|
|
|
|
|
|
2021-10-12 17:11:20 +00:00
|
|
|
static Device *create(DriverHandle *driverHandle, NEO::Device *neoDevice, bool isSubDevice, ze_result_t *returnValue);
|
|
|
|
|
static Device *create(DriverHandle *driverHandle, NEO::Device *neoDevice, bool isSubDevice, ze_result_t *returnValue, L0::Device *deviceL0);
|
2021-10-04 13:05:10 +00:00
|
|
|
static Device *deviceReinit(DriverHandle *driverHandle, L0::Device *device, std::unique_ptr<NEO::Device> &neoDevice, ze_result_t *returnValue);
|
2020-03-06 11:09:57 +01:00
|
|
|
|
|
|
|
|
virtual NEO::PreemptionMode getDevicePreemptionMode() const = 0;
|
2020-03-18 11:36:17 +01:00
|
|
|
virtual const NEO::DeviceInfo &getDeviceInfo() const = 0;
|
2023-01-09 17:14:18 +00:00
|
|
|
NEO::DebuggerL0 *getL0Debugger();
|
2020-03-10 14:42:15 +01:00
|
|
|
|
2020-03-16 13:34:33 +01:00
|
|
|
virtual NEO::GraphicsAllocation *getDebugSurface() const = 0;
|
2020-04-01 09:51:07 +02:00
|
|
|
|
|
|
|
|
virtual NEO::GraphicsAllocation *allocateManagedMemoryFromHostPtr(void *buffer,
|
|
|
|
|
size_t size, struct CommandList *commandList) = 0;
|
|
|
|
|
|
2021-11-09 23:25:07 +00:00
|
|
|
virtual NEO::GraphicsAllocation *allocateMemoryFromHostPtr(const void *buffer, size_t size, bool hostCopyAllowed) = 0;
|
2020-07-03 20:05:35 +05:30
|
|
|
virtual void setSysmanHandle(SysmanDevice *pSysmanDevice) = 0;
|
|
|
|
|
virtual SysmanDevice *getSysmanHandle() = 0;
|
2025-05-21 12:22:11 +00:00
|
|
|
virtual ze_result_t getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr, uint32_t ordinal, uint32_t index, ze_command_queue_priority_t priority, int priorityLevel, bool allocateInterrupt) = 0;
|
2024-07-02 14:27:17 +00:00
|
|
|
virtual ze_result_t getCsrForLowPriority(NEO::CommandStreamReceiver **csr, bool copyOnly) = 0;
|
2022-02-04 13:59:01 +00:00
|
|
|
virtual NEO::GraphicsAllocation *obtainReusableAllocation(size_t requiredSize, NEO::AllocationType type) = 0;
|
2021-08-16 15:31:09 +00:00
|
|
|
virtual void storeReusableAllocation(NEO::GraphicsAllocation &alloc) = 0;
|
2022-10-25 07:21:48 +00:00
|
|
|
virtual ze_result_t getFabricVertex(ze_fabric_vertex_handle_t *phVertex) = 0;
|
2022-10-27 11:40:44 +00:00
|
|
|
virtual uint32_t getEventMaxPacketCount() const = 0;
|
2022-12-13 18:50:36 +00:00
|
|
|
virtual uint32_t getEventMaxKernelCount() const = 0;
|
2024-02-28 12:46:21 +00:00
|
|
|
NEO::TagAllocatorBase *getDeviceInOrderCounterAllocator();
|
2024-03-13 15:48:10 +00:00
|
|
|
NEO::TagAllocatorBase *getHostInOrderCounterAllocator();
|
2024-07-19 15:15:04 +00:00
|
|
|
NEO::TagAllocatorBase *getInOrderTimestampAllocator();
|
2024-03-26 14:26:41 +00:00
|
|
|
NEO::GraphicsAllocation *getSyncDispatchTokenAllocation() const { return syncDispatchTokenAllocation; }
|
2024-03-25 14:54:48 +00:00
|
|
|
uint32_t getNextSyncDispatchQueueId();
|
2024-03-26 10:02:52 +00:00
|
|
|
void ensureSyncDispatchTokenAllocation();
|
2025-04-30 14:15:19 +00:00
|
|
|
void setIdentifier(uint32_t id) { identifier = id; }
|
|
|
|
|
uint32_t getIdentifier() const { return identifier; }
|
2025-05-21 12:22:11 +00:00
|
|
|
ze_result_t getPriorityLevels(int *lowestPriority,
|
|
|
|
|
int *highestPriority);
|
2021-11-25 13:04:28 +00:00
|
|
|
|
|
|
|
|
protected:
|
2021-12-16 12:29:09 +00:00
|
|
|
NEO::Device *neoDevice = nullptr;
|
2024-02-28 12:46:21 +00:00
|
|
|
std::unique_ptr<NEO::TagAllocatorBase> deviceInOrderCounterAllocator;
|
2024-03-13 15:48:10 +00:00
|
|
|
std::unique_ptr<NEO::TagAllocatorBase> hostInOrderCounterAllocator;
|
2024-07-19 15:15:04 +00:00
|
|
|
std::unique_ptr<NEO::TagAllocatorBase> inOrderTimestampAllocator;
|
2024-03-26 10:02:52 +00:00
|
|
|
NEO::GraphicsAllocation *syncDispatchTokenAllocation = nullptr;
|
2024-02-28 12:46:21 +00:00
|
|
|
std::mutex inOrderAllocatorMutex;
|
2024-03-26 10:02:52 +00:00
|
|
|
std::mutex syncDispatchTokenMutex;
|
2024-03-25 14:54:48 +00:00
|
|
|
std::atomic<uint32_t> syncDispatchQueueIdAllocator = 0;
|
2025-04-30 14:15:19 +00:00
|
|
|
uint32_t identifier = 0;
|
2021-12-09 10:38:06 +00:00
|
|
|
bool implicitScalingCapable = false;
|
2025-05-21 12:22:11 +00:00
|
|
|
int queuePriorityHigh = 0;
|
|
|
|
|
int queuePriorityLow = 1;
|
2020-03-06 11:09:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace L0
|