Skip to content

Commit cb152ba

Browse files
fix: copy sip binary to allocation based on blitRequired query
- readOnly ISA allocations must be written through CPU pointer - command buffer allocation in singleAddressSpaceSbaTracking mode cannot be readonly - it is written by SBA tracking commands - this change is fixing ZET_ENABLE_PROGRAM_DEBUGGING mode 2 Related-To: GSD-10359 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
1 parent 25d0daf commit cb152ba

File tree

12 files changed

+96
-15
lines changed

12 files changed

+96
-15
lines changed

shared/source/built_ins/built_ins.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,13 @@ const SipKernel &BuiltIns::getSipKernel(Device &device, OsContext *context) {
114114
binary[bindlessSip.getPidOffset()] = static_cast<uint32_t>((context->getOfflineDumpContextId(deviceIndex) >> 32) & 0xFFFFFFFF);
115115
}
116116

117+
auto &rootDeviceEnvironment = device.getRootDeviceEnvironment();
118+
auto &productHelper = device.getProductHelper();
119+
117120
DeviceBitfield copyBitfield{};
118121
copyBitfield.set(deviceIndex);
119-
copySuccess = MemoryTransferHelper::transferMemoryToAllocationBanks(device, sipAllocation, 0, binary.get(), bindlessSip.getBinary().size(), copyBitfield);
122+
copySuccess = MemoryTransferHelper::transferMemoryToAllocationBanks(productHelper.isBlitCopyRequiredForLocalMemory(rootDeviceEnvironment, *sipAllocation),
123+
device, sipAllocation, 0, binary.get(), bindlessSip.getBinary().size(), copyBitfield);
120124
DEBUG_BREAK_IF(!copySuccess);
121125
}
122126
}

shared/source/command_stream/command_stream_receiver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ bool CommandStreamReceiver::createWorkPartitionAllocation(const Device &device)
868868
*copySrc = {logicalId++, deviceIndex};
869869
DeviceBitfield copyBitfield{};
870870
copyBitfield.set(deviceIndex);
871-
auto copySuccess = MemoryTransferHelper::transferMemoryToAllocationBanks(device, workPartitionAllocation, 0, copySrc.get(), 2 * sizeof(uint32_t), copyBitfield);
871+
auto copySuccess = MemoryTransferHelper::transferMemoryToAllocationBanks(true, device, workPartitionAllocation, 0, copySrc.get(), 2 * sizeof(uint32_t), copyBitfield);
872872

