mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
Add implementation for reading logical subDevice from builtin
- add function for resolving builtins using relocations - add relocation for __SubDeviceID symbol Related-To: NEO-6258 Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
d07c76c237
commit
24c19509b3
@@ -592,15 +592,16 @@ bool CommandStreamReceiver::createWorkPartitionAllocation(const Device &device)
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t logicalId = 0;
|
||||
for (uint32_t deviceIndex = 0; deviceIndex < deviceBitfield.size(); deviceIndex++) {
|
||||
if (!deviceBitfield.test(deviceIndex)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const uint32_t copySrc = deviceIndex;
|
||||
const uint32_t copySrc[2] = {logicalId++, deviceIndex};
|
||||
DeviceBitfield copyBitfield{};
|
||||
copyBitfield.set(deviceIndex);
|
||||
auto copySuccess = MemoryTransferHelper::transferMemoryToAllocationBanks(device, workPartitionAllocation, 0, ©Src, sizeof(copySrc), copyBitfield);
|
||||
auto copySuccess = MemoryTransferHelper::transferMemoryToAllocationBanks(device, workPartitionAllocation, 0, copySrc, sizeof(copySrc), copyBitfield);
|
||||
|
||||
if (!copySuccess) {
|
||||
return false;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "shared/source/compiler_interface/linker.h"
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/compiler_interface/linker.inl"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/device_binary_format/elf/zebin_elf.h"
|
||||
@@ -481,4 +482,21 @@ void Linker::resolveImplicitArgs(const KernelDescriptorsT &kernelDescriptors, De
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Linker::resolveBuiltins(Device *pDevice, UnresolvedExternals &outUnresolvedExternals, const std::vector<PatchableSegment> &instructionsSegments) {
|
||||
int vecIndex = static_cast<int>(outUnresolvedExternals.size() - 1u);
|
||||
for (; vecIndex >= 0; --vecIndex) {
|
||||
if (outUnresolvedExternals[vecIndex].unresolvedRelocation.symbolName == subDeviceID) {
|
||||
RelocatedSymbol symbol;
|
||||
symbol.gpuAddress = static_cast<uintptr_t>(pDevice->getDefaultEngine().commandStreamReceiver->getWorkPartitionAllocationGpuAddress());
|
||||
auto relocAddress = ptrOffset(instructionsSegments[outUnresolvedExternals[vecIndex].instructionsSegmentId].hostPointer,
|
||||
static_cast<uintptr_t>(outUnresolvedExternals[vecIndex].unresolvedRelocation.offset));
|
||||
|
||||
NEO::Linker::patchAddress(relocAddress, symbol, outUnresolvedExternals[vecIndex].unresolvedRelocation);
|
||||
|
||||
outUnresolvedExternals[vecIndex] = outUnresolvedExternals[outUnresolvedExternals.size() - 1u];
|
||||
outUnresolvedExternals.resize(outUnresolvedExternals.size() - 1u);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -152,6 +152,8 @@ struct LinkerInput {
|
||||
};
|
||||
|
||||
struct Linker {
|
||||
static constexpr std::string_view subDeviceID{"__SubDeviceID"};
|
||||
|
||||
using RelocationInfo = LinkerInput::RelocationInfo;
|
||||
|
||||
struct SegmentInfo {
|
||||
@@ -197,7 +199,7 @@ struct Linker {
|
||||
patchDataSegments(globalVariablesSegInfo, globalConstantsSegInfo, globalVariablesSeg, globalConstantsSeg,
|
||||
outUnresolvedExternals, pDevice, constantsInitData, variablesInitData);
|
||||
resolveImplicitArgs(kernelDescriptors, pDevice);
|
||||
|
||||
resolveBuiltins(pDevice, outUnresolvedExternals, instructionsSegments);
|
||||
if (initialUnresolvedExternalsCount < outUnresolvedExternals.size()) {
|
||||
return LinkingStatus::LinkedPartially;
|
||||
}
|
||||
@@ -227,6 +229,7 @@ struct Linker {
|
||||
const void *constantsInitData, const void *variablesInitData);
|
||||
|
||||
void resolveImplicitArgs(const KernelDescriptorsT &kernelDescriptors, Device *pDevice);
|
||||
void resolveBuiltins(Device *pDevice, UnresolvedExternals &outUnresolvedExternals, const std::vector<PatchableSegment> &instructionsSegments);
|
||||
|
||||
template <typename PatchSizeT>
|
||||
void patchIncrement(Device *pDevice, GraphicsAllocation *dstAllocation, size_t relocationOffset, const void *initData, uint64_t incrementValue);
|
||||
|
||||
Reference in New Issue
Block a user