2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2018-09-18 09:11:08 +02:00
|
|
|
* Copyright (C) 2017-2018 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "runtime/command_stream/command_stream_receiver_hw.h"
|
|
|
|
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
2018-07-05 11:23:28 +02:00
|
|
|
#include "unit_tests/mocks/mock_experimental_command_buffer.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
#include <map>
|
|
|
|
|
|
|
|
namespace OCLRT {
|
|
|
|
|
2018-08-17 13:38:09 +02:00
|
|
|
class GmmPageTableMngr;
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
template <typename GfxFamily>
|
|
|
|
class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
|
|
|
|
using BaseClass = CommandStreamReceiverHw<GfxFamily>;
|
|
|
|
|
|
|
|
public:
|
2018-09-12 16:32:42 +02:00
|
|
|
using BaseClass::createScratchSpaceAllocation;
|
2017-12-21 00:45:38 +01:00
|
|
|
using BaseClass::dshState;
|
2018-09-12 16:32:42 +02:00
|
|
|
using BaseClass::getScratchPatchAddress;
|
2017-12-21 00:45:38 +01:00
|
|
|
using BaseClass::hwInfo;
|
2018-04-26 10:01:01 +02:00
|
|
|
using BaseClass::indirectHeap;
|
2017-12-21 00:45:38 +01:00
|
|
|
using BaseClass::iohState;
|
2018-04-26 10:01:01 +02:00
|
|
|
using BaseClass::programPreamble;
|
2018-11-05 11:52:19 +01:00
|
|
|
using BaseClass::programStateSip;
|
2017-12-21 00:45:38 +01:00
|
|
|
using BaseClass::sshState;
|
2018-10-19 10:49:25 +02:00
|
|
|
using BaseClass::CommandStreamReceiver::cleanupResources;
|
2017-12-21 00:45:38 +01:00
|
|
|
using BaseClass::CommandStreamReceiver::commandStream;
|
|
|
|
using BaseClass::CommandStreamReceiver::disableL3Cache;
|
|
|
|
using BaseClass::CommandStreamReceiver::dispatchMode;
|
2018-08-08 13:49:09 +02:00
|
|
|
using BaseClass::CommandStreamReceiver::executionEnvironment;
|
2018-07-05 11:23:28 +02:00
|
|
|
using BaseClass::CommandStreamReceiver::experimentalCmdBuffer;
|
2017-12-21 00:45:38 +01:00
|
|
|
using BaseClass::CommandStreamReceiver::flushStamp;
|
|
|
|
using BaseClass::CommandStreamReceiver::isPreambleSent;
|
2018-11-05 11:52:19 +01:00
|
|
|
using BaseClass::CommandStreamReceiver::isStateSipSent;
|
2018-02-16 09:15:36 +01:00
|
|
|
using BaseClass::CommandStreamReceiver::lastMediaSamplerConfig;
|
|
|
|
using BaseClass::CommandStreamReceiver::lastPreemptionMode;
|
2017-12-21 00:45:38 +01:00
|
|
|
using BaseClass::CommandStreamReceiver::lastSentCoherencyRequest;
|
|
|
|
using BaseClass::CommandStreamReceiver::lastSentL3Config;
|
2018-02-20 08:11:24 +01:00
|
|
|
using BaseClass::CommandStreamReceiver::lastSentThreadArbitrationPolicy;
|
2018-02-16 09:15:36 +01:00
|
|
|
using BaseClass::CommandStreamReceiver::lastVmeSubslicesConfig;
|
2018-01-12 16:41:45 +01:00
|
|
|
using BaseClass::CommandStreamReceiver::latestFlushedTaskCount;
|
2017-12-21 00:45:38 +01:00
|
|
|
using BaseClass::CommandStreamReceiver::latestSentStatelessMocsConfig;
|
2018-08-10 15:23:11 +02:00
|
|
|
using BaseClass::CommandStreamReceiver::mediaVfeStateDirty;
|
2018-09-12 16:32:42 +02:00
|
|
|
using BaseClass::CommandStreamReceiver::requiredScratchSize;
|
2018-03-22 09:41:17 +01:00
|
|
|
using BaseClass::CommandStreamReceiver::requiredThreadArbitrationPolicy;
|
2018-09-12 16:32:42 +02:00
|
|
|
using BaseClass::CommandStreamReceiver::scratchAllocation;
|
2018-10-15 10:35:45 +02:00
|
|
|
using BaseClass::CommandStreamReceiver::stallingPipeControlOnNextFlushRequired;
|
2018-08-10 15:23:11 +02:00
|
|
|
using BaseClass::CommandStreamReceiver::submissionAggregator;
|
2017-12-21 00:45:38 +01:00
|
|
|
using BaseClass::CommandStreamReceiver::taskCount;
|
|
|
|
using BaseClass::CommandStreamReceiver::taskLevel;
|
2018-09-06 09:03:07 +02:00
|
|
|
using BaseClass::CommandStreamReceiver::timestampPacketWriteEnabled;
|
2018-10-09 11:50:58 +02:00
|
|
|
using BaseClass::CommandStreamReceiver::waitForTaskCountAndCleanAllocationList;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
UltCommandStreamReceiver(const UltCommandStreamReceiver &) = delete;
|
|
|
|
UltCommandStreamReceiver &operator=(const UltCommandStreamReceiver &) = delete;
|
|
|
|
|
2018-08-08 13:49:09 +02:00
|
|
|
static CommandStreamReceiver *create(const HardwareInfo &hwInfoIn, bool withAubDump, ExecutionEnvironment &executionEnvironment) {
|
|
|
|
return new UltCommandStreamReceiver<GfxFamily>(hwInfoIn, executionEnvironment);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
2018-08-08 13:49:09 +02:00
|
|
|
UltCommandStreamReceiver(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment) : BaseClass(hwInfoIn, executionEnvironment) {
|
2018-02-16 09:15:36 +01:00
|
|
|
this->storeMakeResidentAllocations = false;
|
2018-03-05 09:25:40 +01:00
|
|
|
if (hwInfoIn.capabilityTable.defaultPreemptionMode == PreemptionMode::MidThread) {
|
2018-10-30 15:24:15 +01:00
|
|
|
tempPreemptionLocation = new GraphicsAllocation(nullptr, 0llu, 0, 0llu);
|
2018-03-05 09:25:40 +01:00
|
|
|
this->preemptionCsrAllocation = tempPreemptionLocation;
|
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
2018-09-06 10:53:35 +02:00
|
|
|
virtual MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory) override {
|
2018-10-11 11:19:49 +02:00
|
|
|
return new OsAgnosticMemoryManager(enable64kbPages, enableLocalMemory, executionEnvironment);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
2018-08-17 13:38:09 +02:00
|
|
|
virtual GmmPageTableMngr *createPageTableManager() override {
|
|
|
|
createPageTableManagerCalled = true;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
void overrideCsrSizeReqFlags(CsrSizeRequestFlags &flags) { this->csrSizeRequestFlags = flags; }
|
2018-06-12 20:33:03 +02:00
|
|
|
bool isPreambleProgrammed() const { return this->isPreambleSent; }
|
|
|
|
bool isGSBAFor32BitProgrammed() const { return this->GSBAFor32BitProgrammed; }
|
|
|
|
bool isMediaVfeStateDirty() const { return this->mediaVfeStateDirty; }
|
|
|
|
bool isLastVmeSubslicesConfig() const { return this->lastVmeSubslicesConfig; }
|
|
|
|
uint32_t getLastSentL3Config() const { return this->lastSentL3Config; }
|
|
|
|
int8_t getLastSentCoherencyRequest() const { return this->lastSentCoherencyRequest; }
|
|
|
|
int8_t getLastMediaSamplerConfig() const { return this->lastMediaSamplerConfig; }
|
|
|
|
PreemptionMode getLastPreemptionMode() const { return this->lastPreemptionMode; }
|
|
|
|
uint32_t getLatestSentStatelessMocsConfig() const { return this->latestSentStatelessMocsConfig; }
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
virtual ~UltCommandStreamReceiver() override;
|
|
|
|
GraphicsAllocation *getTagAllocation() { return tagAllocation; }
|
|
|
|
GraphicsAllocation *getPreemptionCsrAllocation() {
|
|
|
|
return this->preemptionCsrAllocation;
|
|
|
|
}
|
2018-01-10 14:05:34 +01:00
|
|
|
using SamplerCacheFlushState = CommandStreamReceiver::SamplerCacheFlushState;
|
|
|
|
SamplerCacheFlushState peekSamplerCacheFlushRequired() const { return this->samplerCacheFlushRequired; }
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-02-16 09:15:36 +01:00
|
|
|
void makeResident(GraphicsAllocation &gfxAllocation) override {
|
|
|
|
if (storeMakeResidentAllocations) {
|
|
|
|
std::map<GraphicsAllocation *, uint32_t>::iterator it = makeResidentAllocations.find(&gfxAllocation);
|
|
|
|
if (it == makeResidentAllocations.end()) {
|
|
|
|
std::pair<std::map<GraphicsAllocation *, uint32_t>::iterator, bool> result;
|
|
|
|
result = makeResidentAllocations.insert(std::pair<GraphicsAllocation *, uint32_t>(&gfxAllocation, 1));
|
|
|
|
DEBUG_BREAK_IF(!result.second);
|
|
|
|
} else {
|
|
|
|
makeResidentAllocations[&gfxAllocation]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BaseClass::makeResident(gfxAllocation);
|
|
|
|
}
|
|
|
|
|
2018-03-27 09:24:26 +02:00
|
|
|
bool isMadeResident(GraphicsAllocation *graphicsAllocation) {
|
|
|
|
return makeResidentAllocations.find(graphicsAllocation) != makeResidentAllocations.end();
|
|
|
|
}
|
|
|
|
|
2018-02-16 09:15:36 +01:00
|
|
|
std::map<GraphicsAllocation *, uint32_t> makeResidentAllocations;
|
|
|
|
bool storeMakeResidentAllocations;
|
|
|
|
|
2018-06-12 20:33:03 +02:00
|
|
|
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override {
|
|
|
|
CommandStreamReceiverHw<GfxFamily>::activateAubSubCapture(dispatchInfo);
|
|
|
|
activateAubSubCaptureCalled = true;
|
|
|
|
}
|
|
|
|
void flushBatchedSubmissions() override {
|
|
|
|
CommandStreamReceiverHw<GfxFamily>::flushBatchedSubmissions();
|
|
|
|
flushBatchedSubmissionsCalled = true;
|
|
|
|
}
|
|
|
|
void initProgrammingFlags() override {
|
|
|
|
CommandStreamReceiverHw<GfxFamily>::initProgrammingFlags();
|
|
|
|
initProgrammingFlagsCalled = true;
|
|
|
|
}
|
|
|
|
|
2018-08-17 13:38:09 +02:00
|
|
|
bool createPageTableManagerCalled = false;
|
2018-06-12 20:33:03 +02:00
|
|
|
bool activateAubSubCaptureCalled = false;
|
|
|
|
bool flushBatchedSubmissionsCalled = false;
|
|
|
|
bool initProgrammingFlagsCalled = false;
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
protected:
|
|
|
|
using BaseClass::CommandStreamReceiver::tagAddress;
|
|
|
|
using BaseClass::CommandStreamReceiver::tagAllocation;
|
|
|
|
|
2018-03-05 09:25:40 +01:00
|
|
|
GraphicsAllocation *tempPreemptionLocation = nullptr;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
UltCommandStreamReceiver<GfxFamily>::~UltCommandStreamReceiver() {
|
2018-03-05 09:25:40 +01:00
|
|
|
if (tempPreemptionLocation) {
|
|
|
|
this->setPreemptionCsrAllocation(nullptr);
|
|
|
|
delete tempPreemptionLocation;
|
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace OCLRT
|