2020-03-06 18:09:57 +08:00
|
|
|
/*
|
2023-01-16 23:30:27 +08:00
|
|
|
* Copyright (C) 2020-2023 Intel Corporation
|
2020-03-06 18:09:57 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2023-02-28 21:32:48 +08:00
|
|
|
#include "shared/source/helpers/heap_base_address_model.h"
|
|
|
|
|
2020-07-29 17:45:54 +08:00
|
|
|
#include <level_zero/ze_api.h>
|
2020-03-06 18:09:57 +08:00
|
|
|
|
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
|
|
|
|
|
|
|
struct _ze_command_queue_handle_t {};
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
class CommandStreamReceiver;
|
2022-10-21 23:12:24 +08:00
|
|
|
class GraphicsAllocation;
|
|
|
|
using ResidencyContainer = std::vector<GraphicsAllocation *>;
|
|
|
|
} // 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
|
|
|
|
|
|
|
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,
|
|
|
|
ze_fence_handle_t hFence, bool performMigration) = 0;
|
|
|
|
virtual ze_result_t executeCommands(uint32_t numCommands,
|
|
|
|
void *phCommands,
|
|
|
|
ze_fence_handle_t hFence) = 0;
|
2020-07-29 17:45:54 +08:00
|
|
|
virtual ze_result_t synchronize(uint64_t timeout) = 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,
|
2020-11-16 23:24:54 +08:00
|
|
|
const ze_command_queue_desc_t *desc, bool isCopyOnly, bool isInternal, 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);
|
|
|
|
}
|
|
|
|
|
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-02-15 18:52:39 +08:00
|
|
|
uint32_t getClientId() { return this->clientId; }
|
|
|
|
void setClientId(uint32_t value) { this->clientId = value; }
|
|
|
|
|
2023-02-15 19:36:05 +08:00
|
|
|
static constexpr uint32_t clientNotRegistered = std::numeric_limits<uint32_t>::max();
|
|
|
|
|
2020-03-06 18:09:57 +08:00
|
|
|
protected:
|
2022-09-21 00:46:15 +08:00
|
|
|
bool frontEndTrackingEnabled() const;
|
|
|
|
|
2023-02-15 19:36:05 +08:00
|
|
|
uint32_t clientId = clientNotRegistered;
|
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-02-28 21:32:48 +08:00
|
|
|
NEO::HeapAddressModel cmdListHeapAddressModel = NEO::HeapAddressModel::PrivateHeaps;
|
|
|
|
|
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;
|
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
|