2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-01-08 22:58:02 +08:00
|
|
|
* Copyright (c) 2018, Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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:
|
|
|
|
static CommandStreamReceiver *create(const HardwareInfo &hwInfoIn) {
|
|
|
|
return new CommandStreamReceiverHw<GfxFamily>(hwInfoIn);
|
|
|
|
}
|
|
|
|
|
2018-02-20 15:11:24 +08:00
|
|
|
CommandStreamReceiverHw(const HardwareInfo &hwInfoIn);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-02-02 17:33:31 +08:00
|
|
|
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer *allocationsForResidency) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart,
|
|
|
|
const LinearStream &dsh, const LinearStream &ih,
|
|
|
|
const LinearStream &ioh, const LinearStream &ssh,
|
|
|
|
uint32_t taskLevel, DispatchFlags &dispatchFlags) override;
|
|
|
|
|
|
|
|
void flushBatchedSubmissions() override;
|
|
|
|
|
|
|
|
void addPipeControl(LinearStream &commandStream, bool dcFlush) override;
|
|
|
|
int getRequiredPipeControlSize();
|
|
|
|
|
|
|
|
static void addBatchBufferEnd(LinearStream &commandStream, void **patchLocation);
|
|
|
|
static void addBatchBufferStart(MI_BATCH_BUFFER_START *commandBufferMemory, uint64_t startAddress);
|
|
|
|
static void alignToCacheLine(LinearStream &commandStream);
|
|
|
|
|
2018-01-08 22:58:02 +08:00
|
|
|
size_t getRequiredCmdStreamSize(const DispatchFlags &dispatchFlags);
|
2018-01-24 17:11:37 +08:00
|
|
|
size_t getRequiredCmdStreamSizeAligned(const DispatchFlags &dispatchFlags);
|
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-03-21 17:00:49 +08:00
|
|
|
void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep) override;
|
2018-02-15 03:14:20 +08:00
|
|
|
const HardwareInfo &peekHwInfo() const { return hwInfo; }
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
protected:
|
2018-01-08 22:58:02 +08:00
|
|
|
void programPreemption(LinearStream &csr, DispatchFlags &dispatchFlags, const LinearStream &ih);
|
2017-12-21 07:45:38 +08:00
|
|
|
void programL3(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config);
|
|
|
|
void programPreamble(LinearStream &csr, 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);
|
2017-12-21 07:45:38 +08:00
|
|
|
virtual void programVFEState(LinearStream &csr, DispatchFlags &dispatchFlags);
|
|
|
|
virtual void initPageTableManagerRegisters(LinearStream &csr){};
|
|
|
|
|
|
|
|
void addPipeControlWA(LinearStream &commandStream, bool flushDC);
|
|
|
|
void addDcFlushToPipeControl(typename GfxFamily::PIPE_CONTROL *pCmd, bool flushDC);
|
|
|
|
PIPE_CONTROL *addPipeControlCmd(LinearStream &commandStream);
|
|
|
|
|
|
|
|
uint64_t getScratchPatchAddress();
|
2018-03-23 02:02:58 +08:00
|
|
|
MOCKABLE_VIRTUAL void updateLastWaitForCompletionTimestamp();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
static void emitNoop(LinearStream &commandStream, size_t bytesToUpdate);
|
|
|
|
|
|
|
|
HeapDirtyState dshState;
|
|
|
|
HeapDirtyState ihState;
|
|
|
|
HeapDirtyState iohState;
|
|
|
|
HeapDirtyState sshState;
|
|
|
|
|
|
|
|
const HardwareInfo &hwInfo;
|
|
|
|
CsrSizeRequestFlags csrSizeRequestFlags = {};
|
2018-03-22 16:41:17 +08:00
|
|
|
|
|
|
|
std::chrono::high_resolution_clock::time_point lastWaitForCompletionTimestamp;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2018-01-08 22:58:02 +08:00
|
|
|
size_t getSizeRequiredPreambleCS(const Device &device);
|
2017-12-21 07:45:38 +08:00
|
|
|
} // namespace OCLRT
|