Add support for batched dispatch to userspace AUBs

This commit as aimed to add support for batched dispatch,
but doesn't make it the default mode for AubCSR yet.

Change-Id: I4dc366ec5f01adf2c4793009da2100ba0230c60a
This commit is contained in:
Milczarek, Slawomir
2018-01-10 22:03:23 +01:00
committed by sys_ocldev
parent 920d952a4a
commit 7c42353c4c
14 changed files with 166 additions and 71 deletions

View File

@@ -206,6 +206,15 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
DEBUG_BREAK_IF(!engineInfo.pLRCA);
}
if (this->dispatchMode == CommandStreamReceiver::DispatchMode::ImmediateDispatch) {
makeResident(*batchBuffer.commandBufferAllocation);
} else {
allocationsForResidency->push_back(batchBuffer.commandBufferAllocation);
batchBuffer.commandBufferAllocation->residencyTaskCount = this->taskCount;
}
processResidency(allocationsForResidency);
// Write our batch buffer
auto pBatchBuffer = ptrOffset(batchBuffer.commandBufferAllocation->getUnderlyingBuffer(), batchBuffer.startOffset);
auto currentOffset = batchBuffer.usedSize;
@@ -349,6 +358,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
}
pollForCompletion(engineOrdinal);
return 0;
}
@@ -378,37 +388,50 @@ void AUBCommandStreamReceiverHw<GfxFamily>::pollForCompletion(EngineType engineO
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::makeResident(GraphicsAllocation &gfxAllocation) {
if (gfxAllocation.residencyTaskCount < (int)this->taskCount) {
auto cpuAddress = gfxAllocation.getUnderlyingBuffer();
auto gpuAddress = gfxAllocation.getGpuAddress();
auto size = gfxAllocation.getUnderlyingBufferSize();
if (size == 0 || !(((MemoryAllocation *)&gfxAllocation)->allowAubFileWrite))
return;
{
std::ostringstream str;
str << "ppgtt: " << std::hex << std::showbase << gpuAddress;
stream.addComment(str.str().c_str());
}
PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset) {
static const size_t pageSize = 4096;
auto vmAddr = (static_cast<uintptr_t>(gpuAddress) + offset) & ~(pageSize - 1);
auto pAddr = physAddress & ~(pageSize - 1);
AUB::reserveAddressPPGTT(stream, vmAddr, pageSize, pAddr);
AUB::addMemoryWrite(stream, physAddress,
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(cpuAddress) + offset),
size, AubMemDump::AddressSpaceValues::TraceNonlocal);
};
ppgtt.pageWalk(static_cast<uintptr_t>(gpuAddress), size, 0, walker);
this->getMemoryManager()->pushAllocationForResidency(&gfxAllocation);
}
gfxAllocation.residencyTaskCount = (int)this->taskCount;
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxAllocation) {
auto cpuAddress = gfxAllocation.getUnderlyingBuffer();
auto gpuAddress = gfxAllocation.getGpuAddress();
auto size = gfxAllocation.getUnderlyingBufferSize();
if (size == 0 || !(((MemoryAllocation *)&gfxAllocation)->allowAubFileWrite))
return;
{
std::ostringstream str;
str << "ppgtt: " << std::hex << std::showbase << gpuAddress;
stream.addComment(str.str().c_str());
}
PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset) {
static const size_t pageSize = 4096;
auto vmAddr = (static_cast<uintptr_t>(gpuAddress) + offset) & ~(pageSize - 1);
auto pAddr = physAddress & ~(pageSize - 1);
AUB::reserveAddressPPGTT(stream, vmAddr, pageSize, pAddr);
AUB::addMemoryWrite(stream, physAddress,
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(cpuAddress) + offset),
size, AubMemDump::AddressSpaceValues::TraceNonlocal);
};
ppgtt.pageWalk(static_cast<uintptr_t>(gpuAddress), size, 0, walker);
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer *allocationsForResidency) {
auto &residencyAllocations = allocationsForResidency ? *allocationsForResidency : this->getMemoryManager()->getResidencyAllocations();
for (auto &gfxAllocation : residencyAllocations) {
writeMemory(*gfxAllocation);
gfxAllocation->residencyTaskCount = (int)this->taskCount;
}
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::makeNonResident(GraphicsAllocation &gfxAllocation) {
if (gfxAllocation.residencyTaskCount != ObjectNotResident) {