1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
/*
* Copyright (C) 2019-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/command_stream/csr_definitions.h"
#include "shared/source/command_stream/submissions_aggregator.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/indirect_heap/indirect_heap.h"
#include "level_zero/core/source/cmdqueue/cmdqueue.h"
#include <vector>
namespace NEO {
class LinearStream;
class GraphicsAllocation;
class MemoryManager;
} // namespace NEO
namespace L0 {
struct CommandList;
struct Kernel;
struct CommandQueueImp : public CommandQueue {
class CommandBufferManager {
public:
enum BUFFER_ALLOCATION : uint32_t {
FIRST = 0,
SECOND,
COUNT
};
void initialize(Device *device, size_t sizeRequested);
void destroy(NEO::MemoryManager *memoryManager);
void switchBuffers(NEO::CommandStreamReceiver *csr);
NEO::GraphicsAllocation *getCurrentBufferAllocation() {
return buffers[bufferUse];
}
void setCurrentFlushStamp(NEO::FlushStamp flushStamp) {
flushId[bufferUse] = flushStamp;
}
private:
NEO::GraphicsAllocation *buffers[BUFFER_ALLOCATION::COUNT];
NEO::FlushStamp flushId[BUFFER_ALLOCATION::COUNT];
BUFFER_ALLOCATION bufferUse = BUFFER_ALLOCATION::FIRST;
};
static constexpr size_t defaultQueueCmdBufferSize = 128 * MemoryConstants::kiloByte;
static constexpr size_t minCmdBufferPtrAlign = 8;
static constexpr size_t totalCmdBufferSize =
defaultQueueCmdBufferSize +
MemoryConstants::cacheLineSize +
NEO::CSRequirements::csOverfetchSize;
CommandQueueImp() = delete;
CommandQueueImp(Device *device, NEO::CommandStreamReceiver *csr, const ze_command_queue_desc_t *desc)
: device(device), csr(csr), desc(*desc) {
std::atomic_init(&commandQueuePerThreadScratchSize, 0u);
}
ze_result_t destroy() override;
ze_result_t synchronize(uint64_t timeout) override;
void initialize(bool copyOnly);
Device *getDevice() { return device; }
uint32_t getTaskCount() { return taskCount; }
NEO::CommandStreamReceiver *getCsr() { return csr; }
void reserveLinearStreamSize(size_t size);
ze_command_queue_mode_t getSynchronousMode();
virtual void dispatchTaskCountWrite(NEO::LinearStream &commandStream, bool flushDataCache) = 0;
protected:
MOCKABLE_VIRTUAL void submitBatchBuffer(size_t offset, NEO::ResidencyContainer &residencyContainer, void *endingCmdPtr);
ze_result_t synchronizeByPollingForTaskCount(uint64_t timeout);
void printFunctionsPrintfOutput();
Device *device = nullptr;
NEO::CommandStreamReceiver *csr = nullptr;
const ze_command_queue_desc_t desc;
NEO::LinearStream *commandStream = nullptr;
std::atomic<uint32_t> taskCount{0};
std::vector<Kernel *> printfFunctionContainer;
bool gsbaInit = false;
bool frontEndInit = false;
bool gpgpuEnabled = false;
CommandBufferManager buffers;
NEO::ResidencyContainer residencyContainer;
NEO::HeapContainer heapContainer;
};
} // namespace L0
|