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"
|
2018-07-05 17:23:28 +08:00
|
|
|
#include "unit_tests/mocks/mock_experimental_command_buffer.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <map>
|
|
|
|
|
|
|
|
namespace OCLRT {
|
|
|
|
|
2018-08-17 19:38:09 +08:00
|
|
|
class GmmPageTableMngr;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
|
|
|
|
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;
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass::sshState;
|
|
|
|
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;
|
|
|
|
using BaseClass::CommandStreamReceiver::isPreambleSent;
|
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-09-12 22:32:42 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::scratchAllocation;
|
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
|
|
|
|
|
|
|
UltCommandStreamReceiver(const UltCommandStreamReceiver &) = delete;
|
|
|
|
UltCommandStreamReceiver &operator=(const UltCommandStreamReceiver &) = delete;
|
|
|
|
|
2018-08-08 19:49:09 +08:00
|
|
|
static CommandStreamReceiver *create(const HardwareInfo &hwInfoIn, bool withAubDump, ExecutionEnvironment &executionEnvironment) {
|
|
|
|
return new UltCommandStreamReceiver<GfxFamily>(hwInfoIn, executionEnvironment);
|
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-02-16 16:15:36 +08:00
|
|
|
this->storeMakeResidentAllocations = false;
|
2018-03-05 16:25:40 +08:00
|
|
|
if (hwInfoIn.capabilityTable.defaultPreemptionMode == PreemptionMode::MidThread) {
|
|
|
|
tempPreemptionLocation = new GraphicsAllocation(nullptr, 0);
|
|
|
|
this->preemptionCsrAllocation = tempPreemptionLocation;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
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-06-13 02:33:03 +08: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 07:45:38 +08:00
|
|
|
|
|
|
|
virtual ~UltCommandStreamReceiver() override;
|
|
|
|
GraphicsAllocation *getTagAllocation() { return tagAllocation; }
|
|
|
|
GraphicsAllocation *getPreemptionCsrAllocation() {
|
|
|
|
return this->preemptionCsrAllocation;
|
|
|
|
}
|
2018-01-10 21:05:34 +08:00
|
|
|
using SamplerCacheFlushState = CommandStreamReceiver::SamplerCacheFlushState;
|
|
|
|
SamplerCacheFlushState peekSamplerCacheFlushRequired() const { return this->samplerCacheFlushRequired; }
|
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;
|
|
|
|
bool storeMakeResidentAllocations;
|
|
|
|
|
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:
|
|
|
|
using BaseClass::CommandStreamReceiver::tagAddress;
|
|
|
|
using BaseClass::CommandStreamReceiver::tagAllocation;
|
|
|
|
|
2018-03-05 16:25:40 +08:00
|
|
|
GraphicsAllocation *tempPreemptionLocation = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
UltCommandStreamReceiver<GfxFamily>::~UltCommandStreamReceiver() {
|
2018-03-05 16:25:40 +08:00
|
|
|
if (tempPreemptionLocation) {
|
|
|
|
this->setPreemptionCsrAllocation(nullptr);
|
|
|
|
delete tempPreemptionLocation;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace OCLRT
|