mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
test: add missing ult for checking patch address in heapless mode
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
1d456c8c53
commit
f16ce5dd47
@@ -1879,6 +1879,64 @@ TEST_F(ModuleDynamicLinkTests, givenModuleWithInternalRelocationAndUnresolvedExt
|
||||
EXPECT_EQ(externalSymbolAddress, *reinterpret_cast<uint64_t *>(ptrOffset(isaPtr, externalRelocationOffset)));
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY productFamily>
|
||||
class MockCompilerProductHelperHw : public CompilerProductHelperHw<productFamily> {
|
||||
public:
|
||||
bool isHeaplessModeEnabled() const override {
|
||||
return heaplessModeEnabled;
|
||||
}
|
||||
|
||||
MockCompilerProductHelperHw(bool heaplessModeEnabled) : CompilerProductHelperHw<productFamily>(), heaplessModeEnabled(heaplessModeEnabled) {}
|
||||
bool heaplessModeEnabled = false;
|
||||
};
|
||||
|
||||
HWTEST2_F(ModuleDynamicLinkTests, givenHeaplessAndModuleWithInternalRelocationAndUnresolvedExternalSymbolWhenLinkModuleThenPatchedAddressesAreCorrect, MatchAny) {
|
||||
|
||||
for (bool heaplessModeEnabled : {true, false}) {
|
||||
|
||||
auto backup = std::unique_ptr<CompilerProductHelper>(new MockCompilerProductHelperHw<productFamily>(heaplessModeEnabled));
|
||||
neoDevice->getRootDeviceEnvironmentRef().compilerProductHelper.swap(backup);
|
||||
|
||||
auto linkerInput = std::make_unique<::WhiteBox<NEO::LinkerInput>>();
|
||||
linkerInput->traits.requiresPatchingOfInstructionSegments = true;
|
||||
linkerInput->exportedFunctionsSegmentId = 0;
|
||||
uint32_t internalRelocationOffset = 0x10;
|
||||
linkerInput->textRelocations.push_back({{implicitArgsRelocationSymbolName, internalRelocationOffset, LinkerInput::RelocationInfo::Type::address, SegmentType::instructions}});
|
||||
uint32_t externalRelocationOffset = 0x20;
|
||||
constexpr auto externalSymbolName = "unresolved";
|
||||
linkerInput->textRelocations[0].push_back({externalSymbolName, externalRelocationOffset, LinkerInput::RelocationInfo::Type::address, SegmentType::instructions});
|
||||
|
||||
char kernelHeap[MemoryConstants::cacheLineSize] = {};
|
||||
auto kernelInfo = std::make_unique<NEO::KernelInfo>();
|
||||
kernelInfo->heapInfo.pKernelHeap = kernelHeap;
|
||||
kernelInfo->heapInfo.kernelHeapSize = MemoryConstants::cacheLineSize;
|
||||
kernelInfo->kernelDescriptor.kernelAttributes.flags.useStackCalls = true;
|
||||
auto module = std::make_unique<WhiteBox<::L0::Module>>(device, nullptr, ModuleType::user);
|
||||
module->getTranslationUnit()->programInfo.kernelInfos.push_back(kernelInfo.release());
|
||||
module->getTranslationUnit()->programInfo.linkerInput = std::move(linkerInput);
|
||||
auto kernelImmData = std::make_unique<WhiteBox<::L0::KernelImmutableData>>(device);
|
||||
kernelImmData->isaGraphicsAllocation.reset(neoDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(
|
||||
{device->getRootDeviceIndex(), MemoryConstants::cacheLineSize, NEO::AllocationType::kernelIsa, neoDevice->getDeviceBitfield()}));
|
||||
|
||||
auto isaAlloc = kernelImmData->getIsaGraphicsAllocation();
|
||||
auto offsetInParentAllocation = kernelImmData->getIsaOffsetInParentAllocation();
|
||||
auto expectedIsaAddressToPatch = offsetInParentAllocation;
|
||||
expectedIsaAddressToPatch += heaplessModeEnabled ? isaAlloc->getGpuAddress() : isaAlloc->getGpuAddressToPatch();
|
||||
|
||||
module->kernelImmDatas.push_back(std::move(kernelImmData));
|
||||
EXPECT_TRUE(module->linkBinary());
|
||||
|
||||
EXPECT_EQ(expectedIsaAddressToPatch, module->isaSegmentsForPatching[0].gpuAddress);
|
||||
if (heaplessModeEnabled) {
|
||||
EXPECT_EQ(expectedIsaAddressToPatch, module->exportedFunctionsSurface->getGpuAddress());
|
||||
} else {
|
||||
EXPECT_EQ(expectedIsaAddressToPatch, module->exportedFunctionsSurface->getGpuAddressToPatch());
|
||||
}
|
||||
|
||||
neoDevice->getRootDeviceEnvironmentRef().compilerProductHelper.swap(backup);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ModuleDynamicLinkTests, givenMultipleModulesWithUnresolvedSymbolWhenTheEachModuleDefinesTheSymbolThenTheExportedFunctionSurfaceInBothModulesIsAddedToTheImportedSymbolAllocations) {
|
||||
|
||||
uint64_t gpuAddress0 = 0x12345;
|
||||
|
||||
Reference in New Issue
Block a user