mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
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>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
25d0daf754
commit
cb152ba821
@@ -639,8 +639,6 @@ TEST(DebugBindlessSip, givenOfflineDebuggingModeWhenGettingSipForContextThenCorr
|
||||
auto csr = mockDevice->createCommandStreamReceiver();
|
||||
csr->setupContext(*osContext);
|
||||
|
||||
EXPECT_NE(nullptr, mockDevice);
|
||||
|
||||
auto &sipKernel = NEO::SipKernel::getSipKernel(*mockDevice, &csr->getOsContext());
|
||||
EXPECT_NE(nullptr, &sipKernel);
|
||||
|
||||
@@ -652,6 +650,38 @@ TEST(DebugBindlessSip, givenOfflineDebuggingModeWhenGettingSipForContextThenCorr
|
||||
EXPECT_FALSE(contextSip->getStateSaveAreaHeader().empty());
|
||||
}
|
||||
|
||||
TEST(DebugSip, givenOfflineDebuggingModeWhenGettingSipForContextThenMemoryTransferGoesThroughCpuPointer) {
|
||||
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u);
|
||||
executionEnvironment->setDebuggingMode(DebuggingMode::offline);
|
||||
VariableBackup<bool> mockSipBackup(&MockSipData::useMockSip, false);
|
||||
auto builtIns = new NEO::MockBuiltins();
|
||||
builtIns->callBaseGetSipKernel = true;
|
||||
MockRootDeviceEnvironment::resetBuiltins(executionEnvironment->rootDeviceEnvironments[0].get(), builtIns);
|
||||
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithExecutionEnvironment<MockDevice>(defaultHwInfo.get(), executionEnvironment, 0u));
|
||||
|
||||
auto memoryManager = static_cast<MockMemoryManager *>(mockDevice->getMemoryManager());
|
||||
|
||||
const uint32_t contextId = 2u;
|
||||
std::unique_ptr<OsContext> osContext(OsContext::create(executionEnvironment->rootDeviceEnvironments[0]->osInterface.get(),
|
||||
mockDevice->getRootDeviceIndex(), contextId,
|
||||
EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_BCS, EngineUsage::regular}, PreemptionMode::ThreadGroup, mockDevice->getDeviceBitfield())));
|
||||
osContext->setDefaultContext(true);
|
||||
|
||||
auto csr = mockDevice->createCommandStreamReceiver();
|
||||
csr->setupContext(*osContext);
|
||||
|
||||
std::vector<char> sipBinary;
|
||||
std::vector<char> stateSaveAreaHeader;
|
||||
mockDevice->getCompilerInterface()->getSipKernelBinary(*mockDevice, SipKernelType::dbgBindless, sipBinary, stateSaveAreaHeader);
|
||||
|
||||
memoryManager->copyMemoryToAllocationBanksCalled = 0;
|
||||
auto &sipKernel = NEO::SipKernel::getSipKernel(*mockDevice, &csr->getOsContext());
|
||||
ASSERT_NE(nullptr, &sipKernel);
|
||||
EXPECT_EQ(1u, memoryManager->copyMemoryToAllocationBanksCalled);
|
||||
|
||||
EXPECT_EQ(0, memcmp(sipBinary.data(), sipKernel.getSipAllocation()->getUnderlyingBuffer(), sipBinary.size()));
|
||||
}
|
||||
|
||||
TEST(DebugBindlessSip, givenTwoContextsWhenBindlessDebugSipIsRequestedThenEachSipKernelIsAssignedToADifferentContextId) {
|
||||
auto executionEnvironment = MockDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u);
|
||||
auto builtIns = new NEO::MockBuiltins();
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/helpers/unit_test_helper.h"
|
||||
#include "shared/test/common/mocks/mock_allocation_properties.h"
|
||||
#include "shared/test/common/mocks/mock_debugger.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/mocks/mock_gmm.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
@@ -1149,6 +1150,37 @@ TEST(MemoryManagerTest, givenMemoryManagerWhenAllocationIsCommandBufferAndMultiC
|
||||
EXPECT_EQ(mockGa.setAsReadOnlyCalled, 0u);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenSingleAddressSpaceSbaTrackingWhenAllocationIsCommandBufferAndMultiContextCapableIsFalseThenAllocationIsNotSetAsReadOnly) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
executionEnvironment.setDebuggingMode(NEO::DebuggingMode::offline);
|
||||
auto debugger = new MockDebugger;
|
||||
debugger->singleAddressSpaceSbaTracking = true;
|
||||
executionEnvironment.rootDeviceEnvironments[0]->debugger.reset(debugger);
|
||||
|
||||
auto mockProductHelper = std::make_unique<MockProductHelper>();
|
||||
mockProductHelper->isBlitCopyRequiredForLocalMemoryResult = false;
|
||||
mockProductHelper->supportReadOnlyAllocationsResult = true;
|
||||
std::unique_ptr<ProductHelper> productHelper = std::move(mockProductHelper);
|
||||
std::swap(executionEnvironment.rootDeviceEnvironments[0]->productHelper, productHelper);
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
MockGraphicsAllocation mockGa;
|
||||
mockGa.setAllocationType(AllocationType::commandBuffer);
|
||||
|
||||
mockGa.hasAllocationReadOnlyTypeResult = true;
|
||||
|
||||
memoryManager.mockGa = &mockGa;
|
||||
memoryManager.returnMockGAFromDevicePool = true;
|
||||
|
||||
AllocationProperties properties(mockRootDeviceIndex, MemoryConstants::pageSize, AllocationType::commandBuffer, mockDeviceBitfield);
|
||||
properties.flags.cantBeReadOnly = false;
|
||||
properties.flags.multiOsContextCapable = false;
|
||||
|
||||
auto allocation = memoryManager.allocateGraphicsMemoryInPreferredPool(properties,
|
||||
nullptr);
|
||||
EXPECT_EQ(allocation, &mockGa);
|
||||
EXPECT_EQ(mockGa.setAsReadOnlyCalled, 0u);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenMemoryManagerWhenAllocationTypeAndPlatrormSupportReadOnlyAllocationBliterAndAllocationTypeOtherThanCmdBufferTransferNotRequiredThenAllocationIsSetAsReadOnly) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
auto mockProductHelper = std::make_unique<MockProductHelper>();
|
||||
|
||||
Reference in New Issue
Block a user