Do not bind command buffer separately

Improve performance by binding the command buffer together with other
allocations if VM_BIND feature is available. Remove the legacy
flag PassBoundBOToExec from DebugManager to simplify the logic.
Adapt unit tests and reuse handy macros to generate proxy mock-methods.

Related-To: NEO-7348
Signed-off-by: Maciej Bielski <maciej.bielski@intel.com>
This commit is contained in:
Maciej Bielski
2022-09-29 18:31:22 +00:00
committed by Compute-Runtime-Automation
parent e6daa207ad
commit 11eb0aa769
9 changed files with 73 additions and 217 deletions

View File

@ -116,6 +116,10 @@ SubmissionStatus DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBu
this->printBOsForSubmit(allocationsForResidency, *batchBuffer.commandBufferAllocation);
if (this->drm->isVmBindAvailable()) {
allocationsForResidency.push_back(batchBuffer.commandBufferAllocation);
}
MemoryOperationsStatus retVal = memoryOperationsInterface->mergeWithResidencyContainer(this->osContext, allocationsForResidency);
if (retVal != MemoryOperationsStatus::SUCCESS) {
if (retVal == MemoryOperationsStatus::OUT_OF_MEMORY) {
@ -124,16 +128,6 @@ SubmissionStatus DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBu
return SubmissionStatus::FAILED;
}
if (this->drm->isVmBindAvailable()) {
retVal = memoryOperationsInterface->makeResidentWithinOsContext(this->osContext, ArrayRef<GraphicsAllocation *>(&batchBuffer.commandBufferAllocation, 1), true);
if (retVal != MemoryOperationsStatus::SUCCESS) {
if (retVal == MemoryOperationsStatus::OUT_OF_MEMORY) {
return SubmissionStatus::OUT_OF_MEMORY;
}
return SubmissionStatus::FAILED;
}
}
if (this->directSubmission.get()) {
this->startControllingDirectSubmissions();
bool ret = this->directSubmission->dispatchCommandBuffer(batchBuffer, *this->flushStamp.get());
@ -211,7 +205,9 @@ int DrmCommandStreamReceiver<GfxFamily>::exec(const BatchBuffer &batchBuffer, ui
auto osContextLinux = static_cast<OsContextLinux *>(this->osContext);
auto execFlags = osContextLinux->getEngineFlag() | drm->getIoctlHelper()->getDrmParamValue(DrmParam::ExecNoReloc);
// Residency hold all allocation except command buffer, hence + 1
// requiredSize determinant:
// * vmBind UNAVAILABLE => residency holds all allocations except for the command buffer
// * vmBind AVAILABLE => residency holds command buffer as well
auto requiredSize = this->residency.size() + 1;
if (requiredSize > this->execObjectsStorage.size()) {
this->execObjectsStorage.resize(requiredSize);
@ -219,8 +215,7 @@ int DrmCommandStreamReceiver<GfxFamily>::exec(const BatchBuffer &batchBuffer, ui
uint64_t completionGpuAddress = 0;
uint32_t completionValue = 0;
if (this->drm->isVmBindAvailable() &&
this->drm->completionFenceSupport()) {
if (this->drm->isVmBindAvailable() && this->drm->completionFenceSupport()) {
completionGpuAddress = getTagAllocation()->getGpuAddress() + (index * this->postSyncWriteOffset) + Drm::completionFenceOffset;
completionValue = this->latestSentTaskCount;
}
@ -243,16 +238,18 @@ int DrmCommandStreamReceiver<GfxFamily>::exec(const BatchBuffer &batchBuffer, ui
template <typename GfxFamily>
bool DrmCommandStreamReceiver<GfxFamily>::processResidency(const ResidencyContainer &inputAllocationsForResidency, uint32_t handleId) {
bool ret = 0;
if ((!drm->isVmBindAvailable()) || (DebugManager.flags.PassBoundBOToExec.get() == 1)) {
for (auto &alloc : inputAllocationsForResidency) {
auto drmAlloc = static_cast<DrmAllocation *>(alloc);
ret = drmAlloc->makeBOsResident(osContext, handleId, &this->residency, false);
if (ret != 0) {
break;
}
if (drm->isVmBindAvailable()) {
return true;
}
int ret = 0;
for (auto &alloc : inputAllocationsForResidency) {
auto drmAlloc = static_cast<DrmAllocation *>(alloc);
ret = drmAlloc->makeBOsResident(osContext, handleId, &this->residency, false);
if (ret != 0) {
break;
}
}
return ret == 0;
}