2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-09-19 03:29:07 +08:00
|
|
|
* Copyright (C) 2018 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"
|
|
|
|
#include "runtime/helpers/hw_info.h"
|
|
|
|
#include "runtime/helpers/dirty_state_helpers.h"
|
|
|
|
#include "runtime/gen_common/hw_cmds.h"
|
|
|
|
#include "runtime/helpers/options.h"
|
|
|
|
|
|
|
|
namespace OCLRT {
|
|
|
|
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:
|
2018-08-08 19:49:09 +08:00
|
|
|
static CommandStreamReceiver *create(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment) {
|
|
|
|
return new CommandStreamReceiverHw<GfxFamily>(hwInfoIn, executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-08-08 19:49:09 +08:00
|
|
|
CommandStreamReceiverHw(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-09-25 18:38:00 +08:00
|
|
|
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer &allocationsForResidency, OsContext &osContext) 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;
|
|
|
|
|
|
|
|
void addPipeControl(LinearStream &commandStream, bool dcFlush) override;
|
2018-04-13 17:05:09 +08:00
|
|
|
int getRequiredPipeControlSize() const;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
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;
|
|
|
|
size_t getCmdSizeForL3Config() const;
|
|
|
|
size_t getCmdSizeForPipelineSelect() const;
|
2017-12-21 07:45:38 +08:00
|
|
|
size_t getCmdSizeForCoherency();
|
2018-01-19 20:29:25 +08:00
|
|
|
size_t getCmdSizeForMediaSampler(bool mediaSamplerRequired) const;
|
2017-12-21 07:45:38 +08:00
|
|
|
void programCoherency(LinearStream &csr, DispatchFlags &dispatchFlags);
|
|
|
|
|
2018-08-27 21:48:29 +08:00
|
|
|
void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, OsContext &osContext) override;
|
2018-02-15 03:14:20 +08:00
|
|
|
const HardwareInfo &peekHwInfo() const { return hwInfo; }
|
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;
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
protected:
|
2018-08-16 17:18:05 +08:00
|
|
|
void programPreemption(LinearStream &csr, Device &device, 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);
|
2018-01-18 20:57:07 +08:00
|
|
|
void programPipelineSelect(LinearStream &csr, DispatchFlags &dispatchFlags);
|
2018-01-19 20:29:25 +08:00
|
|
|
void programMediaSampler(LinearStream &csr, DispatchFlags &dispatchFlags);
|
2018-09-19 03:29:07 +08:00
|
|
|
void handleEventsTimestampPacketTags(LinearStream &csr, DispatchFlags &dispatchFlags, Device ¤tDevice);
|
2017-12-21 07:45:38 +08:00
|
|
|
virtual void programVFEState(LinearStream &csr, DispatchFlags &dispatchFlags);
|
|
|
|
virtual void initPageTableManagerRegisters(LinearStream &csr){};
|
2018-09-12 22:32:42 +08:00
|
|
|
void createScratchSpaceAllocation(size_t requiredScratchSizeInBytes);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
void addPipeControlWA(LinearStream &commandStream, bool flushDC);
|
|
|
|
void addDcFlushToPipeControl(typename GfxFamily::PIPE_CONTROL *pCmd, bool flushDC);
|
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);
|
2018-09-03 22:44:42 +08:00
|
|
|
size_t getSshHeapSize();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
uint64_t getScratchPatchAddress();
|
|
|
|
|
|
|
|
static void emitNoop(LinearStream &commandStream, size_t bytesToUpdate);
|
|
|
|
|
|
|
|
HeapDirtyState dshState;
|
|
|
|
HeapDirtyState iohState;
|
|
|
|
HeapDirtyState sshState;
|
|
|
|
|
|
|
|
const HardwareInfo &hwInfo;
|
|
|
|
CsrSizeRequestFlags csrSizeRequestFlags = {};
|
2018-09-21 04:54:19 +08:00
|
|
|
bool localMemoryEnabled;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace OCLRT
|