mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 22:43:00 +08:00
Always specify rootDeviceIndex for graphics memory allocations
Related-To: NEO-2941 Change-Id: Ia2362fd6b4e72ede02919152475f40b3edbc3658 Signed-off-by: Igor Venevtsev <igor.venevtsev@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
5f021afd6d
commit
63fd26f6d6
@@ -54,7 +54,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
|
||||
size_t sizeBatchBuffer = 0xffffu;
|
||||
|
||||
std::unique_ptr<GraphicsAllocation, std::function<void(GraphicsAllocation *)>> flatBatchBuffer(
|
||||
aubCsr->getFlatBatchBufferHelper().flattenBatchBuffer(batchBuffer, sizeBatchBuffer, DispatchMode::ImmediateDispatch),
|
||||
aubCsr->getFlatBatchBufferHelper().flattenBatchBuffer(aubCsr->getRootDeviceIndex(), batchBuffer, sizeBatchBuffer, DispatchMode::ImmediateDispatch),
|
||||
[&](GraphicsAllocation *ptr) { memoryManager->freeGraphicsMemory(ptr); });
|
||||
EXPECT_NE(nullptr, flatBatchBuffer->getUnderlyingBuffer());
|
||||
EXPECT_EQ(alignUp(128u + 128u, MemoryConstants::pageSize), sizeBatchBuffer);
|
||||
@@ -79,7 +79,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
|
||||
size_t sizeBatchBuffer = 0xffffu;
|
||||
|
||||
std::unique_ptr<GraphicsAllocation, std::function<void(GraphicsAllocation *)>> flatBatchBuffer(
|
||||
aubCsr->getFlatBatchBufferHelper().flattenBatchBuffer(batchBuffer, sizeBatchBuffer, DispatchMode::ImmediateDispatch),
|
||||
aubCsr->getFlatBatchBufferHelper().flattenBatchBuffer(aubCsr->getRootDeviceIndex(), batchBuffer, sizeBatchBuffer, DispatchMode::ImmediateDispatch),
|
||||
[&](GraphicsAllocation *ptr) { memoryManager->freeGraphicsMemory(ptr); });
|
||||
EXPECT_EQ(nullptr, flatBatchBuffer.get());
|
||||
EXPECT_EQ(0xffffu, sizeBatchBuffer);
|
||||
@@ -106,7 +106,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
|
||||
size_t sizeBatchBuffer = 0xffffu;
|
||||
|
||||
std::unique_ptr<GraphicsAllocation, std::function<void(GraphicsAllocation *)>> flatBatchBuffer(
|
||||
aubCsr->getFlatBatchBufferHelper().flattenBatchBuffer(batchBuffer, sizeBatchBuffer, DispatchMode::AdaptiveDispatch),
|
||||
aubCsr->getFlatBatchBufferHelper().flattenBatchBuffer(aubCsr->getRootDeviceIndex(), batchBuffer, sizeBatchBuffer, DispatchMode::AdaptiveDispatch),
|
||||
[&](GraphicsAllocation *ptr) { memoryManager->freeGraphicsMemory(ptr); });
|
||||
EXPECT_EQ(nullptr, flatBatchBuffer.get());
|
||||
EXPECT_EQ(0xffffu, sizeBatchBuffer);
|
||||
@@ -225,7 +225,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedB
|
||||
size_t sizeBatchBuffer = 0u;
|
||||
|
||||
std::unique_ptr<GraphicsAllocation, std::function<void(GraphicsAllocation *)>> flatBatchBuffer(
|
||||
aubCsr->getFlatBatchBufferHelper().flattenBatchBuffer(batchBuffer, sizeBatchBuffer, DispatchMode::BatchedDispatch),
|
||||
aubCsr->getFlatBatchBufferHelper().flattenBatchBuffer(aubCsr->getRootDeviceIndex(), batchBuffer, sizeBatchBuffer, DispatchMode::BatchedDispatch),
|
||||
[&](GraphicsAllocation *ptr) { memoryManager->freeGraphicsMemory(ptr); });
|
||||
|
||||
EXPECT_NE(nullptr, flatBatchBuffer.get());
|
||||
@@ -252,7 +252,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenDefault
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs};
|
||||
ResidencyContainer allocationsForResidency = {};
|
||||
|
||||
EXPECT_CALL(*mockHelper, flattenBatchBuffer(::testing::_, ::testing::_, ::testing::_)).Times(0);
|
||||
EXPECT_CALL(*mockHelper, flattenBatchBuffer(aubCsr->getRootDeviceIndex(), ::testing::_, ::testing::_, ::testing::_)).Times(0);
|
||||
aubCsr->flush(batchBuffer, allocationsForResidency);
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
|
||||
[&](GraphicsAllocation *ptr) { aubExecutionEnvironment->executionEnvironment->memoryManager->freeGraphicsMemory(ptr); });
|
||||
|
||||
auto expectedAllocation = ptr.get();
|
||||
EXPECT_CALL(*mockHelper, flattenBatchBuffer(::testing::_, ::testing::_, ::testing::_)).WillOnce(::testing::Return(ptr.release()));
|
||||
EXPECT_CALL(*mockHelper, flattenBatchBuffer(aubCsr->getRootDeviceIndex(), ::testing::_, ::testing::_, ::testing::_)).WillOnce(::testing::Return(ptr.release()));
|
||||
aubCsr->flush(batchBuffer, allocationsForResidency);
|
||||
|
||||
EXPECT_EQ(batchBuffer.commandBufferAllocation, expectedAllocation);
|
||||
@@ -304,7 +304,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
|
||||
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs};
|
||||
|
||||
EXPECT_CALL(*mockHelper, flattenBatchBuffer(::testing::_, ::testing::_, ::testing::_)).Times(1);
|
||||
EXPECT_CALL(*mockHelper, flattenBatchBuffer(aubCsr->getRootDeviceIndex(), ::testing::_, ::testing::_, ::testing::_)).Times(1);
|
||||
aubCsr->flush(batchBuffer, allocationsForResidency);
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenForcedF
|
||||
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount, cs.getUsed(), &cs};
|
||||
|
||||
EXPECT_CALL(*mockHelper, flattenBatchBuffer(::testing::_, ::testing::_, ::testing::_)).Times(1);
|
||||
EXPECT_CALL(*mockHelper, flattenBatchBuffer(aubCsr->getRootDeviceIndex(), ::testing::_, ::testing::_, ::testing::_)).Times(1);
|
||||
aubCsr->flush(batchBuffer, allocationsForResidency);
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ HWTEST_F(AubCommandStreamReceiverNoHostPtrTests, givenAubCommandStreamReceiverWh
|
||||
|
||||
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
||||
|
||||
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(imgInfo, true, {});
|
||||
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(aubCsr->getRootDeviceIndex(), imgInfo, true, {});
|
||||
|
||||
auto imageAllocation = memoryManager->allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr);
|
||||
ASSERT_NE(nullptr, imageAllocation);
|
||||
|
||||
@@ -475,7 +475,7 @@ struct MockScratchController : public ScratchSpaceController {
|
||||
|
||||
HWTEST_F(CommandStreamReceiverFlushTaskTests, whenScratchIsRequiredForFirstFlushAndPrivateScratchForSecondFlushThenHandleResidencyProperly) {
|
||||
auto commandStreamReceiver = new MockCsrHw<FamilyType>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
|
||||
auto scratchController = new MockScratchController(*pDevice->executionEnvironment, *commandStreamReceiver->getInternalAllocationStorage());
|
||||
auto scratchController = new MockScratchController(pDevice->getRootDeviceIndex(), *pDevice->executionEnvironment, *commandStreamReceiver->getInternalAllocationStorage());
|
||||
commandStreamReceiver->scratchSpaceController.reset(scratchController);
|
||||
pDevice->resetCommandStreamReceiver(commandStreamReceiver);
|
||||
|
||||
@@ -510,7 +510,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, whenScratchIsRequiredForFirstFlush
|
||||
|
||||
HWTEST_F(CommandStreamReceiverFlushTaskTests, whenPrivateScratchIsRequiredForFirstFlushAndCommonScratchForSecondFlushThenHandleResidencyProperly) {
|
||||
auto commandStreamReceiver = new MockCsrHw<FamilyType>(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex());
|
||||
auto scratchController = new MockScratchController(*pDevice->executionEnvironment, *commandStreamReceiver->getInternalAllocationStorage());
|
||||
auto scratchController = new MockScratchController(pDevice->getRootDeviceIndex(), *pDevice->executionEnvironment, *commandStreamReceiver->getInternalAllocationStorage());
|
||||
commandStreamReceiver->scratchSpaceController.reset(scratchController);
|
||||
pDevice->resetCommandStreamReceiver(commandStreamReceiver);
|
||||
|
||||
|
||||
@@ -1526,7 +1526,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenBlockedKernelWhenItIsUnblocke
|
||||
|
||||
std::unique_ptr<MockKernel> pKernel(MockKernel::create(*pDevice, mockProgram.get(), numGrfRequired));
|
||||
auto event = std::make_unique<MockEvent<Event>>(pCmdQ.get(), CL_COMMAND_MARKER, 0, 0);
|
||||
auto cmdStream = new LinearStream(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties({4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER}));
|
||||
auto cmdStream = new LinearStream(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties({pDevice->getRootDeviceIndex(), 4096, GraphicsAllocation::AllocationType::COMMAND_BUFFER}));
|
||||
|
||||
IndirectHeap *dsh = nullptr, *ioh = nullptr, *ssh = nullptr;
|
||||
pCmdQ->allocateHeapMemory(IndirectHeap::DYNAMIC_STATE, 4096u, dsh);
|
||||
|
||||
@@ -781,7 +781,7 @@ HWTEST_F(BcsTests, givenMapAllocationWhenDispatchReadWriteOperationThenSetValidG
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
auto memoryManager = csr.getMemoryManager();
|
||||
|
||||
AllocationProperties properties{false, 1234, GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, false};
|
||||
AllocationProperties properties{csr.getRootDeviceIndex(), false, 1234, GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, false};
|
||||
GraphicsAllocation *mapAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, reinterpret_cast<void *>(0x12340000));
|
||||
|
||||
auto mapAllocationOffset = 0x1234;
|
||||
@@ -838,7 +838,7 @@ HWTEST_F(BcsTests, givenMapAllocationInBuiltinOpParamsWhenConstructingThenUseItA
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
auto memoryManager = csr.getMemoryManager();
|
||||
|
||||
AllocationProperties properties{false, 1234, GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, false};
|
||||
AllocationProperties properties{csr.getRootDeviceIndex(), false, 1234, GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, false};
|
||||
GraphicsAllocation *mapAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, reinterpret_cast<void *>(0x12340000));
|
||||
|
||||
auto mapAllocationOffset = 0x1234;
|
||||
@@ -881,7 +881,7 @@ HWTEST_F(BcsTests, givenNonZeroCopySvmAllocationWhenConstructingBlitPropertiesFo
|
||||
SVMAllocsManager svmAllocsManager(&mockMemoryManager);
|
||||
|
||||
auto svmAllocationProperties = MemObjHelper::getSvmAllocationProperties(CL_MEM_READ_WRITE);
|
||||
auto svmAlloc = svmAllocsManager.createSVMAlloc(1, svmAllocationProperties);
|
||||
auto svmAlloc = svmAllocsManager.createSVMAlloc(csr.getRootDeviceIndex(), 1, svmAllocationProperties);
|
||||
auto svmData = svmAllocsManager.getSVMAlloc(svmAlloc);
|
||||
|
||||
EXPECT_NE(nullptr, svmData->gpuAllocation);
|
||||
@@ -1031,7 +1031,7 @@ struct MockScratchSpaceController : ScratchSpaceControllerBase {
|
||||
using ScratchSpaceControllerTest = Test<DeviceFixture>;
|
||||
|
||||
TEST_F(ScratchSpaceControllerTest, whenScratchSpaceControllerIsDestroyedThenItReleasePrivateScratchSpaceAllocation) {
|
||||
MockScratchSpaceController scratchSpaceController(*pDevice->getExecutionEnvironment(), *pDevice->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
|
||||
MockScratchSpaceController scratchSpaceController(pDevice->getRootDeviceIndex(), *pDevice->getExecutionEnvironment(), *pDevice->getGpgpuCommandStreamReceiver().getInternalAllocationStorage());
|
||||
scratchSpaceController.privateScratchAllocation = pDevice->getExecutionEnvironment()->memoryManager->allocateGraphicsMemoryInPreferredPool(MockAllocationProperties{MemoryConstants::pageSize}, nullptr);
|
||||
EXPECT_NE(nullptr, scratchSpaceController.privateScratchAllocation);
|
||||
//no memory leak is expected
|
||||
|
||||
@@ -483,7 +483,7 @@ TEST_F(ReducedAddrSpaceCommandStreamReceiverTest,
|
||||
}
|
||||
|
||||
TEST_F(CommandStreamReceiverTest, givenMinimumSizeDoesNotExceedCurrentWhenCallingEnsureCommandBufferAllocationThenDoNotReallocate) {
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({128u, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({commandStreamReceiver->getRootDeviceIndex(), 128u, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
LinearStream commandStream{allocation};
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 100u, 0u);
|
||||
@@ -498,7 +498,7 @@ TEST_F(CommandStreamReceiverTest, givenMinimumSizeDoesNotExceedCurrentWhenCallin
|
||||
}
|
||||
|
||||
TEST_F(CommandStreamReceiverTest, givenMinimumSizeExceedsCurrentWhenCallingEnsureCommandBufferAllocationThenReallocate) {
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({128u, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({commandStreamReceiver->getRootDeviceIndex(), 128u, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
LinearStream commandStream{allocation};
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 129u, 0u);
|
||||
@@ -507,7 +507,7 @@ TEST_F(CommandStreamReceiverTest, givenMinimumSizeExceedsCurrentWhenCallingEnsur
|
||||
}
|
||||
|
||||
TEST_F(CommandStreamReceiverTest, givenMinimumSizeExceedsCurrentWhenCallingEnsureCommandBufferAllocationThenReallocateAndAlignSizeTo64kb) {
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({128u, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({commandStreamReceiver->getRootDeviceIndex(), 128u, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
LinearStream commandStream{allocation};
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 129u, 0u);
|
||||
@@ -522,7 +522,7 @@ TEST_F(CommandStreamReceiverTest, givenMinimumSizeExceedsCurrentWhenCallingEnsur
|
||||
}
|
||||
|
||||
TEST_F(CommandStreamReceiverTest, givenAdditionalAllocationSizeWhenCallingEnsureCommandBufferAllocationThenSizesOfAllocationAndCommandBufferAreCorrect) {
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({128u, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({commandStreamReceiver->getRootDeviceIndex(), 128u, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
LinearStream commandStream{allocation};
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 129u, 350u);
|
||||
@@ -544,7 +544,7 @@ TEST_F(CommandStreamReceiverTest, givenMinimumSizeExceedsCurrentAndNoAllocations
|
||||
}
|
||||
|
||||
TEST_F(CommandStreamReceiverTest, givenMinimumSizeExceedsCurrentAndAllocationsForReuseWhenCallingEnsureCommandBufferAllocationThenObtainAllocationFromInternalAllocationStorage) {
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({commandStreamReceiver->getRootDeviceIndex(), MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
internalAllocationStorage->storeAllocation(std::unique_ptr<GraphicsAllocation>{allocation}, REUSABLE_ALLOCATION);
|
||||
LinearStream commandStream;
|
||||
|
||||
@@ -557,7 +557,7 @@ TEST_F(CommandStreamReceiverTest, givenMinimumSizeExceedsCurrentAndAllocationsFo
|
||||
}
|
||||
|
||||
TEST_F(CommandStreamReceiverTest, givenMinimumSizeExceedsCurrentAndNoSuitableReusableAllocationWhenCallingEnsureCommandBufferAllocationThenObtainAllocationMemoryManager) {
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({commandStreamReceiver->getRootDeviceIndex(), MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
internalAllocationStorage->storeAllocation(std::unique_ptr<GraphicsAllocation>{allocation}, REUSABLE_ALLOCATION);
|
||||
LinearStream commandStream;
|
||||
|
||||
@@ -633,3 +633,67 @@ TEST(CommandStreamReceiverDeviceIndexTest, givenOsContextWithNoDeviceBitfieldWhe
|
||||
csr.setupContext(*osContext);
|
||||
EXPECT_EQ(0u, csr.getDeviceIndex());
|
||||
}
|
||||
|
||||
TEST(CommandStreamReceiverRootDeviceIndexTest, commandStreamGraphicsAllocationsHaveCorrectRootDeviceIndex) {
|
||||
const uint32_t expectedRootDeviceIndex = 101;
|
||||
|
||||
// Setup
|
||||
auto executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
executionEnvironment->rootDeviceEnvironments.resize(2 * expectedRootDeviceIndex);
|
||||
auto memoryManager = new MockMemoryManager(false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(executionEnvironment, expectedRootDeviceIndex));
|
||||
auto commandStreamReceiver = &device->getGpgpuCommandStreamReceiver();
|
||||
|
||||
ASSERT_NE(nullptr, commandStreamReceiver);
|
||||
EXPECT_EQ(expectedRootDeviceIndex, commandStreamReceiver->getRootDeviceIndex());
|
||||
|
||||
// Linear stream / Command buffer
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties({expectedRootDeviceIndex, 128u, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
LinearStream commandStream{allocation};
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 100u, 0u);
|
||||
EXPECT_EQ(allocation, commandStream.getGraphicsAllocation());
|
||||
EXPECT_EQ(128u, commandStream.getMaxAvailableSpace());
|
||||
EXPECT_EQ(expectedRootDeviceIndex, commandStream.getGraphicsAllocation()->getRootDeviceIndex());
|
||||
|
||||
commandStreamReceiver->ensureCommandBufferAllocation(commandStream, 1024u, 0u);
|
||||
EXPECT_NE(allocation, commandStream.getGraphicsAllocation());
|
||||
EXPECT_EQ(0u, commandStream.getMaxAvailableSpace() % MemoryConstants::pageSize64k);
|
||||
EXPECT_EQ(expectedRootDeviceIndex, commandStream.getGraphicsAllocation()->getRootDeviceIndex());
|
||||
memoryManager->freeGraphicsMemory(commandStream.getGraphicsAllocation());
|
||||
|
||||
// Debug surface
|
||||
auto debugSurface = commandStreamReceiver->allocateDebugSurface(MemoryConstants::pageSize);
|
||||
ASSERT_NE(nullptr, debugSurface);
|
||||
EXPECT_EQ(expectedRootDeviceIndex, debugSurface->getRootDeviceIndex());
|
||||
|
||||
// Indirect heaps
|
||||
IndirectHeap::Type heapTypes[]{IndirectHeap::DYNAMIC_STATE, IndirectHeap::GENERAL_STATE, IndirectHeap::INDIRECT_OBJECT, IndirectHeap::SURFACE_STATE};
|
||||
for (auto heapType : heapTypes) {
|
||||
IndirectHeap *heap = nullptr;
|
||||
commandStreamReceiver->allocateHeapMemory(heapType, MemoryConstants::pageSize, heap);
|
||||
ASSERT_NE(nullptr, heap);
|
||||
ASSERT_NE(nullptr, heap->getGraphicsAllocation());
|
||||
EXPECT_EQ(expectedRootDeviceIndex, heap->getGraphicsAllocation()->getRootDeviceIndex());
|
||||
memoryManager->freeGraphicsMemory(heap->getGraphicsAllocation());
|
||||
delete heap;
|
||||
}
|
||||
|
||||
// Tag allocation
|
||||
ASSERT_NE(nullptr, commandStreamReceiver->getTagAllocation());
|
||||
EXPECT_EQ(expectedRootDeviceIndex, commandStreamReceiver->getTagAllocation()->getRootDeviceIndex());
|
||||
|
||||
// Preemption allocation
|
||||
if (nullptr == commandStreamReceiver->getPreemptionAllocation()) {
|
||||
commandStreamReceiver->createPreemptionAllocation();
|
||||
}
|
||||
EXPECT_EQ(expectedRootDeviceIndex, commandStreamReceiver->getPreemptionAllocation()->getRootDeviceIndex());
|
||||
|
||||
// HostPtr surface
|
||||
char memory[8] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
HostPtrSurface surface(memory, sizeof(memory), true);
|
||||
EXPECT_TRUE(commandStreamReceiver->createAllocationForHostSurface(surface, false));
|
||||
ASSERT_NE(nullptr, surface.getAllocation());
|
||||
EXPECT_EQ(expectedRootDeviceIndex, surface.getAllocation()->getRootDeviceIndex());
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ struct ComputeModeRequirements : public ::testing::Test {
|
||||
device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
|
||||
csr = new myCsr<FamilyType>(*device->executionEnvironment);
|
||||
device->resetCommandStreamReceiver(csr);
|
||||
AllocationProperties properties(false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
AllocationProperties properties(device->getRootDeviceIndex(), false, MemoryConstants::pageSize, GraphicsAllocation::AllocationType::SHARED_BUFFER, false);
|
||||
|
||||
alloc = device->getMemoryManager()->createGraphicsAllocationFromSharedHandle((osHandle)123, properties, false);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "test.h"
|
||||
#include "unit_tests/fixtures/ult_command_stream_receiver_fixture.h"
|
||||
#include "unit_tests/mocks/mock_experimental_command_buffer.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@@ -258,9 +259,10 @@ HWTEST_F(MockExperimentalCommandBufferTest, givenEnabledExperimentalCmdBufferWhe
|
||||
MemoryManager *memoryManager = commandStreamReceiver.getMemoryManager();
|
||||
|
||||
//Make two allocations, since CSR will try to reuse it also
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({3 * MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
auto rootDeviceIndex = pDevice->getRootDeviceIndex();
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties({rootDeviceIndex, 3 * MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
||||
allocation = memoryManager->allocateGraphicsMemoryWithProperties({3 * MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
allocation = memoryManager->allocateGraphicsMemoryWithProperties({rootDeviceIndex, 3 * MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::COMMAND_BUFFER});
|
||||
storage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
||||
|
||||
MockExperimentalCommandBuffer *mockExCmdBuffer = static_cast<MockExperimentalCommandBuffer *>(commandStreamReceiver.experimentalCmdBuffer.get());
|
||||
@@ -351,3 +353,19 @@ HWTEST_F(ExperimentalCommandBufferTest, givenEnabledExperimentalCmdBufferWhenCom
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.c_str(), "");
|
||||
}
|
||||
|
||||
TEST(ExperimentalCommandBufferRootDeviceIndexTest, experimentalCommandBufferGraphicsAllocationsHaveCorrectRootDeviceIndex) {
|
||||
const uint32_t expectedRootDeviceIndex = 101;
|
||||
|
||||
// Setup
|
||||
auto executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
executionEnvironment->rootDeviceEnvironments.resize(2 * expectedRootDeviceIndex);
|
||||
auto memoryManager = new MockMemoryManager(false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(executionEnvironment, expectedRootDeviceIndex));
|
||||
auto experimentalCommandBuffer = std::make_unique<MockExperimentalCommandBuffer>(&device->getGpgpuCommandStreamReceiver());
|
||||
|
||||
ASSERT_NE(nullptr, experimentalCommandBuffer);
|
||||
EXPECT_EQ(expectedRootDeviceIndex, experimentalCommandBuffer->experimentalAllocation->getRootDeviceIndex());
|
||||
EXPECT_EQ(expectedRootDeviceIndex, experimentalCommandBuffer->timestamps->getRootDeviceIndex());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user