mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 22:43:00 +08:00
Pass canonized gpuAddress in setCpuPtrAndGpuAddress
Related-To: NEO-6523 Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
c51ce2a35c
commit
77dde01503
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -21,7 +21,9 @@ void ImplicitScalingFixture::SetUp() {
|
||||
|
||||
alignedMemory = alignedMalloc(bufferSize, 4096);
|
||||
|
||||
cmdBufferAlloc.setCpuPtrAndGpuAddress(alignedMemory, gpuVa);
|
||||
auto gmmHelper = pDevice->getGmmHelper();
|
||||
auto canonizedGpuAddress = gmmHelper->canonize(gpuVa);
|
||||
cmdBufferAlloc.setCpuPtrAndGpuAddress(alignedMemory, canonizedGpuAddress);
|
||||
|
||||
commandStream.replaceBuffer(alignedMemory, bufferSize);
|
||||
commandStream.replaceGraphicsAllocation(&cmdBufferAlloc);
|
||||
|
||||
@@ -538,12 +538,18 @@ class OsAgnosticMemoryManagerForImagesWithNoHostPtr : public OsAgnosticMemoryMan
|
||||
|
||||
GraphicsAllocation *allocateGraphicsMemoryForImage(const AllocationData &allocationData) override {
|
||||
auto imageAllocation = OsAgnosticMemoryManager::allocateGraphicsMemoryForImage(allocationData);
|
||||
auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex);
|
||||
auto canonizedGpuAddress = gmmHelper->canonize(imageAllocation->getGpuAddress());
|
||||
|
||||
cpuPtr = imageAllocation->getUnderlyingBuffer();
|
||||
imageAllocation->setCpuPtrAndGpuAddress(nullptr, imageAllocation->getGpuAddress());
|
||||
imageAllocation->setCpuPtrAndGpuAddress(nullptr, canonizedGpuAddress);
|
||||
return imageAllocation;
|
||||
};
|
||||
void freeGraphicsMemoryImpl(GraphicsAllocation *imageAllocation) override {
|
||||
imageAllocation->setCpuPtrAndGpuAddress(cpuPtr, imageAllocation->getGpuAddress());
|
||||
auto gmmHelper = getGmmHelper(imageAllocation->getRootDeviceIndex());
|
||||
auto canonizedGpuAddress = gmmHelper->canonize(imageAllocation->getGpuAddress());
|
||||
imageAllocation->setCpuPtrAndGpuAddress(cpuPtr, canonizedGpuAddress);
|
||||
|
||||
OsAgnosticMemoryManager::freeGraphicsMemoryImpl(imageAllocation);
|
||||
};
|
||||
void *lockResourceImpl(GraphicsAllocation &imageAllocation) override {
|
||||
|
||||
@@ -41,11 +41,14 @@ TEST(LinearStreamSimpleTest, givenLinearStreamWithoutGraphicsAllocationWhenGetti
|
||||
|
||||
TEST(LinearStreamSimpleTest, givenLinearStreamWithGraphicsAllocationWhenGettingGpuBaseThenGpuAddressFromGraphicsAllocationIsReturned) {
|
||||
MockGraphicsAllocation gfxAllocation;
|
||||
gfxAllocation.setCpuPtrAndGpuAddress(nullptr, 0x5555000);
|
||||
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, defaultHwInfo.get());
|
||||
auto canonizedGpuAddress = gmmHelper->canonize(0x5555000);
|
||||
|
||||
gfxAllocation.setCpuPtrAndGpuAddress(nullptr, canonizedGpuAddress);
|
||||
uint32_t pCmdBuffer[1024]{};
|
||||
LinearStream linearStream(&gfxAllocation, pCmdBuffer, 1000);
|
||||
|
||||
EXPECT_EQ(0x5555000u, linearStream.getGpuBase());
|
||||
EXPECT_EQ(canonizedGpuAddress, linearStream.getGpuBase());
|
||||
}
|
||||
|
||||
TEST_F(LinearStreamTest, GivenSizeZeroWhenGettingSpaceUsedThenNonNullPointerIsReturned) {
|
||||
@@ -223,4 +226,4 @@ TEST_F(CommandContainerLinearStreamTest, givenLinearStreamWithCmdContainerWhenTh
|
||||
auto ptr = stream->getSpace(0u);
|
||||
stream->getSpace(dummyCommandSize);
|
||||
EXPECT_EQ(memcmp(ptr, hwHelper.getBatchBufferEndReference(), hwHelper.getBatchBufferEndSize()), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/source/indirect_heap/indirect_heap.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
@@ -64,14 +65,17 @@ TEST_F(HeapDirtyStateTests, givenNonDirtyObjectWhenAddressChangedThenReturnDirty
|
||||
|
||||
auto newBuffer = ptrOffset(buffer, MemoryConstants::pageSize + 1);
|
||||
auto graphicsAllocation = stream->getGraphicsAllocation();
|
||||
graphicsAllocation->setCpuPtrAndGpuAddress(newBuffer, castToUint64(newBuffer));
|
||||
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, defaultHwInfo.get());
|
||||
auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(newBuffer));
|
||||
|
||||
graphicsAllocation->setCpuPtrAndGpuAddress(newBuffer, canonizedGpuAddress);
|
||||
|
||||
stream->replaceBuffer(newBuffer, bufferSize);
|
||||
|
||||
EXPECT_TRUE(mockHeapDirtyState.updateAndCheck(stream.get()));
|
||||
|
||||
EXPECT_EQ(1u, mockHeapDirtyState.sizeInPages);
|
||||
EXPECT_EQ(castToUint64(newBuffer), mockHeapDirtyState.gpuBaseAddress);
|
||||
EXPECT_EQ(canonizedGpuAddress, mockHeapDirtyState.gpuBaseAddress);
|
||||
}
|
||||
|
||||
TEST_F(HeapDirtyStateTests, givenIndirectHeapWithoutGraphicsAllocationWhenUpdateAndCheckIsCalledThenSizeIsSetToZero) {
|
||||
@@ -101,14 +105,17 @@ TEST_F(HeapDirtyStateTests, givenNonDirtyObjectWhenSizeAndBufferChangedThenRetur
|
||||
auto newBuffer = ptrOffset(buffer, 1);
|
||||
auto newBufferSize = bufferSize + MemoryConstants::pageSize;
|
||||
auto graphicsAllocation = stream->getGraphicsAllocation();
|
||||
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, defaultHwInfo.get());
|
||||
auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(newBuffer));
|
||||
|
||||
graphicsAllocation->setSize(newBufferSize);
|
||||
graphicsAllocation->setCpuPtrAndGpuAddress(newBuffer, castToUint64(newBuffer));
|
||||
graphicsAllocation->setCpuPtrAndGpuAddress(newBuffer, canonizedGpuAddress);
|
||||
stream->replaceBuffer(stream->getCpuBase(), newBufferSize);
|
||||
|
||||
EXPECT_TRUE(mockHeapDirtyState.updateAndCheck(stream.get()));
|
||||
|
||||
EXPECT_EQ(getSizeInPages(newBufferSize), mockHeapDirtyState.sizeInPages);
|
||||
EXPECT_EQ(castToUint64(newBuffer), mockHeapDirtyState.gpuBaseAddress);
|
||||
EXPECT_EQ(canonizedGpuAddress, mockHeapDirtyState.gpuBaseAddress);
|
||||
}
|
||||
|
||||
TEST(DirtyStateHelpers, givenDirtyStateHelperWhenTwoDifferentIndirectHeapsAreCheckedButWithTheSame4GBbaseThenStateIsNotDirty) {
|
||||
|
||||
Reference in New Issue
Block a user