Skip to content

Commit ac0471a

Browse files
Remove padding allocation
Change-Id: I0017640ee22b687af1d85fa10d221d2b3cafed0a Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
1 parent b544b2d commit ac0471a

File tree

7 files changed

+9
-53
lines changed

7 files changed

+9
-53
lines changed

runtime/memory_manager/memory_manager.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ void MemoryManager::cleanGraphicsMemoryCreatedFromHostPtr(GraphicsAllocation *gr
118118
}
119119

120120
GraphicsAllocation *MemoryManager::createGraphicsAllocationWithPadding(GraphicsAllocation *inputGraphicsAllocation, size_t sizeWithPadding) {
121-
if (!paddingAllocation) {
122-
paddingAllocation = allocateGraphicsMemoryWithProperties({inputGraphicsAllocation->getRootDeviceIndex(), paddingBufferSize, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY});
123-
}
124121
return createPaddedAllocation(inputGraphicsAllocation, sizeWithPadding);
125122
}
126123

@@ -132,12 +129,6 @@ void MemoryManager::freeSystemMemory(void *ptr) {
132129
::alignedFree(ptr);
133130
}
134131

135-
void MemoryManager::applyCommonCleanup() {
136-
if (this->paddingAllocation) {
137-
this->freeGraphicsMemory(this->paddingAllocation);
138-
}
139-
}
140-
141132
void MemoryManager::freeGraphicsMemory(GraphicsAllocation *gfxAllocation) {
142133
if (!gfxAllocation) {
143134
return;

runtime/memory_manager/memory_manager.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ class MemoryManager {
110110

111111
bool peekVirtualPaddingSupport() const { return virtualPaddingAvailable; }
112112
void setVirtualPaddingSupport(bool virtualPaddingSupport) { virtualPaddingAvailable = virtualPaddingSupport; }
113-
GraphicsAllocation *peekPaddingAllocation() { return paddingAllocation; }
114113

115114
DeferredDeleter *getDeferredDeleter() const {
116115
return deferredDeleter.get();
@@ -213,8 +212,6 @@ class MemoryManager {
213212

214213
bool force32bitAllocations = false;
215214
bool virtualPaddingAvailable = false;
216-
GraphicsAllocation *paddingAllocation = nullptr;
217-
void applyCommonCleanup();
218215
std::unique_ptr<DeferredDeleter> deferredDeleter;
219216
bool asyncDeleterEnabled = false;
220217
bool enable64kbpages = false;

runtime/memory_manager/os_agnostic_memory_manager.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ OsAgnosticMemoryManager::OsAgnosticMemoryManager(bool aubUsage, ExecutionEnviron
3737
}
3838
}
3939

40-
OsAgnosticMemoryManager::~OsAgnosticMemoryManager() {
41-
applyCommonCleanup();
42-
}
40+
OsAgnosticMemoryManager::~OsAgnosticMemoryManager() = default;
4341

4442
struct OsHandle {
4543
};

runtime/os_interface/linux/drm_memory_manager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ DrmMemoryManager::DrmMemoryManager(gemCloseWorkerMode mode,
6161
}
6262

6363
DrmMemoryManager::~DrmMemoryManager() {
64-
applyCommonCleanup();
6564
if (gemCloseWorker) {
6665
gemCloseWorker->close(false);
6766
}

runtime/os_interface/windows/wddm_memory_manager.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@
3434

3535
namespace NEO {
3636

37-
WddmMemoryManager::~WddmMemoryManager() {
38-
applyCommonCleanup();
39-
}
37+
WddmMemoryManager::~WddmMemoryManager() = default;
4038

4139
WddmMemoryManager::WddmMemoryManager(ExecutionEnvironment &executionEnvironment) : MemoryManager(executionEnvironment),
4240
wddm(executionEnvironment.osInterface->get()->getWddm()) {

unit_tests/memory_manager/memory_manager_tests.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -962,29 +962,6 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenGraphicsAllocationIsP
962962
ASSERT_NE(nullptr, paddedGraphicsAllocation);
963963
EXPECT_NE(paddedGraphicsAllocation, graphicsAllocation);
964964

965-
//padding buffer was created
966-
ASSERT_NE(nullptr, memoryManager.peekPaddingAllocation());
967-
auto paddingAllocation = memoryManager.peekPaddingAllocation();
968-
EXPECT_EQ(paddingBufferSize, paddingAllocation->getUnderlyingBufferSize());
969-
970-
memoryManager.freeGraphicsMemory(paddedGraphicsAllocation);
971-
memoryManager.freeGraphicsMemory(graphicsAllocation);
972-
}
973-
974-
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenTwoGraphicsAllocationArePaddedThenOnlyOnePaddingBufferIsUsed) {
975-
MockExecutionEnvironment executionEnvironment(*platformDevices);
976-
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, false, executionEnvironment);
977-
auto graphicsAllocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
978-
979-
auto sizeWithPadding = 8192;
980-
auto paddedGraphicsAllocation = memoryManager.createGraphicsAllocationWithPadding(graphicsAllocation, sizeWithPadding);
981-
auto paddingAllocation = memoryManager.peekPaddingAllocation();
982-
auto paddedGraphicsAllocation2 = memoryManager.createGraphicsAllocationWithPadding(graphicsAllocation, sizeWithPadding);
983-
auto paddingAllocation2 = memoryManager.peekPaddingAllocation();
984-
985-
EXPECT_EQ(paddingAllocation2, paddingAllocation);
986-
987-
memoryManager.freeGraphicsMemory(paddedGraphicsAllocation2);
988965
memoryManager.freeGraphicsMemory(paddedGraphicsAllocation);
989966
memoryManager.freeGraphicsMemory(graphicsAllocation);
990967
}

unit_tests/os_interface/linux/drm_memory_manager_tests.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2122,18 +2122,16 @@ TEST_F(DrmMemoryManagerTest, givenSharedAllocationWithSmallerThenRealSizeWhenCre
21222122
}
21232123

21242124
TEST_F(DrmMemoryManagerTest, givenMemoryManagerSupportingVirutalPaddingWhenItIsRequiredThenNewGraphicsAllocationIsCreated) {
2125-
mock->ioctl_expected.gemUserptr = 3;
2126-
mock->ioctl_expected.gemWait = 3;
2127-
mock->ioctl_expected.gemClose = 3;
2125+
mock->ioctl_expected.gemUserptr = 2;
2126+
mock->ioctl_expected.gemWait = 2;
2127+
mock->ioctl_expected.gemClose = 2;
21282128
//first let's create normal buffer
21292129
auto bufferSize = MemoryConstants::pageSize;
21302130
auto buffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{bufferSize});
21312131

21322132
//buffer should have size 16
21332133
EXPECT_EQ(bufferSize, buffer->getUnderlyingBufferSize());
21342134

2135-
EXPECT_EQ(nullptr, memoryManager->peekPaddingAllocation());
2136-
21372135
auto bufferWithPaddingSize = 8192u;
21382136
auto paddedAllocation = memoryManager->createGraphicsAllocationWithPadding(buffer, 8192u);
21392137
EXPECT_NE(nullptr, paddedAllocation);
@@ -2277,10 +2275,10 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit
22772275
}
22782276

22792277
TEST_F(DrmMemoryManagerTest, givenMemoryManagerSupportingVirutalPaddingWhenAllocUserptrFailsThenReturnsNullptr) {
2280-
mock->ioctl_expected.gemUserptr = 3;
2281-
mock->ioctl_expected.gemWait = 2;
2282-
mock->ioctl_expected.gemClose = 2;
2283-
this->ioctlResExt = {mock->ioctl_cnt.total + 2, -1};
2278+
mock->ioctl_expected.gemUserptr = 2;
2279+
mock->ioctl_expected.gemWait = 1;
2280+
mock->ioctl_expected.gemClose = 1;
2281+
this->ioctlResExt = {mock->ioctl_cnt.total + 1, -1};
22842282
mock->ioctl_res_ext = &ioctlResExt;
22852283

22862284
//first let's create normal buffer
@@ -2290,8 +2288,6 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerSupportingVirutalPaddingWhenAlloc
22902288
//buffer should have size 16
22912289
EXPECT_EQ(bufferSize, buffer->getUnderlyingBufferSize());
22922290

2293-
EXPECT_EQ(nullptr, memoryManager->peekPaddingAllocation());
2294-
22952291
auto bufferWithPaddingSize = 8192u;
22962292
auto paddedAllocation = memoryManager->createGraphicsAllocationWithPadding(buffer, bufferWithPaddingSize);
22972293
EXPECT_EQ(nullptr, paddedAllocation);

0 commit comments

Comments
 (0)