@@ -182,7 +182,6 @@ HWTEST_F(ModuleTest, givenUserModuleWhenCreatedThenCorrectAllocationTypeIsUsedFo
182182
183183template <bool localMemEnabled>
184184struct ModuleKernelIsaAllocationsFixture : public ModuleFixture {
185- static constexpr size_t isaAllocationPageSize = (localMemEnabled ? MemoryConstants::pageSize64k : MemoryConstants::pageSize);
186185 using Module = WhiteBox<::L0::Module>;
187186
188187 void setUp () {
@@ -217,7 +216,7 @@ struct ModuleKernelIsaAllocationsFixture : public ModuleFixture {
217216 void givenSeparateIsaMemoryRegionPerKernelWhenGraphicsAllocationFailsThenProperErrorReturned () {
218217 mockModule->allocateKernelsIsaMemoryCallBase = false ;
219218 mockModule->computeKernelIsaAllocationAlignedSizeWithPaddingCallBase = false ;
220- mockModule->computeKernelIsaAllocationAlignedSizeWithPaddingResult = isaAllocationPageSize ;
219+ mockModule->computeKernelIsaAllocationAlignedSizeWithPaddingResult = this -> mockModule -> getIsaAllocationPageSize () ;
221220
222221 auto result = module ->initialize (&this ->moduleDesc , device->getNEODevice ());
223222 EXPECT_EQ (result, ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY);
@@ -806,6 +805,35 @@ HWTEST_F(ModuleTest, whenMultipleModulesCreatedThenModulesShareIsaAllocation) {
806805 }
807806};
808807
808+ TEST_F (ModuleTest, GivenLocalMemoryEnabledOrDisabledAnd2MBAlignmentEnabledOrDisabledWhenGettingIsaAllocationPageSizeThenCorrectValueIsReturned) {
809+ DebugManagerStateRestore restorer;
810+
811+ auto mockProductHelper = new MockProductHelper;
812+ device->getNEODevice ()->getRootDeviceEnvironmentRef ().productHelper .reset (mockProductHelper);
813+
814+ MockModule mockModule{device, nullptr , ModuleType::user};
815+ EXPECT_EQ (mockModule.getIsaAllocationPageSize (), mockModule.isaAllocationPageSize );
816+
817+ {
818+ debugManager.flags .EnableLocalMemory .set (0 );
819+ mockProductHelper->is2MBLocalMemAlignmentEnabledResult = true ;
820+
821+ EXPECT_EQ (MemoryConstants::pageSize, mockModule.getIsaAllocationPageSize ());
822+ }
823+ {
824+ debugManager.flags .EnableLocalMemory .set (1 );
825+ mockProductHelper->is2MBLocalMemAlignmentEnabledResult = true ;
826+
827+ EXPECT_EQ (MemoryConstants::pageSize2M, mockModule.getIsaAllocationPageSize ());
828+ }
829+ {
830+ debugManager.flags .EnableLocalMemory .set (1 );
831+ mockProductHelper->is2MBLocalMemAlignmentEnabledResult = false ;
832+
833+ EXPECT_EQ (MemoryConstants::pageSize64k, mockModule.getIsaAllocationPageSize ());
834+ }
835+ }
836+
809837template <typename T1, typename T2>
810838struct ModuleSpecConstantsFixture : public DeviceFixture {
811839 void setUp () {
@@ -4347,7 +4375,6 @@ TEST_F(ModuleTest, whenContainsStatefulAccessIsCalledThenResultIsCorrect) {
43474375
43484376template <bool localMemEnabled>
43494377struct ModuleIsaAllocationsFixture : public DeviceFixture {
4350- static constexpr size_t isaAllocationPageSize = (localMemEnabled ? MemoryConstants::pageSize64k : MemoryConstants::pageSize);
43514378 static constexpr NEO::MemoryPool isaAllocationMemoryPool = (localMemEnabled ? NEO::MemoryPool::localMemory : NEO::MemoryPool::system4KBPagesWith32BitGpuAddressing);
43524379
43534380 void setUp () {
@@ -4363,6 +4390,7 @@ struct ModuleIsaAllocationsFixture : public DeviceFixture {
43634390 this ->mockMemoryManager ->localMemorySupported [this ->neoDevice ->getRootDeviceIndex ()] = true ;
43644391 this ->mockModule .reset (new MockModule{this ->device , nullptr , ModuleType::user});
43654392 this ->mockModule ->translationUnit .reset (new MockModuleTranslationUnit{this ->device });
4393+ this ->isaAllocationPageSize = this ->mockModule ->getIsaAllocationPageSize ();
43664394 }
43674395
43684396 void tearDown () {
@@ -4418,8 +4446,8 @@ struct ModuleIsaAllocationsFixture : public DeviceFixture {
44184446 EXPECT_EQ (kernelImmData[1 ]->getIsaOffsetInParentAllocation (), 0lu);
44194447 EXPECT_EQ (kernelImmData[1 ]->getIsaSubAllocationSize (), 0lu);
44204448 if constexpr (localMemEnabled) {
4421- EXPECT_EQ (isaAllocationPageSize , kernelImmData[0 ]->getIsaSize ());
4422- EXPECT_EQ (isaAllocationPageSize , kernelImmData[1 ]->getIsaSize ());
4449+ EXPECT_EQ (alignUp< size_t >(maxAllocationSizeInPage, MemoryConstants::pageSize64k) , kernelImmData[0 ]->getIsaSize ());
4450+ EXPECT_EQ (alignUp< size_t >(tinyAllocationSize, MemoryConstants::pageSize64k) , kernelImmData[1 ]->getIsaSize ());
44234451 } else {
44244452 EXPECT_EQ (this ->computeKernelIsaAllocationSizeWithPadding (maxAllocationSizeInPage), kernelImmData[0 ]->getIsaSize ());
44254453 EXPECT_EQ (this ->computeKernelIsaAllocationSizeWithPadding (tinyAllocationSize), kernelImmData[1 ]->getIsaSize ());
@@ -4466,6 +4494,7 @@ struct ModuleIsaAllocationsFixture : public DeviceFixture {
44664494
44674495 size_t isaPadding;
44684496 size_t kernelStartPointerAlignment;
4497+ size_t isaAllocationPageSize;
44694498 NEO::Device *neoDevice = nullptr ;
44704499 MockMemoryManager *mockMemoryManager = nullptr ;
44714500 std::unique_ptr<MockModule> mockModule = nullptr ;
0 commit comments