873873
if (!copySuccess) {
874874
return false;

shared/source/debugger/debugger.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Debugger {
3232
virtual ~Debugger() = default;
3333
virtual void captureStateBaseAddress(NEO::LinearStream &cmdStream, SbaAddresses sba, bool useFirstLevelBB) = 0;
3434
virtual size_t getSbaTrackingCommandsSize(size_t trackedAddressCount) = 0;
35+
virtual bool getSingleAddressSpaceSbaTracking() const = 0;
3536

3637
void *getDebugSurfaceReservedSurfaceState(IndirectHeap &ssh);
3738

shared/source/debugger/debugger_l0.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class DebuggerL0 : public NEO::Debugger, NEO::NonCopyableAndNonMovableClass {
111111
void setSingleAddressSpaceSbaTracking(bool value) {
112112
singleAddressSpaceSbaTracking = value;
113113
}
114-
bool getSingleAddressSpaceSbaTracking() { return singleAddressSpaceSbaTracking; }
114+
bool getSingleAddressSpaceSbaTracking() const override { return singleAddressSpaceSbaTracking; }
115115

116116
struct CommandQueueNotification {
117117
uint32_t subDeviceIndex = 0;

shared/source/memory_manager/allocation_properties.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ struct AllocationData {
111111
uint32_t use32BitFrontWindow : 1;
112112
uint32_t isUSMDeviceMemory : 1;
113113
uint32_t zeroMemory : 1;
114-
uint32_t reserved : 16;
114+
uint32_t cantBeReadOnly : 1;
115+
uint32_t reserved : 15;
115116
} flags;
116117
uint32_t allFlags = 0;
117118
};

shared/source/memory_manager/graphics_allocation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2024 Intel Corporation
2+
* Copyright (C) 2018-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -158,9 +158,9 @@ bool GraphicsAllocation::hasAllocationReadOnlyType() {
158158
return false;
159159
}
160160

161-
void GraphicsAllocation::checkAllocationTypeReadOnlyRestrictions(const AllocationProperties &properties) {
161+
void GraphicsAllocation::checkAllocationTypeReadOnlyRestrictions(const AllocationData &allocData) {
162162
if (getAllocationType() == AllocationType::commandBuffer &&
163-
(properties.flags.cantBeReadOnly | properties.flags.multiOsContextCapable)) {
163+
(allocData.flags.cantBeReadOnly | allocData.flags.multiOsContextCapable)) {
164164
setAsCantBeReadOnly(true);
165165
return;
166166
}

shared/source/memory_manager/graphics_allocation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class CommandStreamReceiver;
3939
class GraphicsAllocation;
4040
class ProductHelper;
4141

42+
struct AllocationData;
4243
struct AllocationProperties;
4344

4445
struct AubInfo {
@@ -338,7 +339,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation>, NEO::NonCopyableAn
338339
void setShareableHostMemory(bool shareableHostMemory) { this->shareableHostMemory = shareableHostMemory; }
339340
bool isShareableHostMemory() const { return shareableHostMemory; }
340341
MOCKABLE_VIRTUAL bool hasAllocationReadOnlyType();
341-
MOCKABLE_VIRTUAL void checkAllocationTypeReadOnlyRestrictions(const AllocationProperties &properties);
342+
MOCKABLE_VIRTUAL void checkAllocationTypeReadOnlyRestrictions(const AllocationData &allocData);
342343

343344
OsHandleStorage fragmentsStorage;
344345
StorageInfo storageInfo = {};

shared/source/memory_manager/memory_manager.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,13 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
654654
allocationData.flags.preferCompressed = properties.flags.preferCompressed;
655655
allocationData.flags.preferCompressed |= CompressionSelector::preferCompressedAllocation(properties);
656656
allocationData.flags.multiOsContextCapable = properties.flags.multiOsContextCapable;
657+
allocationData.flags.cantBeReadOnly = properties.flags.cantBeReadOnly;
657658
allocationData.usmInitialPlacement = properties.usmInitialPlacement;
658659

660+
if (properties.allocationType == AllocationType::commandBuffer && rootDeviceEnvironment.debugger.get() && rootDeviceEnvironment.debugger->getSingleAddressSpaceSbaTracking()) {
661+
allocationData.flags.cantBeReadOnly = true;
662+
}
663+
659664
if (GraphicsAllocation::isDebugSurfaceAllocationType(properties.allocationType) ||
660665
GraphicsAllocation::isConstantOrGlobalSurfaceAllocationType(properties.allocationType)) {
661666
allocationData.flags.zeroMemory = 1;
@@ -786,7 +791,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemoryInPreferredPool(const A
786791
if (!allocation) {
787792
return nullptr;
788793
}
789-
allocation->checkAllocationTypeReadOnlyRestrictions(properties);
794+
allocation->checkAllocationTypeReadOnlyRestrictions(allocationData);
790795

791796
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex];
792797
auto &productHelper = rootDeviceEnvironment.getProductHelper();
@@ -1271,10 +1276,13 @@ bool MemoryTransferHelper::transferMemoryToAllocation(bool useBlitter, const Dev
12711276
}
12721277
return device.getMemoryManager()->copyMemoryToAllocation(dstAllocation, dstOffset, srcMemory, srcSize);
12731278
}
1274-
bool MemoryTransferHelper::transferMemoryToAllocationBanks(const Device &device, GraphicsAllocation *dstAllocation, size_t dstOffset, const void *srcMemory,
1279+
bool MemoryTransferHelper::transferMemoryToAllocationBanks(bool useBlitter, const Device &device, GraphicsAllocation *dstAllocation, size_t dstOffset, const void *srcMemory,
12751280
size_t srcSize, DeviceBitfield dstMemoryBanks) {
1276-
auto blitSuccess = BlitHelper::blitMemoryToAllocationBanks(device, dstAllocation, dstOffset, srcMemory, {srcSize, 1, 1}, dstMemoryBanks) == BlitOperationResult::success;
1281+
auto blitSuccess = false;
12771282

1283+
if (useBlitter) {
1284+
blitSuccess = BlitHelper::blitMemoryToAllocationBanks(device, dstAllocation, dstOffset, srcMemory, {srcSize, 1, 1}, dstMemoryBanks) == BlitOperationResult::success;
1285+
}
12781286
if (!blitSuccess) {
12791287
return device.getMemoryManager()->copyMemoryToAllocationBanks(dstAllocation, dstOffset, srcMemory, srcSize, dstMemoryBanks);
12801288
}

shared/source/memory_manager/memory_manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ constexpr size_t paddingBufferSize = 2 * MemoryConstants::megaByte;
9595

9696
namespace MemoryTransferHelper {
9797
bool transferMemoryToAllocation(bool useBlitter, const Device &device, GraphicsAllocation *dstAllocation, size_t dstOffset, const void *srcMemory, size_t srcSize);
98-
bool transferMemoryToAllocationBanks(const Device &device, GraphicsAllocation *dstAllocation, size_t dstOffset, const void *srcMemory,
98+
bool transferMemoryToAllocationBanks(bool useBlitter, const Device &device, GraphicsAllocation *dstAllocation, size_t dstOffset, const void *srcMemory,
9999
size_t srcSize, DeviceBitfield dstMemoryBanks);
100100
} // namespace MemoryTransferHelper
101101

shared/test/common/mocks/mock_debugger.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2021-2022 Intel Corporation
2+
* Copyright (C) 2021-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -19,5 +19,9 @@ class MockDebugger : public Debugger {
1919
size_t getSbaTrackingCommandsSize(size_t trackedAddressCount) override {
2020
return 0;
2121
}
22+
bool getSingleAddressSpaceSbaTracking() const override {
23+
return singleAddressSpaceSbaTracking;
24+
}
25+
bool singleAddressSpaceSbaTracking = false;
2226
};
2327
} // namespace NEO

0 commit comments

Comments
 (0)