2020-03-06 11:09:57 +01:00
|
|
|
/*
|
2025-02-19 17:56:25 +00:00
|
|
|
* Copyright (C) 2020-2025 Intel Corporation
|
2020-03-06 11:09:57 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2023-08-21 10:35:14 +00:00
|
|
|
#include "shared/source/command_stream/task_count_helper.h"
|
2024-06-07 11:43:29 +00:00
|
|
|
#include "shared/source/helpers/common_types.h"
|
2023-12-07 16:32:19 +00:00
|
|
|
#include "shared/source/helpers/definitions/engine_group_types.h"
|
2023-02-28 13:32:48 +00:00
|
|
|
#include "shared/source/helpers/heap_base_address_model.h"
|
|
|
|
|
|
2024-08-29 12:03:35 +00:00
|
|
|
#include "level_zero/core/source/helpers/api_handle_helper.h"
|
2020-07-29 02:45:54 -07:00
|
|
|
#include <level_zero/ze_api.h>
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2023-08-21 10:35:14 +00:00
|
|
|
#include <atomic>
|
2022-09-22 10:46:22 +00:00
|
|
|
#include <mutex>
|
2022-10-21 15:12:24 +00:00
|
|
|
#include <vector>
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2025-07-16 20:12:19 +00:00
|
|
|
struct _ze_command_queue_handle_t : BaseHandleWithLoaderTranslation<ZEL_HANDLE_COMMAND_QUEUE> {};
|
2025-03-28 09:32:57 +00:00
|
|
|
static_assert(IsCompliantWithDdiHandlesExt<_ze_command_queue_handle_t>);
|
2020-03-06 11:09:57 +01:00
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
class CommandStreamReceiver;
|
2022-10-21 15:12:24 +00:00
|
|
|
class GraphicsAllocation;
|
2024-05-27 21:37:08 +00:00
|
|
|
class LinearStream;
|
2022-10-21 15:12:24 +00:00
|
|
|
using ResidencyContainer = std::vector<GraphicsAllocation *>;
|
2024-06-07 11:43:29 +00:00
|
|
|
|
2022-10-21 15:12:24 +00:00
|
|
|
} // namespace NEO
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2022-09-22 10:46:22 +00:00
|
|
|
struct UnifiedMemoryControls;
|
|
|
|
|
|
2020-03-06 11:09:57 +01:00
|
|
|
namespace L0 {
|
2022-06-02 19:30:32 +00:00
|
|
|
struct Device;
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2024-06-07 11:43:29 +00:00
|
|
|
struct QueueProperties {
|
|
|
|
|
NEO::SynchronizedDispatchMode synchronizedDispatchMode = NEO::SynchronizedDispatchMode::disabled;
|
|
|
|
|
bool interruptHint = false;
|
2024-06-12 09:25:42 +00:00
|
|
|
bool copyOffloadHint = false;
|
2025-05-21 12:22:11 +00:00
|
|
|
int priorityLevel = 0;
|
2024-06-07 11:43:29 +00:00
|
|
|
};
|
|
|
|
|
|
2020-03-06 11:09:57 +01:00
|
|
|
struct CommandQueue : _ze_command_queue_handle_t {
|
|
|
|
|
template <typename Type>
|
|
|
|
|
struct Allocator {
|
|
|
|
|
static CommandQueue *allocate(Device *device, NEO::CommandStreamReceiver *csr, const ze_command_queue_desc_t *desc) {
|
|
|
|
|
return new Type(device, csr, desc);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
virtual ~CommandQueue() = default;
|
|
|
|
|
|
|
|
|
|
virtual ze_result_t createFence(const ze_fence_desc_t *desc, ze_fence_handle_t *phFence) = 0;
|
|
|
|
|
virtual ze_result_t destroy() = 0;
|
|
|
|
|
virtual ze_result_t executeCommandLists(uint32_t numCommandLists,
|
|
|
|
|
ze_command_list_handle_t *phCommandLists,
|
2024-02-14 12:55:20 +00:00
|
|
|
ze_fence_handle_t hFence, bool performMigration,
|
2025-04-10 21:08:13 +00:00
|
|
|
NEO::LinearStream *parentImmediateCommandlistLinearStream,
|
|
|
|
|
std::unique_lock<std::mutex> *outerLockForIndirect) = 0;
|
2020-07-29 02:45:54 -07:00
|
|
|
virtual ze_result_t synchronize(uint64_t timeout) = 0;
|
2024-02-03 11:55:02 +00:00
|
|
|
virtual ze_result_t getOrdinal(uint32_t *pOrdinal) = 0;
|
|
|
|
|
virtual ze_result_t getIndex(uint32_t *pIndex) = 0;
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2020-03-05 00:25:57 -08:00
|
|
|
static CommandQueue *create(uint32_t productFamily, Device *device, NEO::CommandStreamReceiver *csr,
|
2023-04-19 15:21:05 +00:00
|
|
|
const ze_command_queue_desc_t *desc, bool isCopyOnly, bool isInternal, bool immediateCmdListQueue, ze_result_t &resultValue);
|
2020-03-06 11:09:57 +01:00
|
|
|
|
|
|
|
|
static CommandQueue *fromHandle(ze_command_queue_handle_t handle) {
|
|
|
|
|
return static_cast<CommandQueue *>(handle);
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-07 11:43:29 +00:00
|
|
|
static QueueProperties extractQueueProperties(const ze_command_queue_desc_t &desc);
|
2024-06-06 15:23:40 +00:00
|
|
|
|
2022-10-21 15:12:24 +00:00
|
|
|
virtual void handleIndirectAllocationResidency(UnifiedMemoryControls unifiedMemoryControls, std::unique_lock<std::mutex> &lockForIndirect, bool performMigration) = 0;
|
|
|
|
|
virtual void makeResidentAndMigrate(bool performMigration, const NEO::ResidencyContainer &residencyContainer) = 0;
|
2022-09-22 10:46:22 +00:00
|
|
|
|
2020-03-05 00:25:57 -08:00
|
|
|
ze_command_queue_handle_t toHandle() { return this; }
|
2020-03-06 11:09:57 +01:00
|
|
|
|
2021-03-16 10:34:28 +00:00
|
|
|
bool peekIsCopyOnlyCommandQueue() const { return this->isCopyOnlyCommandQueue; }
|
|
|
|
|
|
2023-06-22 16:38:44 +00:00
|
|
|
virtual void unregisterCsrClient() = 0;
|
2023-09-25 07:58:39 +00:00
|
|
|
virtual void registerCsrClient() = 0;
|
2023-02-15 10:52:39 +00:00
|
|
|
|
2023-08-21 10:35:14 +00:00
|
|
|
TaskCountType getTaskCount() const { return taskCount; }
|
|
|
|
|
void setTaskCount(TaskCountType newTaskCount) { taskCount = newTaskCount; }
|
|
|
|
|
|
2025-07-10 10:59:42 +00:00
|
|
|
inline bool getAndClearIsWalkerWithProfilingEnqueued() {
|
|
|
|
|
bool retVal = this->isWalkerWithProfilingEnqueued;
|
|
|
|
|
this->isWalkerWithProfilingEnqueued = false;
|
|
|
|
|
return retVal;
|
|
|
|
|
}
|
2025-08-01 12:56:02 +00:00
|
|
|
inline void setPatchingPreamble(bool patching) {
|
|
|
|
|
this->patchingPreamble = patching;
|
|
|
|
|
}
|
2025-08-09 09:41:44 +00:00
|
|
|
inline bool getPatchingPreamble() const {
|
|
|
|
|
return this->patchingPreamble;
|
|
|
|
|
}
|
2025-07-10 10:59:42 +00:00
|
|
|
|
2020-03-06 11:09:57 +01:00
|
|
|
protected:
|
2022-09-20 16:46:15 +00:00
|
|
|
bool frontEndTrackingEnabled() const;
|
|
|
|
|
|
2021-09-03 11:42:31 +00:00
|
|
|
uint32_t partitionCount = 1;
|
2021-11-02 16:58:19 +00:00
|
|
|
uint32_t activeSubDevices = 1;
|
2023-08-21 10:35:14 +00:00
|
|
|
std::atomic<TaskCountType> taskCount = 0;
|
2023-12-12 11:37:31 +00:00
|
|
|
NEO::HeapAddressModel cmdListHeapAddressModel = NEO::HeapAddressModel::privateHeaps;
|
2023-02-28 13:32:48 +00:00
|
|
|
|
2021-04-24 18:21:05 +00:00
|
|
|
bool preemptionCmdSyncProgramming = true;
|
2020-03-16 13:34:33 +01:00
|
|
|
bool commandQueueDebugCmdsProgrammed = false;
|
2020-04-07 16:50:09 +02:00
|
|
|
bool isCopyOnlyCommandQueue = false;
|
2020-11-16 16:24:54 +01:00
|
|
|
bool internalUsage = false;
|
2022-09-26 13:12:04 +00:00
|
|
|
bool frontEndStateTracking = false;
|
2022-09-20 16:46:15 +00:00
|
|
|
bool pipelineSelectStateTracking = false;
|
2022-09-20 16:46:15 +00:00
|
|
|
bool stateComputeModeTracking = false;
|
2023-01-26 14:33:36 +00:00
|
|
|
bool stateBaseAddressTracking = false;
|
2023-02-22 21:30:40 +00:00
|
|
|
bool doubleSbaWa = false;
|
2023-04-03 18:28:53 +00:00
|
|
|
bool dispatchCmdListBatchBufferAsPrimary = false;
|
2023-11-23 13:58:58 +00:00
|
|
|
bool heaplessModeEnabled = false;
|
2024-03-29 03:22:39 +00:00
|
|
|
bool heaplessStateInitEnabled = false;
|
2025-07-10 10:59:42 +00:00
|
|
|
bool isWalkerWithProfilingEnqueued = false;
|
2025-08-01 12:56:02 +00:00
|
|
|
bool patchingPreamble = false;
|
2020-03-06 11:09:57 +01:00
|
|
|
};
|
|
|
|
|
|
2020-03-05 00:25:57 -08:00
|
|
|
using CommandQueueAllocatorFn = CommandQueue *(*)(Device *device, NEO::CommandStreamReceiver *csr,
|
|
|
|
|
const ze_command_queue_desc_t *desc);
|
2020-03-06 11:09:57 +01:00
|
|
|
extern CommandQueueAllocatorFn commandQueueFactory[];
|
|
|
|
|
|
|
|
|
|
template <uint32_t productFamily, typename CommandQueueType>
|
|
|
|
|
struct CommandQueuePopulateFactory {
|
|
|
|
|
CommandQueuePopulateFactory() {
|
|
|
|
|
commandQueueFactory[productFamily] = CommandQueue::Allocator<CommandQueueType>::allocate;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace L0
|