2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-01-28 20:44:59 +08:00
|
|
|
* Copyright (C) 2018-2019 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-19 03:29:07 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "runtime/command_stream/command_stream_receiver.h"
|
2019-02-27 17:06:14 +08:00
|
|
|
#include "runtime/execution_environment/execution_environment.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "runtime/gen_common/hw_cmds.h"
|
2019-01-25 17:20:32 +08:00
|
|
|
#include "runtime/helpers/csr_deps.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/helpers/dirty_state_helpers.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
#include "runtime/helpers/hw_info.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/helpers/options.h"
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
class DeviceCommandStreamReceiver;
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
class CommandStreamReceiverHw : public CommandStreamReceiver {
|
|
|
|
typedef typename GfxFamily::MI_BATCH_BUFFER_START MI_BATCH_BUFFER_START;
|
|
|
|
typedef typename GfxFamily::PIPE_CONTROL PIPE_CONTROL;
|
|
|
|
|
|
|
|
public:
|
2019-10-29 15:01:53 +08:00
|
|
|
static CommandStreamReceiver *create(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex) {
|
|
|
|
return new CommandStreamReceiverHw<GfxFamily>(executionEnvironment, rootDeviceIndex);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2019-10-29 15:01:53 +08:00
|
|
|
CommandStreamReceiverHw(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-11-26 21:04:52 +08:00
|
|
|
FlushStamp flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart,
|
2018-04-17 19:50:50 +08:00
|
|
|
const IndirectHeap &dsh, const IndirectHeap &ioh, const IndirectHeap &ssh,
|
2018-08-01 16:01:41 +08:00
|
|
|
uint32_t taskLevel, DispatchFlags &dispatchFlags, Device &device) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
void flushBatchedSubmissions() override;
|
|
|
|
|
|
|
|
static void addBatchBufferEnd(LinearStream &commandStream, void **patchLocation);
|
2018-07-05 17:23:28 +08:00
|
|
|
void addBatchBufferStart(MI_BATCH_BUFFER_START *commandBufferMemory, uint64_t startAddress, bool secondary);
|
2017-12-21 07:45:38 +08:00
|
|
|
static void alignToCacheLine(LinearStream &commandStream);
|
|
|
|
|
2018-08-29 19:39:27 +08:00
|
|
|
size_t getRequiredStateBaseAddressSize() const;
|
2018-08-07 15:07:50 +08:00
|
|
|
size_t getRequiredCmdStreamSize(const DispatchFlags &dispatchFlags, Device &device);
|
|
|
|
size_t getRequiredCmdStreamSizeAligned(const DispatchFlags &dispatchFlags, Device &device);
|
2018-08-16 17:18:05 +08:00
|
|
|
size_t getRequiredCmdSizeForPreamble(Device &device) const;
|
2018-04-13 17:05:09 +08:00
|
|
|
size_t getCmdSizeForPreemption(const DispatchFlags &dispatchFlags) const;
|
2019-08-08 01:33:40 +08:00
|
|
|
size_t getCmdSizeForEpilogue(const DispatchFlags &dispatchFlags) const;
|
2019-08-08 17:44:23 +08:00
|
|
|
size_t getCmdSizeForEpilogueCommands(const DispatchFlags &dispatchFlags) const;
|
2018-04-13 17:05:09 +08:00
|
|
|
size_t getCmdSizeForL3Config() const;
|
|
|
|
size_t getCmdSizeForPipelineSelect() const;
|
2018-09-21 20:06:35 +08:00
|
|
|
size_t getCmdSizeForComputeMode();
|
2018-01-19 20:29:25 +08:00
|
|
|
size_t getCmdSizeForMediaSampler(bool mediaSamplerRequired) const;
|
2019-10-11 12:54:10 +08:00
|
|
|
size_t getCmdSizeForEngineMode(const DispatchFlags &dispatchFlags) const;
|
2018-09-21 20:06:35 +08:00
|
|
|
void programComputeMode(LinearStream &csr, DispatchFlags &dispatchFlags);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-11-26 21:04:52 +08:00
|
|
|
void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) override;
|
2019-02-27 17:06:14 +08:00
|
|
|
const HardwareInfo &peekHwInfo() const { return *executionEnvironment.getHardwareInfo(); }
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-14 18:07:51 +08:00
|
|
|
void collectStateBaseAddresPatchInfo(
|
2018-04-04 17:34:46 +08:00
|
|
|
uint64_t commandBufferAddress,
|
2018-03-14 18:07:51 +08:00
|
|
|
uint64_t commandOffset,
|
|
|
|
const LinearStream &dsh,
|
|
|
|
const LinearStream &ioh,
|
|
|
|
const LinearStream &ssh,
|
2018-04-04 17:34:46 +08:00
|
|
|
uint64_t generalStateBase);
|
2018-03-14 18:07:51 +08:00
|
|
|
|
2018-04-10 16:26:59 +08:00
|
|
|
void resetKmdNotifyHelper(KmdNotifyHelper *newHelper);
|
|
|
|
|
2018-06-06 16:34:51 +08:00
|
|
|
CommandStreamReceiverType getType() override {
|
|
|
|
return CommandStreamReceiverType::CSR_HW;
|
|
|
|
}
|
|
|
|
|
2019-10-28 18:54:59 +08:00
|
|
|
uint32_t blitBuffer(const BlitProperties &blitProperties) override;
|
2019-04-03 21:59:31 +08:00
|
|
|
|
2019-09-12 23:30:13 +08:00
|
|
|
bool isMultiOsContextCapable() const override;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
protected:
|
2019-07-31 14:57:00 +08:00
|
|
|
void programPreemption(LinearStream &csr, DispatchFlags &dispatchFlags);
|
2017-12-21 07:45:38 +08:00
|
|
|
void programL3(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config);
|
2018-08-16 17:18:05 +08:00
|
|
|
void programPreamble(LinearStream &csr, Device &device, DispatchFlags &dispatchFlags, uint32_t &newL3Config);
|
2019-09-10 22:13:11 +08:00
|
|
|
void programPipelineSelect(LinearStream &csr, PipelineSelectArgs &pipelineSelectArgs);
|
2019-08-08 01:33:40 +08:00
|
|
|
void programEpilogue(LinearStream &csr, void **batchBufferEndLocation, DispatchFlags &dispatchFlags);
|
2019-08-08 17:44:23 +08:00
|
|
|
void programEpliogueCommands(LinearStream &csr, const DispatchFlags &dispatchFlags);
|
2018-01-19 20:29:25 +08:00
|
|
|
void programMediaSampler(LinearStream &csr, DispatchFlags &dispatchFlags);
|
2018-11-05 18:52:19 +08:00
|
|
|
void programStateSip(LinearStream &cmdStream, Device &device);
|
2019-05-29 21:37:54 +08:00
|
|
|
void programVFEState(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t maxFrontEndThreads);
|
2019-10-03 20:38:49 +08:00
|
|
|
void programStallingPipeControlForBarrier(LinearStream &cmdStream, DispatchFlags &dispatchFlags);
|
2017-12-21 07:45:38 +08:00
|
|
|
virtual void initPageTableManagerRegisters(LinearStream &csr){};
|
2019-10-11 12:54:10 +08:00
|
|
|
void programEngineModeCommands(LinearStream &csr, const DispatchFlags &dispatchFlags);
|
|
|
|
void programEngineModeEpliogue(LinearStream &csr, const DispatchFlags &dispatchFlags);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-05-21 16:57:28 +08:00
|
|
|
void addClearSLMWorkAround(typename GfxFamily::PIPE_CONTROL *pCmd);
|
2017-12-21 07:45:38 +08:00
|
|
|
PIPE_CONTROL *addPipeControlCmd(LinearStream &commandStream);
|
2019-07-19 18:45:56 +08:00
|
|
|
PIPE_CONTROL *addPipeControlBeforeStateBaseAddress(LinearStream &commandStream);
|
2018-09-03 22:44:42 +08:00
|
|
|
size_t getSshHeapSize();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
uint64_t getScratchPatchAddress();
|
2019-03-29 07:49:23 +08:00
|
|
|
void createScratchSpaceController();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
static void emitNoop(LinearStream &commandStream, size_t bytesToUpdate);
|
|
|
|
|
2019-01-28 20:44:59 +08:00
|
|
|
bool detectInitProgrammingFlagsRequired(const DispatchFlags &dispatchFlags) const;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
HeapDirtyState dshState;
|
|
|
|
HeapDirtyState iohState;
|
|
|
|
HeapDirtyState sshState;
|
|
|
|
|
|
|
|
CsrSizeRequestFlags csrSizeRequestFlags = {};
|
|
|
|
};
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|