Skip to content

Commit b2ee148

Browse files
Split residency task count and always resident flag
Related-To: NEO-5052 Change-Id: I1ae5f40a0e3ccc6fc269278f986709becccdaca6 Signed-off-by: Lukasz Jobczyk <[email protected]>
1 parent b4da88a commit b2ee148

File tree

6 files changed

+20
-22
lines changed

6 files changed

+20
-22
lines changed

opencl/source/os_interface/linux/drm_command_stream.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ bool DrmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer, Reside
7474
memoryOperationsInterface->mergeWithResidencyContainer(this->osContext, allocationsForResidency);
7575

7676
if (this->directSubmission.get()) {
77-
memoryOperationsInterface->makeResidentWithinOsContext(this->osContext, ArrayRef<GraphicsAllocation *>(&batchBuffer.commandBufferAllocation, 1));
77+
memoryOperationsInterface->makeResidentWithinOsContext(this->osContext, ArrayRef<GraphicsAllocation *>(&batchBuffer.commandBufferAllocation, 1), true);
7878
return this->directSubmission->dispatchCommandBuffer(batchBuffer, *this->flushStamp.get());
7979
}
8080

shared/source/os_interface/linux/drm_memory_operations_handler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class DrmMemoryOperationsHandler : public MemoryOperationsHandler {
2020
DrmMemoryOperationsHandler() = default;
2121
~DrmMemoryOperationsHandler() override = default;
2222

23-
virtual MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations) = 0;
23+
virtual MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable) = 0;
2424
virtual MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) = 0;
2525
virtual void mergeWithResidencyContainer(OsContext *osContext, ResidencyContainer &residencyContainer) = 0;
2626
virtual std::unique_lock<std::mutex> lockHandlerForExecWA() = 0;

shared/source/os_interface/linux/drm_memory_operations_handler_bind.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ DrmMemoryOperationsHandlerBind::~DrmMemoryOperationsHandlerBind() = default;
2424
MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) {
2525
auto engines = device->getEngines();
2626
for (const auto &engine : engines) {
27-
this->makeResidentWithinOsContext(engine.osContext, gfxAllocations);
27+
this->makeResidentWithinOsContext(engine.osContext, gfxAllocations, false);
2828
}
2929
return MemoryOperationsStatus::SUCCESS;
3030
}
3131

