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