Make batch buffer resident during direct submit

Related-To: NEO-4338

Change-Id: I9d4d0f0baf96ed5d4aa6d7c8d8206e0681984e84
Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2020-07-31 09:18:50 +02:00
committed by sys_ocldev
parent 403594fce0
commit c08e3dde82
7 changed files with 38 additions and 10 deletions

View File

@ -19,6 +19,7 @@ class DrmMemoryOperationsHandler : public MemoryOperationsHandler {
DrmMemoryOperationsHandler() = default;
~DrmMemoryOperationsHandler() override = default;
virtual MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations) = 0;
virtual MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) = 0;
virtual void mergeWithResidencyContainer(OsContext *osContext, ResidencyContainer &residencyContainer) = 0;
virtual std::unique_lock<std::mutex> lockHandlerForExecWA() = 0;

View File

@ -22,18 +22,23 @@ DrmMemoryOperationsHandlerBind::DrmMemoryOperationsHandlerBind() = default;
DrmMemoryOperationsHandlerBind::~DrmMemoryOperationsHandlerBind() = default;
MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) {
std::lock_guard<std::mutex> lock(mutex);
auto engines = device->getEngines();
for (const auto &engine : engines) {
for (auto gfxAllocation = gfxAllocations.begin(); gfxAllocation != gfxAllocations.end(); gfxAllocation++) {
if (!(*gfxAllocation)->isAlwaysResident(engine.osContext->getContextId())) {
auto drmAllocation = static_cast<DrmAllocation *>(*gfxAllocation);
auto &drmContextIds = static_cast<const OsContextLinux *>(engine.osContext)->getDrmContextIds();
for (uint32_t drmIterator = 0u; drmIterator < drmContextIds.size(); drmIterator++) {
drmAllocation->makeBOsResident(engine.osContext->getContextId(), drmIterator, nullptr, true);
}
drmAllocation->updateResidencyTaskCount(GraphicsAllocation::objectAlwaysResident, engine.osContext->getContextId());
this->makeResidentWithinOsContext(engine.osContext, gfxAllocations);
}
return MemoryOperationsStatus::SUCCESS;
}
MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations) {
std::lock_guard<std::mutex> lock(mutex);
for (auto gfxAllocation = gfxAllocations.begin(); gfxAllocation != gfxAllocations.end(); gfxAllocation++) {
if (!(*gfxAllocation)->isAlwaysResident(osContext->getContextId())) {
auto drmAllocation = static_cast<DrmAllocation *>(*gfxAllocation);
auto &drmContextIds = static_cast<const OsContextLinux *>(osContext)->getDrmContextIds();
for (uint32_t drmIterator = 0u; drmIterator < drmContextIds.size(); drmIterator++) {
drmAllocation->makeBOsResident(osContext->getContextId(), drmIterator, nullptr, true);
}
drmAllocation->updateResidencyTaskCount(GraphicsAllocation::objectAlwaysResident, osContext->getContextId());
}
}
return MemoryOperationsStatus::SUCCESS;

View File

@ -14,6 +14,7 @@ class DrmMemoryOperationsHandlerBind : public DrmMemoryOperationsHandler {
DrmMemoryOperationsHandlerBind();
~DrmMemoryOperationsHandlerBind() override;
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override;
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override;

View File

@ -16,12 +16,17 @@ namespace NEO {
DrmMemoryOperationsHandlerDefault::DrmMemoryOperationsHandlerDefault() = default;
DrmMemoryOperationsHandlerDefault::~DrmMemoryOperationsHandlerDefault() = default;
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) {
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations) {
std::lock_guard<std::mutex> lock(mutex);
this->residency.insert(gfxAllocations.begin(), gfxAllocations.end());
return MemoryOperationsStatus::SUCCESS;
}
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) {
OsContext *osContext = nullptr;
return this->makeResidentWithinOsContext(osContext, gfxAllocations);
}
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) {
std::lock_guard<std::mutex> lock(mutex);
this->residency.erase(&gfxAllocation);

View File

@ -17,6 +17,7 @@ class DrmMemoryOperationsHandlerDefault : public DrmMemoryOperationsHandler {
DrmMemoryOperationsHandlerDefault();
~DrmMemoryOperationsHandlerDefault() override;
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override;
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override;