32-
MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations) {
32+
MemoryOperationsStatus DrmMemoryOperationsHandlerBind::makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable) {
3333
std::lock_guard<std::mutex> lock(mutex);
3434
for (auto gfxAllocation = gfxAllocations.begin(); gfxAllocation != gfxAllocations.end(); gfxAllocation++) {
35-
if (!(*gfxAllocation)->isAlwaysResident(osContext->getContextId())) {
36-
auto drmAllocation = static_cast<DrmAllocation *>(*gfxAllocation);
37-
auto &drmContextIds = static_cast<const OsContextLinux *>(osContext)->getDrmContextIds();
38-
for (uint32_t drmIterator = 0u; drmIterator < drmContextIds.size(); drmIterator++) {
39-
drmAllocation->makeBOsResident(osContext, drmIterator, nullptr, true);
40-
}
35+
auto drmAllocation = static_cast<DrmAllocation *>(*gfxAllocation);
36+
auto &drmContextIds = static_cast<const OsContextLinux *>(osContext)->getDrmContextIds();
37+
for (uint32_t drmIterator = 0u; drmIterator < drmContextIds.size(); drmIterator++) {
38+
drmAllocation->makeBOsResident(osContext, drmIterator, nullptr, true);
39+
}
40+
if (!evictable) {
4141
drmAllocation->updateResidencyTaskCount(GraphicsAllocation::objectAlwaysResident, osContext->getContextId());
4242
}
4343
}
@@ -58,14 +58,12 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::evict(Device *device, Gra
5858

5959
MemoryOperationsStatus DrmMemoryOperationsHandlerBind::evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) {
6060
std::lock_guard<std::mutex> lock(mutex);
61-
if (gfxAllocation.isAlwaysResident(osContext->getContextId())) {
62-
auto drmAllocation = static_cast<DrmAllocation *>(&gfxAllocation);
63-
auto &drmContextIds = static_cast<const OsContextLinux *>(osContext)->getDrmContextIds();
64-
for (uint32_t drmIterator = 0u; drmIterator < drmContextIds.size(); drmIterator++) {
65-
drmAllocation->makeBOsResident(osContext, drmIterator, nullptr, false);
66-
}
67-
drmAllocation->updateResidencyTaskCount(GraphicsAllocation::objectNotResident, osContext->getContextId());
61+
auto drmAllocation = static_cast<DrmAllocation *>(&gfxAllocation);
62+
auto &drmContextIds = static_cast<const OsContextLinux *>(osContext)->getDrmContextIds();
63+
for (uint32_t drmIterator = 0u; drmIterator < drmContextIds.size(); drmIterator++) {
64+
drmAllocation->makeBOsResident(osContext, drmIterator, nullptr, false);
6865
}
66+
drmAllocation->updateResidencyTaskCount(GraphicsAllocation::objectNotResident, osContext->getContextId());
6967
return MemoryOperationsStatus::SUCCESS;
7068
}
7169

@@ -84,7 +82,7 @@ MemoryOperationsStatus DrmMemoryOperationsHandlerBind::isResident(Device *device
8482
}
8583

8684
void DrmMemoryOperationsHandlerBind::mergeWithResidencyContainer(OsContext *osContext, ResidencyContainer &residencyContainer) {
87-
this->makeResidentWithinOsContext(osContext, ArrayRef<GraphicsAllocation *>(residencyContainer));
85+
this->makeResidentWithinOsContext(osContext, ArrayRef<GraphicsAllocation *>(residencyContainer), true);
8886
residencyContainer.clear();
8987
}
9088

shared/source/os_interface/linux/drm_memory_operations_handler_bind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class DrmMemoryOperationsHandlerBind : public DrmMemoryOperationsHandler {
1414
DrmMemoryOperationsHandlerBind();
1515
~DrmMemoryOperationsHandlerBind() override;
1616

17-
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
17+
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable) override;
1818
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
1919
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override;
2020
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override;

shared/source/os_interface/linux/drm_memory_operations_handler_default.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ namespace NEO {
1616
DrmMemoryOperationsHandlerDefault::DrmMemoryOperationsHandlerDefault() = default;
1717
DrmMemoryOperationsHandlerDefault::~DrmMemoryOperationsHandlerDefault() = default;
1818

19-
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations) {
19+
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable) {
2020
std::lock_guard<std::mutex> lock(mutex);
2121
this->residency.insert(gfxAllocations.begin(), gfxAllocations.end());
2222
return MemoryOperationsStatus::SUCCESS;
2323
}
2424

2525
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) {
2626
OsContext *osContext = nullptr;
27-
return this->makeResidentWithinOsContext(osContext, gfxAllocations);
27+
return this->makeResidentWithinOsContext(osContext, gfxAllocations, false);
2828
}
2929

3030
MemoryOperationsStatus DrmMemoryOperationsHandlerDefault::evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) {

shared/source/os_interface/linux/drm_memory_operations_handler_default.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class DrmMemoryOperationsHandlerDefault : public DrmMemoryOperationsHandler {
1717
DrmMemoryOperationsHandlerDefault();
1818
~DrmMemoryOperationsHandlerDefault() override;
1919

20-
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
20+
MemoryOperationsStatus makeResidentWithinOsContext(OsContext *osContext, ArrayRef<GraphicsAllocation *> gfxAllocations, bool evictable) override;
2121
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
2222
MemoryOperationsStatus isResident(Device *device, GraphicsAllocation &gfxAllocation) override;
2323
MemoryOperationsStatus evictWithinOsContext(OsContext *osContext, GraphicsAllocation &gfxAllocation) override;

0 commit comments

Comments
 (0)