Skip to content

Commit f5e37e7

Browse files
Revert "fix: configure ISA Pool params based on productHelper"
This reverts commit bf20ae7. Signed-off-by: Fabian Zwoliński <[email protected]>
1 parent b32f726 commit f5e37e7

File tree

14 files changed

+22
-226
lines changed

14 files changed

+22
-226
lines changed

level_zero/core/source/module/module_imp.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,10 @@ void ModuleTranslationUnit::processDebugData() {
503503
ModuleImp::ModuleImp(Device *device, ModuleBuildLog *moduleBuildLog, ModuleType type)
504504
: device(device), translationUnit(std::make_unique<ModuleTranslationUnit>(device)),
505505
moduleBuildLog(moduleBuildLog), type(type) {
506+
auto &gfxCoreHelper = device->getGfxCoreHelper();
506507
auto &hwInfo = device->getHwInfo();
508+
this->isaAllocationPageSize = gfxCoreHelper.useSystemMemoryPlacementForISA(hwInfo) ? MemoryConstants::pageSize : MemoryConstants::pageSize64k;
507509
this->productFamily = hwInfo.platform.eProductFamily;
508-
this->isaAllocationPageSize = getIsaAllocationPageSize();
509510
}
510511

511512
ModuleImp::~ModuleImp() {
@@ -1720,19 +1721,4 @@ NEO::GraphicsAllocation *ModuleImp::getKernelsIsaParentAllocation() const {
17201721
return sharedIsaAllocation->getGraphicsAllocation();
17211722
}
17221723

1723-
size_t ModuleImp::getIsaAllocationPageSize() const {
1724-
auto &gfxCoreHelper = device->getGfxCoreHelper();
1725-
auto &hwInfo = device->getHwInfo();
1726-
1727-
if (gfxCoreHelper.useSystemMemoryPlacementForISA(hwInfo)) {
1728-
return MemoryConstants::pageSize;
1729-
}
1730-
1731-
if (device->getProductHelper().is2MBLocalMemAlignmentEnabled()) {
1732-
return MemoryConstants::pageSize2M;
1733-
} else {
1734-
return MemoryConstants::pageSize64k;
1735-
}
1736-
}
1737-
17381724
} // namespace L0

level_zero/core/source/module/module_imp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ struct ModuleImp : public Module {
190190
MOCKABLE_VIRTUAL size_t computeKernelIsaAllocationAlignedSizeWithPadding(size_t isaSize, bool lastKernel);
191191
MOCKABLE_VIRTUAL NEO::GraphicsAllocation *allocateKernelsIsaMemory(size_t size);
192192
StackVec<NEO::GraphicsAllocation *, 32> getModuleAllocations();
193-
size_t getIsaAllocationPageSize() const;
194193

195194
Device *device = nullptr;
196195
PRODUCT_FAMILY productFamily{};

level_zero/core/test/unit_tests/mocks/mock_module.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ struct WhiteBox<::L0::Module> : public ::L0::ModuleImp {
5858
using BaseClass::copyPatchedSegments;
5959
using BaseClass::device;
6060
using BaseClass::exportedFunctionsSurface;
61-
using BaseClass::getIsaAllocationPageSize;
6261
using BaseClass::importedSymbolAllocations;
6362
using BaseClass::isaSegmentsForPatching;
6463
using BaseClass::isFullyLinked;
@@ -112,7 +111,6 @@ struct MockModule : public L0::ModuleImp {
112111
using ModuleImp::allocateKernelsIsaMemory;
113112
using ModuleImp::computeKernelIsaAllocationAlignedSizeWithPadding;
114113
using ModuleImp::debugModuleHandle;
115-
using ModuleImp::getIsaAllocationPageSize;
116114
using ModuleImp::getModuleAllocations;
117115
using ModuleImp::initializeKernelImmutableDatas;
118116
using ModuleImp::isaAllocationPageSize;

level_zero/core/test/unit_tests/sources/module/test_module.cpp

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "shared/test/common/mocks/mock_l0_debugger.h"
3535
#include "shared/test/common/mocks/mock_memory_operations_handler.h"
3636
#include "shared/test/common/mocks/mock_modules_zebin.h"
37-
#include "shared/test/common/mocks/mock_product_helper.h"
3837
#include "shared/test/common/test_macros/hw_test.h"
3938

4039
#include "level_zero/core/source/kernel/kernel_imp.h"
@@ -175,6 +174,7 @@ HWTEST_F(ModuleTest, givenUserModuleWhenCreatedThenCorrectAllocationTypeIsUsedFo
175174

176175
template <bool localMemEnabled>
177176
struct ModuleKernelIsaAllocationsFixture : public ModuleFixture {
177+
static constexpr size_t isaAllocationPageSize = (localMemEnabled ? MemoryConstants::pageSize64k : MemoryConstants::pageSize);
178178
using Module = WhiteBox<::L0::Module>;
179179

180180
void setUp() {
@@ -209,7 +209,7 @@ struct ModuleKernelIsaAllocationsFixture : public ModuleFixture {
209209
void givenSeparateIsaMemoryRegionPerKernelWhenGraphicsAllocationFailsThenProperErrorReturned() {
210210
mockModule->allocateKernelsIsaMemoryCallBase = false;
211211
mockModule->computeKernelIsaAllocationAlignedSizeWithPaddingCallBase = false;
212-
mockModule->computeKernelIsaAllocationAlignedSizeWithPaddingResult = this->mockModule->getIsaAllocationPageSize();
212+
mockModule->computeKernelIsaAllocationAlignedSizeWithPaddingResult = isaAllocationPageSize;
213213

214214
auto result = module->initialize(&this->moduleDesc, device->getNEODevice());
215215
EXPECT_EQ(result, ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY);
@@ -793,35 +793,6 @@ HWTEST_F(ModuleTest, whenMultipleModulesCreatedThenModulesShareIsaAllocation) {
793793
}
794794
};
795795

796-
TEST_F(ModuleTest, GivenLocalMemoryEnabledOrDisabledAnd2MBAlignmentEnabledOrDisabledWhenGettingIsaAllocationPageSizeThenCorrectValueIsReturned) {
797-
DebugManagerStateRestore restorer;
798-
auto mockProductHelper = new MockProductHelper;
799-
800-
device->getNEODevice()->getRootDeviceEnvironmentRef().productHelper.reset(mockProductHelper);
801-
802-
MockModule mockModule{device, nullptr, ModuleType::user};
803-
EXPECT_EQ(mockModule.getIsaAllocationPageSize(), mockModule.isaAllocationPageSize);
804-
805-
{
806-
debugManager.flags.EnableLocalMemory.set(0);
807-
mockProductHelper->is2MBLocalMemAlignmentEnabledResult = true;
808-
809-
EXPECT_EQ(MemoryConstants::pageSize, mockModule.getIsaAllocationPageSize());
810-
}
811-
{
812-
debugManager.flags.EnableLocalMemory.set(1);
813-
mockProductHelper->is2MBLocalMemAlignmentEnabledResult = true;
814-
815-
EXPECT_EQ(MemoryConstants::pageSize2M, mockModule.getIsaAllocationPageSize());
816-
}
817-
{
818-
debugManager.flags.EnableLocalMemory.set(1);
819-
mockProductHelper->is2MBLocalMemAlignmentEnabledResult = false;
820-
821-
EXPECT_EQ(MemoryConstants::pageSize64k, mockModule.getIsaAllocationPageSize());
822-
}
823-
}
824-
825796
template <typename T1, typename T2>
826797
struct ModuleSpecConstantsFixture : public DeviceFixture {
827798
void setUp() {
@@ -4077,6 +4048,7 @@ TEST_F(ModuleTest, whenContainsStatefulAccessIsCalledThenResultIsCorrect) {
40774048

40784049
template <bool localMemEnabled>
40794050
struct ModuleIsaAllocationsFixture : public DeviceFixture {
4051+
static constexpr size_t isaAllocationPageSize = (localMemEnabled ? MemoryConstants::pageSize64k : MemoryConstants::pageSize);
40804052
static constexpr NEO::MemoryPool isaAllocationMemoryPool = (localMemEnabled ? NEO::MemoryPool::localMemory : NEO::MemoryPool::system4KBPagesWith32BitGpuAddressing);
40814053

40824054
void setUp() {
@@ -4092,7 +4064,6 @@ struct ModuleIsaAllocationsFixture : public DeviceFixture {
40924064
this->mockMemoryManager->localMemorySupported[this->neoDevice->getRootDeviceIndex()] = true;
40934065
this->mockModule.reset(new MockModule{this->device, nullptr, ModuleType::user});
40944066
this->mockModule->translationUnit.reset(new MockModuleTranslationUnit{this->device});
4095-
this->isaAllocationPageSize = this->mockModule->getIsaAllocationPageSize();
40964067
}
40974068

40984069
void tearDown() {
@@ -4148,8 +4119,8 @@ struct ModuleIsaAllocationsFixture : public DeviceFixture {
41484119
EXPECT_EQ(kernelImmDatas[1]->getIsaOffsetInParentAllocation(), 0lu);
41494120
EXPECT_EQ(kernelImmDatas[1]->getIsaSubAllocationSize(), 0lu);
41504121
if constexpr (localMemEnabled) {
4151-
EXPECT_EQ(alignUp<size_t>(maxAllocationSizeInPage, MemoryConstants::pageSize64k), kernelImmDatas[0]->getIsaSize());
4152-
EXPECT_EQ(alignUp<size_t>(tinyAllocationSize, MemoryConstants::pageSize64k), kernelImmDatas[1]->getIsaSize());
4122+
EXPECT_EQ(isaAllocationPageSize, kernelImmDatas[0]->getIsaSize());
4123+
EXPECT_EQ(isaAllocationPageSize, kernelImmDatas[1]->getIsaSize());
41534124
} else {
41544125
EXPECT_EQ(this->computeKernelIsaAllocationSizeWithPadding(maxAllocationSizeInPage), kernelImmDatas[0]->getIsaSize());
41554126
EXPECT_EQ(this->computeKernelIsaAllocationSizeWithPadding(tinyAllocationSize), kernelImmDatas[1]->getIsaSize());
@@ -4196,7 +4167,6 @@ struct ModuleIsaAllocationsFixture : public DeviceFixture {
41964167

41974168
size_t isaPadding;
41984169
size_t kernelStartPointerAlignment;
4199-
size_t isaAllocationPageSize;
42004170
NEO::Device *neoDevice = nullptr;
42014171
MockMemoryManager *mockMemoryManager = nullptr;
42024172
std::unique_ptr<MockModule> mockModule = nullptr;

opencl/test/unit_test/mem_obj/buffer_pool_alloc_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ TEST_F(AggregatedSmallBuffersEnabledTest, givenAggregatedSmallBuffersEnabledWhen
200200
EXPECT_TRUE(poolAllocator->isAggregatedSmallBuffersEnabled(context.get()));
201201
EXPECT_EQ(1u, poolAllocator->bufferPools.size());
202202
EXPECT_NE(nullptr, poolAllocator->bufferPools[0].mainStorage.get());
203-
EXPECT_NE(nullptr, mockMemoryManager->lastAllocationPropertiesWithPtr);
204-
EXPECT_TRUE(mockMemoryManager->lastAllocationPropertiesWithPtr->makeDeviceBufferLockable);
205-
EXPECT_FALSE(mockMemoryManager->lastAllocationPropertiesWithPtr->flags.preferCompressed);
203+
EXPECT_NE(nullptr, mockMemoryManager->lastAllocationProperties);
204+
EXPECT_TRUE(mockMemoryManager->lastAllocationProperties->makeDeviceBufferLockable);
205+
EXPECT_FALSE(mockMemoryManager->lastAllocationProperties->flags.preferCompressed);
206206
}
207207

208208
TEST_F(AggregatedSmallBuffersEnabledTest, givenAggregatedSmallBuffersEnabledAndSizeLargerThanThresholdWhenBufferCreateCalledThenDoNotUsePool) {

opencl/test/unit_test/program/kernel_info_tests.cpp

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "shared/source/program/kernel_info.h"
1111
#include "shared/test/common/mocks/mock_execution_environment.h"
1212
#include "shared/test/common/mocks/mock_graphics_allocation.h"
13-
#include "shared/test/common/mocks/mock_product_helper.h"
1413
#include "shared/test/common/mocks/mock_sip.h"
1514
#include "shared/test/common/mocks/ult_device_factory.h"
1615

@@ -85,62 +84,6 @@ TEST(KernelInfoTest, givenKernelInfoWhenCreatingKernelAllocationWithInternalIsaT
8584
device->getMemoryManager()->checkGpuUsageAndDestroyGraphicsAllocations(allocation);
8685
}
8786

88-
TEST(KernelInfoTest, Given2MBAlignmentEnabledByProductHelperWhenCreatingKernelAllocationThenAllocationPropertiesAlignmentIsSetTo2M) {
89-
DebugManagerStateRestore restorer;
90-
91-
KernelInfo kernelInfo;
92-
auto factory = UltDeviceFactory{1, 0};
93-
auto device = factory.rootDevices[0];
94-
const size_t heapSize = 0x40;
95-
char heap[heapSize];
96-
kernelInfo.heapInfo.kernelHeapSize = heapSize;
97-
kernelInfo.heapInfo.pKernelHeap = &heap;
98-
99-
auto mockProductHelper = new MockProductHelper;
100-
device->getRootDeviceEnvironmentRef().productHelper.reset(mockProductHelper);
101-
mockProductHelper->is2MBLocalMemAlignmentEnabledResult = true;
102-
debugManager.flags.AlignLocalMemoryVaTo2MB.set(0);
103-
104-
auto mockMemoryManager = static_cast<MockMemoryManager *>(device->getMemoryManager());
105-
mockMemoryManager->shouldStoreLastAllocationProperties = true;
106-
107-
auto retVal = kernelInfo.createKernelAllocation(*device, false);
108-
EXPECT_TRUE(retVal);
109-
110-
ASSERT_NE(nullptr, mockMemoryManager->lastAllocationProperties);
111-
EXPECT_EQ(MemoryConstants::pageSize2M, mockMemoryManager->lastAllocationProperties->alignment);
112-
113-
device->getMemoryManager()->checkGpuUsageAndDestroyGraphicsAllocations(kernelInfo.kernelAllocation);
114-
}
115-
116-
TEST(KernelInfoTest, Given2MBAlignmentForcedByDebugFlagWhenCreatingKernelAllocationThenAllocationPropertiesAlignmentIsSetTo2M) {
117-
DebugManagerStateRestore restorer;
118-
119-
KernelInfo kernelInfo;
120-
auto factory = UltDeviceFactory{1, 0};
121-
auto device = factory.rootDevices[0];
122-
const size_t heapSize = 0x40;
123-
char heap[heapSize];
124-
kernelInfo.heapInfo.kernelHeapSize = heapSize;
125-
kernelInfo.heapInfo.pKernelHeap = &heap;
126-
127-
auto mockProductHelper = new MockProductHelper;
128-
device->getRootDeviceEnvironmentRef().productHelper.reset(mockProductHelper);
129-
mockProductHelper->is2MBLocalMemAlignmentEnabledResult = false;
130-
debugManager.flags.AlignLocalMemoryVaTo2MB.set(1);
131-
132-
auto mockMemoryManager = static_cast<MockMemoryManager *>(device->getMemoryManager());
133-
mockMemoryManager->shouldStoreLastAllocationProperties = true;
134-
135-
auto retVal = kernelInfo.createKernelAllocation(*device, false);
136-
EXPECT_TRUE(retVal);
137-
138-
ASSERT_NE(nullptr, mockMemoryManager->lastAllocationProperties);
139-
EXPECT_EQ(MemoryConstants::pageSize2M, mockMemoryManager->lastAllocationProperties->alignment);
140-
141-
device->getMemoryManager()->checkGpuUsageAndDestroyGraphicsAllocations(kernelInfo.kernelAllocation);
142-
}
143-
14487
class MyMemoryManager : public OsAgnosticMemoryManager {
14588
public:
14689
using OsAgnosticMemoryManager::OsAgnosticMemoryManager;

shared/source/os_interface/linux/drm_memory_manager.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,10 +1881,11 @@ void fillGmmsInAllocation(GmmHelper *gmmHelper, DrmAllocation *allocation) {
18811881
}
18821882
}
18831883

1884-
inline uint64_t getCanonizedHeapAllocationAddress(HeapIndex heap, GmmHelper *gmmHelper, GfxPartition *gfxPartition, size_t &sizeAllocated, size_t alignment, bool packed) {
1885-
if (const size_t customAlignment = static_cast<size_t>(debugManager.flags.ExperimentalEnableCustomLocalMemoryAlignment.get());
1886-
customAlignment > 0) {
1887-
alignment = customAlignment;
1884+
inline uint64_t getCanonizedHeapAllocationAddress(HeapIndex heap, GmmHelper *gmmHelper, GfxPartition *gfxPartition, size_t &sizeAllocated, bool packed) {
1885+
size_t alignment = 0;
1886+
1887+
if (debugManager.flags.ExperimentalEnableCustomLocalMemoryAlignment.get() != -1) {
1888+
alignment = static_cast<size_t>(debugManager.flags.ExperimentalEnableCustomLocalMemoryAlignment.get());
18881889
}
18891890
auto address = gfxPartition->heapAllocateWithCustomAlignment(heap, sizeAllocated, alignment);
18901891
return gmmHelper->canonize(address);
@@ -1904,15 +1905,10 @@ AllocationStatus getGpuAddress(const AlignmentSelector &alignmentSelector, HeapA
19041905
case AllocationType::kernelIsa:
19051906
case AllocationType::kernelIsaInternal:
19061907
case AllocationType::internalHeap:
1907-
case AllocationType::debugModuleArea: {
1908-
size_t alignment = 0;
1909-
if (gmmHelper->getRootDeviceEnvironment().getHelper<ProductHelper>().is2MBLocalMemAlignmentEnabled()) {
1910-
alignment = MemoryConstants::pageSize2M;
1911-
}
1908+
case AllocationType::debugModuleArea:
19121909
gpuAddress = getCanonizedHeapAllocationAddress(heapAssigner.get32BitHeapIndex(allocType, true, hwInfo, allocationData.flags.use32BitFrontWindow),
1913-
gmmHelper, gfxPartition, sizeAllocated, alignment, false);
1910+
gmmHelper, gfxPartition, sizeAllocated, false);
19141911
break;
1915-
}
19161912
case AllocationType::writeCombined:
19171913
sizeAllocated = 0;
19181914
break;

shared/source/program/kernel_info.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ bool KernelInfo::createKernelAllocation(const Device &device, bool internalIsa)
6262

6363
AllocationProperties properties = {device.getRootDeviceIndex(), kernelIsaSize, allocType, device.getDeviceBitfield()};
6464

65-
if (device.getProductHelper().is2MBLocalMemAlignmentEnabled() ||
66-
debugManager.flags.AlignLocalMemoryVaTo2MB.get() == 1) {
65+
if (debugManager.flags.AlignLocalMemoryVaTo2MB.get() == 1) {
6766
properties.alignment = MemoryConstants::pageSize2M;
6867
}
6968

shared/source/utilities/isa_pool_allocator.cpp

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include "shared/source/utilities/isa_pool_allocator.h"
99

1010
#include "shared/source/device/device.h"
11-
#include "shared/source/helpers/aligned_memory.h"
1211
#include "shared/source/memory_manager/allocation_properties.h"
1312
#include "shared/source/memory_manager/memory_manager.h"
1413
#include "shared/source/utilities/buffer_pool_allocator.inl"
@@ -17,9 +16,6 @@ namespace NEO {
1716

1817
ISAPool::ISAPool(Device *device, bool isBuiltin, size_t storageSize)
1918
: BaseType(device->getMemoryManager(), nullptr), device(device), isBuiltin(isBuiltin) {
20-
DEBUG_BREAK_IF(device->getProductHelper().is2MBLocalMemAlignmentEnabled() &&
21-
!isAligned(storageSize, MemoryConstants::pageSize2M));
22-
2319
this->chunkAllocator.reset(new NEO::HeapAllocator(params.startingOffset, storageSize, MemoryConstants::pageSize, 0u));
2420

2521
auto allocationType = isBuiltin ? NEO::AllocationType::kernelIsaInternal : NEO::AllocationType::kernelIsa;
@@ -59,7 +55,6 @@ const StackVec<NEO::GraphicsAllocation *, 1> &ISAPool::getAllocationsVector() {
5955
}
6056

6157
ISAPoolAllocator::ISAPoolAllocator(Device *device) : device(device) {
62-
initAllocParams();
6358
}
6459

6560
/**
@@ -81,7 +76,7 @@ SharedIsaAllocation *ISAPoolAllocator::requestGraphicsAllocationForIsa(bool isBu
8176
auto maxAllocationSize = getAllocationSize(isBuiltin);
8277

8378
if (size > maxAllocationSize) {
84-
addNewBufferPool(ISAPool(device, isBuiltin, alignToPoolSize(size)));
79+
addNewBufferPool(ISAPool(device, isBuiltin, size));
8580
}
8681

8782
auto sharedIsaAllocation = tryAllocateISA(isBuiltin, size);
@@ -96,7 +91,7 @@ SharedIsaAllocation *ISAPoolAllocator::requestGraphicsAllocationForIsa(bool isBu
9691
return sharedIsaAllocation;
9792
}
9893

99-
addNewBufferPool(ISAPool(device, isBuiltin, alignToPoolSize(getAllocationSize(isBuiltin))));
94+
addNewBufferPool(ISAPool(device, isBuiltin, getAllocationSize(isBuiltin)));
10095
return tryAllocateISA(isBuiltin, size);
10196
}
10297

@@ -135,19 +130,4 @@ SharedIsaAllocation *ISAPoolAllocator::tryAllocateISA(bool isBuiltin, size_t siz
135130
return nullptr;
136131
}
137132

138-
void ISAPoolAllocator::initAllocParams() {
139-
if (device->getProductHelper().is2MBLocalMemAlignmentEnabled()) {
140-
userAllocationSize = MemoryConstants::pageSize2M * 2;
141-
buitinAllocationSize = MemoryConstants::pageSize2M;
142-
poolAlignment = MemoryConstants::pageSize2M;
143-
} else {
144-
userAllocationSize = MemoryConstants::pageSize2M * 2;
145-
buitinAllocationSize = MemoryConstants::pageSize64k;
146-
}
147-
}
148-
149-
size_t ISAPoolAllocator::alignToPoolSize(size_t size) const {
150-
return alignUp(size, poolAlignment);
151-
}
152-
153133
} // namespace NEO

shared/source/utilities/isa_pool_allocator.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,15 @@ class ISAPoolAllocator : public AbstractBuffersAllocator<ISAPool, GraphicsAlloca
7373
void freeSharedIsaAllocation(SharedIsaAllocation *sharedIsaAllocation);
7474

7575
private:
76-
void initAllocParams();
7776
SharedIsaAllocation *tryAllocateISA(bool isBuiltin, size_t size);
77+
7878
size_t getAllocationSize(bool isBuiltin) const {
7979
return isBuiltin ? buitinAllocationSize : userAllocationSize;
8080
}
81-
size_t alignToPoolSize(size_t size) const;
8281

8382
Device *device;
8483
size_t userAllocationSize = MemoryConstants::pageSize2M * 2;
8584
size_t buitinAllocationSize = MemoryConstants::pageSize64k;
86-
size_t poolAlignment = 1u;
8785
std::mutex allocatorMtx;
8886
};
8987

0 commit comments

Comments
 (0)