Revert "performance: remove page size limit for sharing ISAs"

This reverts commit e7c036a91b.

Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
Compute-Runtime-Validation
2024-05-12 08:32:38 +02:00
committed by Compute-Runtime-Automation
parent 741474208e
commit de789ac7e5
4 changed files with 77 additions and 22 deletions

View File

@@ -805,7 +805,7 @@ ze_result_t ModuleImp::setIsaGraphicsAllocations() {
}
bool debuggerDisabled = (this->device->getL0Debugger() == nullptr);
if (debuggerDisabled) {
if (debuggerDisabled && kernelsIsaTotalSize <= isaAllocationPageSize) {
auto neoDevice = this->device->getNEODevice();
auto &isaAllocator = neoDevice->getIsaPoolAllocator();
auto crossModuleAllocation = isaAllocator.requestGraphicsAllocationForIsa(this->type == ModuleType::builtin, kernelsIsaTotalSize);

View File

@@ -828,7 +828,24 @@ TEST_F(KernelImmutableDataTests, givenInternalModuleWhenKernelIsCreatedThenIsaIs
mockMemoryManager->copyMemoryToAllocationCalledTimes);
}
TEST_F(KernelImmutableDataTests, givenInternalModuleWhenKernelIsCreatedThenIsaCopiedDuringLinking) {
struct KernelIsaCopyingMomentTest : public ModuleImmutableDataFixture, public ::testing::TestWithParam<std::pair<uint32_t, size_t>> {
void SetUp() override {
ModuleImmutableDataFixture::setUp();
}
void TearDown() override {
ModuleImmutableDataFixture::tearDown();
}
};
std::pair<uint32_t, size_t> kernelIsaCopyingPairs[] = {
{1, 1},
{static_cast<uint32_t>(MemoryConstants::pageSize64k + 1), 0}}; // pageSize64 is a common upper-bound for both system and local memory
INSTANTIATE_TEST_CASE_P(, KernelIsaCopyingMomentTest, testing::ValuesIn(kernelIsaCopyingPairs));
TEST_P(KernelIsaCopyingMomentTest, givenInternalModuleWhenKernelIsCreatedThenIsaCopiedDuringLinkingOnlyIfCanFitInACommonParentPage) {
auto [testKernelHeapSize, numberOfCopiesToAllocationAtModuleInitialization] = GetParam();
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->compilerInterface.reset(cip);
@@ -849,11 +866,11 @@ TEST_F(KernelImmutableDataTests, givenInternalModuleWhenKernelIsCreatedThenIsaCo
moduleMock->translationUnit->programInfo.linkerInput = std::move(linkerInput);
auto mockTranslationUnit = toMockPtr(moduleMock->translationUnit.get());
mockTranslationUnit->processUnpackedBinaryCallBase = false;
uint32_t testKernelHeapSize = MemoryConstants::pageSize;
auto kernelHeap = new char[testKernelHeapSize];
uint32_t kernelHeap = 0;
auto kernelInfo = new KernelInfo();
kernelInfo->heapInfo.kernelHeapSize = testKernelHeapSize;
kernelInfo->heapInfo.pKernelHeap = kernelHeap;
kernelInfo->heapInfo.pKernelHeap = &kernelHeap;
Mock<::L0::KernelImp> kernelMock;
kernelMock.module = moduleMock.get();
@@ -866,15 +883,24 @@ TEST_F(KernelImmutableDataTests, givenInternalModuleWhenKernelIsCreatedThenIsaCo
moduleMock->translationUnit->programInfo.kernelInfos.push_back(kernelInfo);
moduleMock->kernelImmData = &kernelMock.immutableData;
size_t previouscopyMemoryToAllocationCalledTimes = mockMemoryManager->copyMemoryToAllocationCalledTimes;
ze_result_t result = ZE_RESULT_ERROR_MODULE_BUILD_FAILURE;
auto initialAmountOfCopies = mockMemoryManager->copyMemoryToAllocationCalledTimes;
result = moduleMock->initialize(&moduleDesc, neoDevice);
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
EXPECT_EQ(mockTranslationUnit->processUnpackedBinaryCalled, 1u);
EXPECT_EQ(mockMemoryManager->copyMemoryToAllocationCalledTimes, 1u + initialAmountOfCopies);
size_t expectedPreviouscopyMemoryToAllocationCalledTimes = previouscopyMemoryToAllocationCalledTimes +
numberOfCopiesToAllocationAtModuleInitialization;
EXPECT_EQ(expectedPreviouscopyMemoryToAllocationCalledTimes, mockMemoryManager->copyMemoryToAllocationCalledTimes);
for (auto &ki : moduleMock->kernelImmDatas) {
EXPECT_TRUE(ki->isIsaCopiedToAllocation());
bool isaExpectedToBeCopied = (numberOfCopiesToAllocationAtModuleInitialization != 0u);
EXPECT_EQ(isaExpectedToBeCopied, ki->isIsaCopiedToAllocation());
}
if (numberOfCopiesToAllocationAtModuleInitialization == 0) {
// For large builtin kernels copying is not optimized and done at kernel initailization
expectedPreviouscopyMemoryToAllocationCalledTimes++;
}
ze_kernel_desc_t desc = {};
@@ -884,8 +910,7 @@ TEST_F(KernelImmutableDataTests, givenInternalModuleWhenKernelIsCreatedThenIsaCo
kernelMock.initialize(&desc);
EXPECT_EQ(mockMemoryManager->copyMemoryToAllocationCalledTimes, 1u + initialAmountOfCopies);
delete[] kernelHeap;
EXPECT_EQ(expectedPreviouscopyMemoryToAllocationCalledTimes, mockMemoryManager->copyMemoryToAllocationCalledTimes);
}
TEST_F(KernelImmutableDataTests, givenKernelInitializedWithPrivateMemoryThenContainerHasOneExtraSpaceForAllocation) {

View File

@@ -202,13 +202,11 @@ struct ModuleKernelIsaAllocationsFixture : public ModuleFixture {
device->getNEODevice()->getIsaPoolAllocator().freeSharedIsaAllocation(alloc);
}
template <typename FamilyType>
void givenSeparateIsaMemoryRegionPerKernelWhenGraphicsAllocationFailsThenProperErrorReturned() {
mockModule->allocateKernelsIsaMemoryCallBase = false;
mockModule->computeKernelIsaAllocationAlignedSizeWithPaddingCallBase = false;
mockModule->computeKernelIsaAllocationAlignedSizeWithPaddingResult = isaAllocationPageSize;
auto debugger = MockDebuggerL0Hw<FamilyType>::allocate(device->getNEODevice());
device->getNEODevice()->getRootDeviceEnvironmentRef().debugger.reset(debugger);
auto result = module->initialize(&this->moduleDesc, device->getNEODevice());
EXPECT_EQ(result, ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY);
}
@@ -225,7 +223,7 @@ HWTEST_F(ModuleKernelIsaAllocationsInLocalMemoryTests, givenIsaMemoryRegionShare
}
HWTEST_F(ModuleKernelIsaAllocationsInLocalMemoryTests, givenSeparateIsaMemoryRegionPerKernelWhenGraphicsAllocationFailsThenProperErrorReturned) {
this->givenSeparateIsaMemoryRegionPerKernelWhenGraphicsAllocationFailsThenProperErrorReturned<FamilyType>();
this->givenSeparateIsaMemoryRegionPerKernelWhenGraphicsAllocationFailsThenProperErrorReturned();
}
using ModuleKernelIsaAllocationsInSharedMemoryTests = Test<ModuleKernelIsaAllocationsFixture<false>>;
@@ -235,7 +233,7 @@ HWTEST_F(ModuleKernelIsaAllocationsInSharedMemoryTests, givenIsaMemoryRegionShar
}
HWTEST_F(ModuleKernelIsaAllocationsInSharedMemoryTests, givenSeparateIsaMemoryRegionPerKernelWhenGraphicsAllocationFailsThenProperErrorReturned) {
this->givenSeparateIsaMemoryRegionPerKernelWhenGraphicsAllocationFailsThenProperErrorReturned<FamilyType>();
this->givenSeparateIsaMemoryRegionPerKernelWhenGraphicsAllocationFailsThenProperErrorReturned();
}
HWTEST_F(ModuleTest, givenBuiltinModuleWhenCreatedThenCorrectAllocationTypeIsUsedForIsa) {
@@ -3827,7 +3825,7 @@ struct ModuleIsaAllocationsFixture : public DeviceFixture {
}
template <typename FamilyType>
void givenMultipleKernelIsasAndDebuggerEnabledWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations() {
void givenMultipleKernelIsasWhichFitInSinglePageAndDebuggerEnabledWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations() {
auto requestedSize = 0x40;
this->prepareKernelInfoAndAddToTranslationUnit(requestedSize);
this->prepareKernelInfoAndAddToTranslationUnit(requestedSize);
@@ -3843,6 +3841,32 @@ struct ModuleIsaAllocationsFixture : public DeviceFixture {
EXPECT_NE(nullptr, kernelImmDatas[1]->getIsaGraphicsAllocation());
}
void givenMultipleKernelIsasWhichExceedSinglePageWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations() {
auto maxAllocationSizeInPage = alignDown(isaAllocationPageSize - this->isaPadding, this->kernelStartPointerAlignment);
this->prepareKernelInfoAndAddToTranslationUnit(maxAllocationSizeInPage);
auto tinyAllocationSize = 0x8;
this->prepareKernelInfoAndAddToTranslationUnit(tinyAllocationSize);
this->mockModule->initializeKernelImmutableDatas();
auto &kernelImmDatas = this->mockModule->getKernelImmutableDataVector();
EXPECT_EQ(nullptr, kernelImmDatas[0]->getIsaParentAllocation());
EXPECT_NE(nullptr, kernelImmDatas[0]->getIsaGraphicsAllocation());
EXPECT_EQ(kernelImmDatas[0]->getIsaOffsetInParentAllocation(), 0lu);
EXPECT_EQ(kernelImmDatas[0]->getIsaSubAllocationSize(), 0lu);
EXPECT_EQ(nullptr, kernelImmDatas[1]->getIsaParentAllocation());
EXPECT_NE(nullptr, kernelImmDatas[1]->getIsaGraphicsAllocation());
EXPECT_EQ(kernelImmDatas[1]->getIsaOffsetInParentAllocation(), 0lu);
EXPECT_EQ(kernelImmDatas[1]->getIsaSubAllocationSize(), 0lu);
if constexpr (localMemEnabled) {
EXPECT_EQ(isaAllocationPageSize, kernelImmDatas[0]->getIsaSize());
EXPECT_EQ(isaAllocationPageSize, kernelImmDatas[1]->getIsaSize());
} else {
EXPECT_EQ(this->computeKernelIsaAllocationSizeWithPadding(maxAllocationSizeInPage), kernelImmDatas[0]->getIsaSize());
EXPECT_EQ(this->computeKernelIsaAllocationSizeWithPadding(tinyAllocationSize), kernelImmDatas[1]->getIsaSize());
}
}
struct ProxyKernelImmutableData : public KernelImmutableData {
using BaseClass = KernelImmutableData;
using BaseClass::BaseClass;
@@ -3916,8 +3940,12 @@ TEST_F(ModuleIsaAllocationsInLocalMemoryTest, givenMultipleKernelIsasWhichFitInS
EXPECT_EQ(kernelImmDatas[1]->getIsaGraphicsAllocation()->getMemoryPool(), isaAllocationMemoryPool);
}
HWTEST_F(ModuleIsaAllocationsInLocalMemoryTest, givenMultipleKernelIsasAndDebuggerEnabledWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations) {
this->givenMultipleKernelIsasAndDebuggerEnabledWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations<FamilyType>();
HWTEST_F(ModuleIsaAllocationsInLocalMemoryTest, givenMultipleKernelIsasWhichFitInSinglePage64KAndDebuggerEnabledWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations) {
this->givenMultipleKernelIsasWhichFitInSinglePageAndDebuggerEnabledWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations<FamilyType>();
}
TEST_F(ModuleIsaAllocationsInLocalMemoryTest, givenMultipleKernelIsasWhichExceedSinglePage64KWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations) {
this->givenMultipleKernelIsasWhichExceedSinglePageWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations();
}
TEST_F(ModuleIsaAllocationsInLocalMemoryTest, givenMultipleKernelIsasWhenKernelInitializationFailsThenItIsProperlyCleanedAndPreviouslyInitializedKernelsLeftUntouched) {
@@ -3967,8 +3995,12 @@ TEST_F(ModuleIsaAllocationsInSystemMemoryTest, givenKernelIsaWhichCouldFitInPage
EXPECT_EQ(kernelImmDatas[1]->getIsaGraphicsAllocation()->getMemoryPool(), isaAllocationMemoryPool);
}
HWTEST_F(ModuleIsaAllocationsInSystemMemoryTest, givenMultipleKernelIsasAndDebuggerEnabledWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations) {
this->givenMultipleKernelIsasAndDebuggerEnabledWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations<FamilyType>();
HWTEST_F(ModuleIsaAllocationsInSystemMemoryTest, givenMultipleKernelIsasWhichFitInSinglePageAndDebuggerEnabledWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations) {
this->givenMultipleKernelIsasWhichFitInSinglePageAndDebuggerEnabledWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations<FamilyType>();
}
TEST_F(ModuleIsaAllocationsInSystemMemoryTest, givenMultipleKernelIsasWhichExceedSinglePageWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations) {
this->givenMultipleKernelIsasWhichExceedSinglePageWhenKernelImmutableDatasAreInitializedThenKernelIsasGetSeparateAllocations();
}
TEST_F(ModuleIsaAllocationsInSystemMemoryTest, givenMultipleKernelIsasWhenKernelInitializationFailsThenItIsProperlyCleanedAndPreviouslyInitializedKernelsLeftUntouched) {