Decouple memory manager and device

Change-Id: Ia64cc955e1d290cad4c50b6a2a41052d9acf0eec
This commit is contained in:
Stefanowski, Adam
2018-08-16 11:18:05 +02:00
committed by sys_ocldev
parent a30d6d66ca
commit 1ad70dfebe
19 changed files with 106 additions and 105 deletions

View File

@@ -60,7 +60,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
size_t getRequiredCmdStreamSize(const DispatchFlags &dispatchFlags, Device &device);
size_t getRequiredCmdStreamSizeAligned(const DispatchFlags &dispatchFlags, Device &device);
size_t getRequiredCmdSizeForPreamble() const;
size_t getRequiredCmdSizeForPreamble(Device &device) const;
size_t getCmdSizeForPreemption(const DispatchFlags &dispatchFlags) const;
size_t getCmdSizeForL3Config() const;
size_t getCmdSizeForPipelineSelect() const;
@@ -86,9 +86,9 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
}
protected:
void programPreemption(LinearStream &csr, DispatchFlags &dispatchFlags);
void programPreemption(LinearStream &csr, Device &device, DispatchFlags &dispatchFlags);
void programL3(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config);
void programPreamble(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config);
void programPreamble(LinearStream &csr, Device &device, DispatchFlags &dispatchFlags, uint32_t &newL3Config);
void programPipelineSelect(LinearStream &csr, DispatchFlags &dispatchFlags);
void programMediaSampler(LinearStream &csr, DispatchFlags &dispatchFlags);
virtual void programVFEState(LinearStream &csr, DispatchFlags &dispatchFlags);

View File

