mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 08:53:55 +08:00
Add implementation for reading logical subDevice from builtin
Related-To: NEO-6258 Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
aa6e3bbef5
commit
34856747b4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -1003,6 +1003,90 @@ TEST(LinkerTests, givenInvalidLinkerInputThenLinkerFails) {
|
||||
EXPECT_EQ(NEO::LinkingStatus::Error, linkResult);
|
||||
}
|
||||
|
||||
TEST(LinkerTests, givenUnresolvedExternalSymbolsWhenResolveBuiltinsIsCalledThenSubDeviceIDSymbolsAreRmoved) {
|
||||
struct LinkerMock : public NEO::Linker {
|
||||
public:
|
||||
using NEO::Linker::resolveBuiltins;
|
||||
|
||||
LinkerMock(const LinkerInput &data) : NEO::Linker(data) {
|
||||
}
|
||||
};
|
||||
|
||||
NEO::LinkerInput linkerInput;
|
||||
LinkerMock linker(linkerInput);
|
||||
NEO::Linker::UnresolvedExternals unresolvedExternals;
|
||||
unresolvedExternals.push_back({{"__SubDeviceID", 0, NEO::Linker::RelocationInfo::Type::AddressLow, NEO::SegmentType::Instructions}, 0u, false});
|
||||
unresolvedExternals.push_back({{"__MaxHWThreadIDPerSubDevice", 156, NEO::Linker::RelocationInfo::Type::AddressLow, NEO::SegmentType::Instructions}, 0u, false});
|
||||
unresolvedExternals.push_back({{"__MaxHWThreadIDPerSubDevice", 140, NEO::Linker::RelocationInfo::Type::AddressHigh, NEO::SegmentType::Instructions}, 0u, false});
|
||||
unresolvedExternals.push_back({{"__SubDeviceID", 64, NEO::Linker::RelocationInfo::Type::AddressHigh, NEO::SegmentType::Instructions}, 0u, false});
|
||||
|
||||
std::vector<char> instructionSegment;
|
||||
instructionSegment.resize(128u);
|
||||
NEO::Linker::PatchableSegments instructionsSegments;
|
||||
instructionsSegments.push_back({instructionSegment.data(), 64u});
|
||||
instructionsSegments.push_back({&instructionSegment[64], 64u});
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.CreateMultipleSubDevices.set(2);
|
||||
DebugManager.flags.EnableImplicitScaling.set(1);
|
||||
|
||||
auto device = std::unique_ptr<NEO::MockDevice>(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get()));
|
||||
linker.resolveBuiltins(device.get(), unresolvedExternals, instructionsSegments);
|
||||
|
||||
EXPECT_EQ(2U, unresolvedExternals.size());
|
||||
for (auto &symbol : unresolvedExternals) {
|
||||
EXPECT_NE(NEO::Linker::subDeviceID, symbol.unresolvedRelocation.symbolName);
|
||||
}
|
||||
|
||||
auto gpuAddressAs64bit = device->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocationGpuAddress();
|
||||
EXPECT_EQ(*reinterpret_cast<uint32_t *>(&instructionSegment[64]), static_cast<uint32_t>((gpuAddressAs64bit >> 32) & 0xffffffff));
|
||||
EXPECT_EQ(*reinterpret_cast<uint32_t *>(instructionSegment.data()), static_cast<uint32_t>(gpuAddressAs64bit & 0xffffffff));
|
||||
}
|
||||
|
||||
TEST(LinkerTests, givenUnresolvedExternalsWhenLinkThenSubDeviceIDSymbolsAreRemoved) {
|
||||
NEO::LinkerInput linkerInput;
|
||||
|
||||
NEO::Linker linker(linkerInput);
|
||||
NEO::Linker::SegmentInfo globalVar, globalConst, exportedFunc;
|
||||
NEO::Linker::UnresolvedExternals unresolvedExternals;
|
||||
unresolvedExternals.push_back({{"__SubDeviceID", 0, NEO::Linker::RelocationInfo::Type::AddressLow, NEO::SegmentType::Instructions}, 0u, false});
|
||||
unresolvedExternals.push_back({{"__MaxHWThreadIDPerSubDevice", 156, NEO::Linker::RelocationInfo::Type::AddressLow, NEO::SegmentType::Instructions}, 0u, false});
|
||||
unresolvedExternals.push_back({{"__MaxHWThreadIDPerSubDevice", 140, NEO::Linker::RelocationInfo::Type::AddressHigh, NEO::SegmentType::Instructions}, 0u, false});
|
||||
unresolvedExternals.push_back({{"__SubDeviceID", 64, NEO::Linker::RelocationInfo::Type::AddressHigh, NEO::SegmentType::Instructions}, 0u, false});
|
||||
|
||||
NEO::Linker::KernelDescriptorsT kernelDescriptors;
|
||||
|
||||
NEO::GraphicsAllocation *patchableGlobalVarSeg = nullptr;
|
||||
NEO::GraphicsAllocation *patchableConstVarSeg = nullptr;
|
||||
std::vector<char> instructionSegment;
|
||||
instructionSegment.resize(128u);
|
||||
NEO::Linker::PatchableSegments instructionsSegments;
|
||||
instructionsSegments.push_back({instructionSegment.data(), 0});
|
||||
instructionsSegments.push_back({&instructionSegment[64], 64u});
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.CreateMultipleSubDevices.set(2);
|
||||
DebugManager.flags.EnableImplicitScaling.set(1);
|
||||
|
||||
auto device = std::unique_ptr<NEO::MockDevice>(NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(NEO::defaultHwInfo.get()));
|
||||
|
||||
linker.link(
|
||||
globalVar, globalConst, exportedFunc, {},
|
||||
patchableGlobalVarSeg, patchableConstVarSeg, instructionsSegments,
|
||||
unresolvedExternals, device.get(), nullptr, nullptr, kernelDescriptors);
|
||||
|
||||
auto relocatedSymbols = linker.extractRelocatedSymbols();
|
||||
EXPECT_EQ(0U, relocatedSymbols.size());
|
||||
EXPECT_EQ(2U, unresolvedExternals.size());
|
||||
for (auto &symbol : unresolvedExternals) {
|
||||
EXPECT_NE(NEO::Linker::subDeviceID, symbol.unresolvedRelocation.symbolName);
|
||||
}
|
||||
|
||||
auto gpuAddressAs64bit = device->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocationGpuAddress();
|
||||
EXPECT_EQ(*reinterpret_cast<uint32_t *>(&instructionSegment[64]), static_cast<uint32_t>((gpuAddressAs64bit >> 32) & 0xffffffff));
|
||||
EXPECT_EQ(*reinterpret_cast<uint32_t *>(instructionSegment.data()), static_cast<uint32_t>(gpuAddressAs64bit & 0xffffffff));
|
||||
}
|
||||
|
||||
TEST(LinkerTests, givenUnresolvedExternalWhenPatchingInstructionsThenLinkPartially) {
|
||||
NEO::LinkerInput linkerInput;
|
||||
vISA::GenRelocEntry entry = {};
|
||||
|
||||
Reference in New Issue
Block a user