2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-01-12 21:18:53 +08:00
|
|
|
* Copyright (c) 2017 - 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_hw.h"
|
|
|
|
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
namespace OCLRT {
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
|
|
|
|
using BaseClass = CommandStreamReceiverHw<GfxFamily>;
|
|
|
|
|
|
|
|
public:
|
|
|
|
using BaseClass::dshState;
|
|
|
|
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;
|
|
|
|
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-03-22 16:41:17 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::requiredThreadArbitrationPolicy;
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::taskCount;
|
|
|
|
using BaseClass::CommandStreamReceiver::taskLevel;
|
|
|
|
|
|
|
|
UltCommandStreamReceiver(const UltCommandStreamReceiver &) = delete;
|
|
|
|
UltCommandStreamReceiver &operator=(const UltCommandStreamReceiver &) = delete;
|
|
|
|
|
2018-01-19 17:00:51 +08:00
|
|
|
static CommandStreamReceiver *create(const HardwareInfo &hwInfoIn, bool withAubDump) {
|
2017-12-21 07:45:38 +08:00
|
|
|
return new UltCommandStreamReceiver<GfxFamily>(hwInfoIn);
|
|
|
|
}
|
|
|
|
|
|
|
|
UltCommandStreamReceiver(const HardwareInfo &hwInfoIn) : BaseClass(hwInfoIn) {
|
|
|
|
tempTagLocation = new GraphicsAllocation(nullptr, 0);
|
|
|
|
this->tagAllocation = tempTagLocation;
|
|
|
|
this->tagAddress = reinterpret_cast<uint32_t *>(tempTagLocation->getUnderlyingBuffer());
|
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
|
|
|
}
|
|
|
|
|
|
|
|
virtual MemoryManager *createMemoryManager(bool enable64kbPages) override {
|
|
|
|
memoryManager = new OsAgnosticMemoryManager(enable64kbPages);
|
|
|
|
return memoryManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
void overrideCsrSizeReqFlags(CsrSizeRequestFlags &flags) { this->csrSizeRequestFlags = flags; }
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
protected:
|
|
|
|
using BaseClass::CommandStreamReceiver::memoryManager;
|
|
|
|
using BaseClass::CommandStreamReceiver::tagAddress;
|
|
|
|
using BaseClass::CommandStreamReceiver::tagAllocation;
|
2018-01-12 23:41:45 +08:00
|
|
|
using BaseClass::CommandStreamReceiver::waitForTaskCountAndCleanAllocationList;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
GraphicsAllocation *tempTagLocation;
|
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-01-12 23:41:45 +08:00
|
|
|
this->setTagAllocation(nullptr);
|
2017-12-21 07:45:38 +08:00
|
|
|
delete tempTagLocation;
|
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
|