@@ -88,14 +88,14 @@ inline void CommandStreamReceiverHw<GfxFamily>::alignToCacheLine(LinearStream &c
}
template <typename GfxFamily>
inline size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdSizeForPreamble() const {
inline size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdSizeForPreamble(Device &device) const {
size_t size = 0;
if (mediaVfeStateDirty) {
size += sizeof(typename GfxFamily::PIPE_CONTROL) + sizeof(typename GfxFamily::MEDIA_VFE_STATE);
}
if (!this->isPreambleSent) {
size += PreambleHelper<GfxFamily>::getAdditionalCommandsSize(*memoryManager->device);
size += PreambleHelper<GfxFamily>::getAdditionalCommandsSize(device);
}
if (!this->isPreambleSent || this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy) {
size += PreambleHelper<GfxFamily>::getThreadArbitrationCommandsSize();
@@ -254,11 +254,11 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
auto commandStreamStartCSR = commandStreamCSR.getUsed();
initPageTableManagerRegisters(commandStreamCSR);
programPreemption(commandStreamCSR, dispatchFlags);
programPreemption(commandStreamCSR, device, dispatchFlags);
programCoherency(commandStreamCSR, dispatchFlags);
programL3(commandStreamCSR, dispatchFlags, newL3Config);
programPipelineSelect(commandStreamCSR, dispatchFlags);
programPreamble(commandStreamCSR, dispatchFlags, newL3Config);
programPreamble(commandStreamCSR, device, dispatchFlags, newL3Config);
programMediaSampler(commandStreamCSR, dispatchFlags);
if (this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy) {
@@ -428,7 +428,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
this->latestFlushedTaskCount = this->taskCount + 1;
this->makeSurfacePackNonResident(nullptr);
} else {
auto commandBuffer = new CommandBuffer;
auto commandBuffer = new CommandBuffer(device);
commandBuffer->batchBuffer = batchBuffer;
commandBuffer->surfaces.swap(getMemoryManager()->getResidencyAllocations());
commandBuffer->batchBufferEndLocation = bbEndLocation;
@@ -480,12 +480,13 @@ inline void CommandStreamReceiverHw<GfxFamily>::flushBatchedSubmissions() {
}
typedef typename GfxFamily::MI_BATCH_BUFFER_START MI_BATCH_BUFFER_START;
typedef typename GfxFamily::PIPE_CONTROL PIPE_CONTROL;
Device *device = this->getMemoryManager()->device;
std::unique_lock<MutexType> lockGuard(ownershipMutex);
EngineType engineType = device->getEngineType();
auto &commandBufferList = this->submissionAggregator->peekCmdBufferList();
if (!commandBufferList.peekIsEmpty()) {
auto &device = commandBufferList.peekHead()->device;
EngineType engineType = device.getEngineType();
ResidencyContainer surfacesForSubmit;
ResourcePackage resourcePackage;
auto pipeControlLocationSize = getRequiredPipeControlSize();
@@ -494,7 +495,7 @@ inline void CommandStreamReceiverHw<GfxFamily>::flushBatchedSubmissions() {
while (!commandBufferList.peekIsEmpty()) {
size_t totalUsedSize = 0u;
this->submissionAggregator->aggregateCommandBuffers(resourcePackage, totalUsedSize, (size_t)device->getDeviceInfo().globalMemSize * 5 / 10);
this->submissionAggregator->aggregateCommandBuffers(resourcePackage, totalUsedSize, (size_t)device.getDeviceInfo().globalMemSize * 5 / 10);
auto primaryCmdBuffer = commandBufferList.removeFrontOne();
auto nextCommandBuffer = commandBufferList.peekHead();
auto currentBBendLocation = primaryCmdBuffer->batchBufferEndLocation;
@@ -609,7 +610,7 @@ size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdStreamSizeAligned(const
template <typename GfxFamily>
size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdStreamSize(const DispatchFlags &dispatchFlags, Device &device) {
size_t size = getRequiredCmdSizeForPreamble();
size_t size = getRequiredCmdSizeForPreamble(device);
size += sizeof(typename GfxFamily::STATE_BASE_ADDRESS) + sizeof(PIPE_CONTROL);
size += getRequiredPipeControlSize();
size += sizeof(typename GfxFamily::MI_BATCH_BUFFER_START);
@@ -658,9 +659,8 @@ inline void CommandStreamReceiverHw<GfxFamily>::waitForTaskCountWithKmdNotifyFal
}
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::programPreemption(LinearStream &csr, DispatchFlags &dispatchFlags) {
PreemptionHelper::programCmdStream<GfxFamily>(csr, dispatchFlags.preemptionMode, this->lastPreemptionMode, preemptionCsrAllocation,
*memoryManager->device);
inline void CommandStreamReceiverHw<GfxFamily>::programPreemption(LinearStream &csr, Device &device, DispatchFlags &dispatchFlags) {
PreemptionHelper::programCmdStream<GfxFamily>(csr, dispatchFlags.preemptionMode, this->lastPreemptionMode, preemptionCsrAllocation, device);
this->lastPreemptionMode = dispatchFlags.preemptionMode;
}
@@ -696,9 +696,9 @@ inline size_t CommandStreamReceiverHw<GfxFamily>::getCmdSizeForL3Config() const
}
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::programPreamble(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config) {
inline void CommandStreamReceiverHw<GfxFamily>::programPreamble(LinearStream &csr, Device &device, DispatchFlags &dispatchFlags, uint32_t &newL3Config) {
if (!this->isPreambleSent) {
PreambleHelper<GfxFamily>::programPreamble(&csr, *memoryManager->device, newL3Config, this->requiredThreadArbitrationPolicy, this->preemptionCsrAllocation);
PreambleHelper<GfxFamily>::programPreamble(&csr, device, newL3Config, this->requiredThreadArbitrationPolicy, this->preemptionCsrAllocation);
this->isPreambleSent = true;
this->lastSentL3Config = newL3Config;
this->lastSentThreadArbitrationPolicy = this->requiredThreadArbitrationPolicy;

View File

@@ -110,6 +110,6 @@ void OCLRT::SubmissionAggregator::aggregateCommandBuffers(ResourcePackage &resou
OCLRT::BatchBuffer::BatchBuffer(GraphicsAllocation *commandBufferAllocation, size_t startOffset, size_t chainedBatchBufferStartOffset, GraphicsAllocation *chainedBatchBuffer, bool requiresCoherency, bool lowPriority, QueueThrottle throttle, size_t usedSize, LinearStream *stream) : commandBufferAllocation(commandBufferAllocation), startOffset(startOffset), chainedBatchBufferStartOffset(chainedBatchBufferStartOffset), chainedBatchBuffer(chainedBatchBuffer), requiresCoherency(requiresCoherency), low_priority(lowPriority), throttle(throttle), usedSize(usedSize), stream(stream) {
}
OCLRT::CommandBuffer::CommandBuffer() {
OCLRT::CommandBuffer::CommandBuffer(Device &device) : device(device) {
flushStamp.reset(new FlushStampTracker(false));
}

View File

@@ -27,6 +27,7 @@
#include "runtime/memory_manager/residency_container.h"
#include <vector>
namespace OCLRT {
class Device;
class Event;
class FlushStampTracker;
class GraphicsAllocation;
@@ -56,7 +57,7 @@ struct BatchBuffer {
};
struct CommandBuffer : public IDNode<CommandBuffer> {
CommandBuffer();
CommandBuffer(Device &);
ResidencyContainer surfaces;
BatchBuffer batchBuffer;
void *batchBufferEndLocation = nullptr;
@@ -65,6 +66,7 @@ struct CommandBuffer : public IDNode<CommandBuffer> {
void *pipeControlThatMayBeErasedLocation = nullptr;
void *epiloguePipeControlLocation = nullptr;
std::unique_ptr<FlushStampTracker> flushStamp;
Device &device;
};
struct CommandBufferList : public IDList<CommandBuffer, false, true, false> {};
@@ -81,4 +83,4 @@ class SubmissionAggregator {
CommandBufferList cmdBuffers;
uint32_t inspectionId = 1;
};
} // namespace OCLRT
} // namespace OCLRT