mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
feat(zebin): Add support for ELF section type SHT_NOBITS
This commit adds support for parsing SHT_NOBITS zebin's ELF sections (containing global/constant zero-initialized data). Related-To: NEO-7196 Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
31154dc20b
commit
fa03aa9a40
@@ -31,6 +31,7 @@ struct ProgramInfo {
|
||||
struct GlobalSurfaceInfo {
|
||||
const void *initData = nullptr;
|
||||
size_t size = 0U;
|
||||
size_t zeroInitSize = 0U;
|
||||
};
|
||||
|
||||
void prepareLinkerInputStorage();
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAllocManager, NEO::Device &device, size_t size, bool constant,
|
||||
GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAllocManager, NEO::Device &device, size_t totalSize, size_t zeroInitSize, bool constant,
|
||||
LinkerInput *const linkerInput, const void *initData) {
|
||||
bool globalsAreExported = false;
|
||||
GraphicsAllocation *gpuAllocation = nullptr;
|
||||
@@ -37,7 +37,7 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAlloc
|
||||
subDeviceBitfields.insert({rootDeviceIndex, deviceBitfield});
|
||||
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY, rootDeviceIndices, subDeviceBitfields);
|
||||
unifiedMemoryProperties.device = &device;
|
||||
auto ptr = svmAllocManager->createUnifiedMemoryAllocation(size, unifiedMemoryProperties);
|
||||
auto ptr = svmAllocManager->createUnifiedMemoryAllocation(totalSize, unifiedMemoryProperties);
|
||||
DEBUG_BREAK_IF(ptr == nullptr);
|
||||
if (ptr == nullptr) {
|
||||
return nullptr;
|
||||
@@ -49,7 +49,7 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAlloc
|
||||
auto allocationType = constant ? AllocationType::CONSTANT_SURFACE : AllocationType::GLOBAL_SURFACE;
|
||||
gpuAllocation = device.getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex,
|
||||
true, // allocateMemory
|
||||
size, allocationType,
|
||||
totalSize, allocationType,
|
||||
false, // isMultiStorageAllocation
|
||||
deviceBitfield});
|
||||
}
|
||||
@@ -61,11 +61,13 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAlloc
|
||||
auto &rootDeviceEnvironment = device.getRootDeviceEnvironment();
|
||||
auto &productHelper = device.getProductHelper();
|
||||
|
||||
auto success = MemoryTransferHelper::transferMemoryToAllocation(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, *gpuAllocation),
|
||||
device, gpuAllocation, 0, initData, size);
|
||||
|
||||
UNRECOVERABLE_IF(!success);
|
||||
|
||||
bool isOnlyBssData = (totalSize == zeroInitSize);
|
||||
if (false == isOnlyBssData) {
|
||||
auto initSize = totalSize - zeroInitSize;
|
||||
auto success = MemoryTransferHelper::transferMemoryToAllocation(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, *gpuAllocation),
|
||||
device, gpuAllocation, 0, initData, initSize);
|
||||
UNRECOVERABLE_IF(!success);
|
||||
}
|
||||
return gpuAllocation;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -17,7 +17,7 @@ class SVMAllocsManager;
|
||||
struct LinkerInput;
|
||||
|
||||
GraphicsAllocation *allocateGlobalsSurface(SVMAllocsManager *const svmAllocManager, Device &device,
|
||||
size_t size, bool constant,
|
||||
size_t totalSize, size_t zeroInitSize, bool constant,
|
||||
LinkerInput *const linkerInput, const void *initData);
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user