2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-09-18 15:11:08 +08:00
|
|
|
* Copyright (C) 2017-2018 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "runtime/command_stream/command_stream_receiver_hw.h"
|
|
|
|
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
|
|
|
#include <map>
|
2018-11-16 16:11:52 +08:00
|
|
|
#include <memory>
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
namespace OCLRT {
|
|
|
|
|
2018-08-17 19:38:09 +08:00
|
|
|
class GmmPageTableMngr;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
2018-11-16 16:11:52 +08:00
|
|
|
class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily>, public NonCopyableOrMovableClass {
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass = CommandStreamReceiverHw<GfxFamily>;
|
|
|
|
|
|
|
|
public:
|
2018-09-12 22:32:42 +08:00
|
|
|
using BaseClass::createScratchSpaceAllocation;
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass::dshState;
|
2018-09-12 22:32:42 +08:00
|
|
|
using BaseClass::getScratchPatchAddress;
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass::hwInfo;
|
2018-04-26 16:01:01 +08:00
|
|
|
using BaseClass::indirectHeap;
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass::iohState;
|
2018-04-26 16:01:01 +08:00
|
|
|
using BaseClass::programPreamble;
|
2018-11-05 18:52:19 +08:00
|
|
|
using BaseClass::programStateSip;
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass::sshState;
|
2018-10-19 16:49:25 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::cleanupResources;
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::commandStream;
|
|
|
|
using BaseClass::CommandStreamReceiver::disableL3Cache;
|
|
|
|
using BaseClass::CommandStreamReceiver::dispatchMode;
|
2018-08-08 19:49:09 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::executionEnvironment;
|
2018-07-05 17:23:28 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::experimentalCmdBuffer;
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::flushStamp;
|
2018-11-16 16:11:52 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::GSBAFor32BitProgrammed;
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::isPreambleSent;
|
2018-11-05 18:52:19 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::isStateSipSent;
|
2018-02-16 16:15:36 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::lastMediaSamplerConfig;
|
|
|
|
using BaseClass::CommandStreamReceiver::lastPreemptionMode;
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::lastSentCoherencyRequest;
|
|
|
|
using BaseClass::CommandStreamReceiver::lastSentL3Config;
|
2018-02-20 15:11:24 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::lastSentThreadArbitrationPolicy;
|
2018-02-16 16:15:36 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::lastVmeSubslicesConfig;
|
2018-01-12 23:41:45 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::latestFlushedTaskCount;
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::latestSentStatelessMocsConfig;
|
2018-08-10 21:23:11 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::mediaVfeStateDirty;
|
2018-09-12 22:32:42 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::requiredScratchSize;
|
2018-03-22 16:41:17 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::requiredThreadArbitrationPolicy;
|
2018-11-16 16:11:52 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::samplerCacheFlushRequired;
|
2018-09-12 22:32:42 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::scratchAllocation;
|
2018-10-15 16:35:45 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::stallingPipeControlOnNextFlushRequired;
|
2018-08-10 21:23:11 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::submissionAggregator;
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::taskCount;
|
|
|
|
using BaseClass::CommandStreamReceiver::taskLevel;
|
2018-09-06 15:03:07 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::timestampPacketWriteEnabled;
|
2018-10-09 17:50:58 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::waitForTaskCountAndCleanAllocationList;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-11-16 16:11:52 +08:00
|
|
|
virtual ~UltCommandStreamReceiver() override {
|
|
|
|
if (tempPreemptionLocation) {
|
|
|
|
this->setPreemptionCsrAllocation(nullptr);
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-08-08 19:49:09 +08:00
|
|
|
UltCommandStreamReceiver(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment) : BaseClass(hwInfoIn, executionEnvironment) {
|
2018-03-05 16:25:40 +08:00
|
|
|
if (hwInfoIn.capabilityTable.defaultPreemptionMode == PreemptionMode::MidThread) {
|
2018-11-16 16:11:52 +08:00
|
|
|
tempPreemptionLocation = std::make_unique<GraphicsAllocation>(nullptr, 0, 0, 0);
|
|
|
|
this->preemptionCsrAllocation = tempPreemptionLocation.get();
|
2018-03-05 16:25:40 +08:00
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-11-16 16:11:52 +08:00
|
|
|
static CommandStreamReceiver *create(const HardwareInfo &hwInfoIn, bool withAubDump, ExecutionEnvironment &executionEnvironment) {
|
|
|
|
return new UltCommandStreamReceiver<GfxFamily>(hwInfoIn, executionEnvironment);
|
|
|
|
}
|
|
|
|
|
2018-09-06 16:53:35 +08:00
|
|
|
virtual MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory) override {
|
2018-10-11 17:19:49 +08:00
|
|
|
return new OsAgnosticMemoryManager(enable64kbPages, enableLocalMemory, executionEnvironment);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2018-08-17 19:38:09 +08:00
|
|
|
virtual GmmPageTableMngr *createPageTableManager() override {
|
|
|
|
createPageTableManagerCalled = true;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
void overrideCsrSizeReqFlags(CsrSizeRequestFlags &flags) { this->csrSizeRequestFlags = flags; }
|
2018-11-16 16:11:52 +08:00
|
|
|
GraphicsAllocation *getPreemptionCsrAllocation() { return this->preemptionCsrAllocation; }
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-02-16 16:15:36 +08: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 15:24:26 +08:00
|
|
|
bool isMadeResident(GraphicsAllocation *graphicsAllocation) {
|
|
|
|
return makeResidentAllocations.find(graphicsAllocation) != makeResidentAllocations.end();
|
|
|
|
}
|
|
|
|
|
2018-02-16 16:15:36 +08:00
|
|
|
std::map<GraphicsAllocation *, uint32_t> makeResidentAllocations;
|
2018-11-16 16:11:52 +08:00
|
|
|
bool storeMakeResidentAllocations = false;
|
2018-02-16 16:15:36 +08:00
|
|
|
|
2018-06-13 02:33:03 +08: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 19:38:09 +08:00
|
|
|
bool createPageTableManagerCalled = false;
|
2018-06-13 02:33:03 +08:00
|
|
|
bool activateAubSubCaptureCalled = false;
|
|
|
|
bool flushBatchedSubmissionsCalled = false;
|
|
|
|
bool initProgrammingFlagsCalled = false;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
protected:
|
2018-11-16 16:11:52 +08:00
|
|
|
std::unique_ptr<GraphicsAllocation> tempPreemptionLocation;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace OCLRT
|