mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Revert "Move kernel globals from SVM to USM device"
This reverts commit 706a5a7a8c
.
Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
f7a4790d84
commit
45c8124d8f
@ -1229,7 +1229,7 @@ uint64_t DrmMemoryManager::getLocalMemorySize(uint32_t rootDeviceIndex, uint32_t
|
||||
}
|
||||
|
||||
bool DrmMemoryManager::copyMemoryToAllocation(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy) {
|
||||
if (graphicsAllocation->getUnderlyingBuffer()) {
|
||||
if (graphicsAllocation->getUnderlyingBuffer() || !isLocalMemorySupported(graphicsAllocation->getRootDeviceIndex())) {
|
||||
return MemoryManager::copyMemoryToAllocation(graphicsAllocation, destinationOffset, memoryToCopy, sizeToCopy);
|
||||
}
|
||||
return copyMemoryToAllocationBanks(graphicsAllocation, destinationOffset, memoryToCopy, sizeToCopy, maxNBitValue(graphicsAllocation->storageInfo.getNumBanks()));
|
||||
|
@ -39,16 +39,14 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAlloc
|
||||
rootDeviceIndices.push_back(rootDeviceIndex);
|
||||
std::map<uint32_t, DeviceBitfield> subDeviceBitfields;
|
||||
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->createSVMAlloc(size, svmProps, rootDeviceIndices, subDeviceBitfields);
|
||||
DEBUG_BREAK_IF(ptr == nullptr);
|
||||
if (ptr == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
auto usmAlloc = svmAllocManager->getSVMAlloc(ptr);
|
||||
UNRECOVERABLE_IF(usmAlloc == nullptr);
|
||||
gpuAllocation = usmAlloc->gpuAllocations.getGraphicsAllocation(rootDeviceIndex);
|
||||
auto svmAlloc = svmAllocManager->getSVMAlloc(ptr);
|
||||
UNRECOVERABLE_IF(svmAlloc == nullptr);
|
||||
gpuAllocation = svmAlloc->gpuAllocations.getGraphicsAllocation(rootDeviceIndex);
|
||||
} else {
|
||||
auto allocationType = constant ? AllocationType::CONSTANT_SURFACE : AllocationType::GLOBAL_SURFACE;
|
||||
gpuAllocation = device.getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex,
|
||||
|
@ -20,7 +20,6 @@ class MockGraphicsAllocation : public MemoryAllocation {
|
||||
using MemoryAllocation::allocationOffset;
|
||||
using MemoryAllocation::allocationType;
|
||||
using MemoryAllocation::aubInfo;
|
||||
using MemoryAllocation::cpuPtr;
|
||||
using MemoryAllocation::gpuAddress;
|
||||
using MemoryAllocation::MemoryAllocation;
|
||||
using MemoryAllocation::memoryPool;
|
||||
|
@ -5,7 +5,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
@ -20,15 +19,3 @@ TEST(MemoryManagerTest, WhenCallingIsAllocationTypeToCaptureThenScratchAndPrivat
|
||||
EXPECT_TRUE(mockMemoryManager.isAllocationTypeToCapture(AllocationType::LINEAR_STREAM));
|
||||
EXPECT_TRUE(mockMemoryManager.isAllocationTypeToCapture(AllocationType::INTERNAL_HEAP));
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenAllocationWithNullCpuPtrThenMemoryCopyToAllocationReturnsFalse) {
|
||||
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
constexpr uint8_t allocationSize = 10;
|
||||
uint8_t allocationStorage[allocationSize] = {0};
|
||||
MockGraphicsAllocation allocation{allocationStorage, allocationSize};
|
||||
allocation.cpuPtr = nullptr;
|
||||
constexpr size_t offset = 0;
|
||||
|
||||
EXPECT_FALSE(memoryManager.copyMemoryToAllocation(&allocation, offset, nullptr, 0));
|
||||
}
|
||||
|
@ -1495,7 +1495,7 @@ TEST_F(DrmMemoryManagerCopyMemoryToAllocationPrelimTest, givenDrmMemoryManagerWh
|
||||
size_t sourceAllocationSize = MemoryConstants::pageSize;
|
||||
size_t destinationAllocationSize = sourceAllocationSize + offset;
|
||||
|
||||
DrmMemoryManagerToTestCopyMemoryToAllocation drmMemoryManager(*executionEnvironment, true, destinationAllocationSize);
|
||||
DrmMemoryManagerToTestCopyMemoryToAllocation drmMemoryManger(*executionEnvironment, true, destinationAllocationSize);
|
||||
std::vector<uint8_t> dataToCopy(sourceAllocationSize, 1u);
|
||||
|
||||
AllocationData allocData;
|
||||
@ -1507,19 +1507,19 @@ TEST_F(DrmMemoryManagerCopyMemoryToAllocationPrelimTest, givenDrmMemoryManagerWh
|
||||
allocData.storageInfo.memoryBanks.set(0, true);
|
||||
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
auto allocation = drmMemoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
auto allocation = drmMemoryManger.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
auto ret = drmMemoryManager.copyMemoryToAllocation(allocation, offset, dataToCopy.data(), dataToCopy.size());
|
||||
auto ret = drmMemoryManger.copyMemoryToAllocation(allocation, offset, dataToCopy.data(), dataToCopy.size());
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(drmMemoryManager.lockedLocalMemory[0].get(), offset), dataToCopy.data(), dataToCopy.size()));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(drmMemoryManger.lockedLocalMemory[0].get(), offset), dataToCopy.data(), dataToCopy.size()));
|
||||
|
||||
drmMemoryManager.freeGraphicsMemory(allocation);
|
||||
drmMemoryManger.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerCopyMemoryToAllocationPrelimTest, givenDrmMemoryManagerWhenCopyMemoryToAllocationFailsToLockResourceThenItReturnsFalse) {
|
||||
DrmMemoryManagerToTestCopyMemoryToAllocation drmMemoryManager(*executionEnvironment, true, 0);
|
||||
DrmMemoryManagerToTestCopyMemoryToAllocation drmMemoryManger(*executionEnvironment, true, 0);
|
||||
std::vector<uint8_t> dataToCopy(MemoryConstants::pageSize, 1u);
|
||||
|
||||
AllocationData allocData;
|
||||
@ -1530,13 +1530,13 @@ TEST_F(DrmMemoryManagerCopyMemoryToAllocationPrelimTest, givenDrmMemoryManagerWh
|
||||
allocData.rootDeviceIndex = rootDeviceIndex;
|
||||
allocData.storageInfo.memoryBanks.set(0, true);
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
auto allocation = drmMemoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
auto allocation = drmMemoryManger.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
auto ret = drmMemoryManager.copyMemoryToAllocation(allocation, 0, dataToCopy.data(), dataToCopy.size());
|
||||
auto ret = drmMemoryManger.copyMemoryToAllocation(allocation, 0, dataToCopy.data(), dataToCopy.size());
|
||||
EXPECT_FALSE(ret);
|
||||
|
||||
drmMemoryManager.freeGraphicsMemory(allocation);
|
||||
drmMemoryManger.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerCopyMemoryToAllocationPrelimTest, givenDrmMemoryManagerWhenCopyMemoryToAllocationWithCpuPtrThenAllocationIsFilledWithCorrectData) {
|
||||
@ -1544,18 +1544,18 @@ TEST_F(DrmMemoryManagerCopyMemoryToAllocationPrelimTest, givenDrmMemoryManagerWh
|
||||
size_t sourceAllocationSize = MemoryConstants::pageSize;
|
||||
size_t destinationAllocationSize = sourceAllocationSize + offset;
|
||||
|
||||
DrmMemoryManagerToTestCopyMemoryToAllocation drmMemoryManager(*executionEnvironment, false, 0);
|
||||
DrmMemoryManagerToTestCopyMemoryToAllocation drmMemoryManger(*executionEnvironment, false, 0);
|
||||
std::vector<uint8_t> dataToCopy(sourceAllocationSize, 1u);
|
||||
|
||||
auto allocation = drmMemoryManager.allocateGraphicsMemoryWithProperties({mockRootDeviceIndex, destinationAllocationSize, AllocationType::KERNEL_ISA, mockDeviceBitfield});
|
||||
auto allocation = drmMemoryManger.allocateGraphicsMemoryWithProperties({mockRootDeviceIndex, destinationAllocationSize, AllocationType::KERNEL_ISA, mockDeviceBitfield});
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
auto ret = drmMemoryManager.copyMemoryToAllocation(allocation, offset, dataToCopy.data(), dataToCopy.size());
|
||||
auto ret = drmMemoryManger.copyMemoryToAllocation(allocation, offset, dataToCopy.data(), dataToCopy.size());
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(allocation->getUnderlyingBuffer(), offset), dataToCopy.data(), dataToCopy.size()));
|
||||
|
||||
drmMemoryManager.freeGraphicsMemory(allocation);
|
||||
drmMemoryManger.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerCopyMemoryToAllocationPrelimTest, givenDrmMemoryManagerWhenCopyMemoryToAllocationOnAllMemoryBanksReturnsSuccessThenAllocationIsFilledWithCorrectData) {
|
||||
@ -1563,7 +1563,7 @@ TEST_F(DrmMemoryManagerCopyMemoryToAllocationPrelimTest, givenDrmMemoryManagerWh
|
||||
size_t sourceAllocationSize = MemoryConstants::pageSize;
|
||||
size_t destinationAllocationSize = sourceAllocationSize + offset;
|
||||
|
||||
DrmMemoryManagerToTestCopyMemoryToAllocation drmMemoryManager(*executionEnvironment, true, destinationAllocationSize);
|
||||
DrmMemoryManagerToTestCopyMemoryToAllocation drmMemoryManger(*executionEnvironment, true, destinationAllocationSize);
|
||||
std::vector<uint8_t> dataToCopy(sourceAllocationSize, 1u);
|
||||
|
||||
AllocationData allocData;
|
||||
@ -1574,17 +1574,17 @@ TEST_F(DrmMemoryManagerCopyMemoryToAllocationPrelimTest, givenDrmMemoryManagerWh
|
||||
allocData.storageInfo.memoryBanks = maxNBitValue(MemoryBanks::getBankForLocalMemory(3));
|
||||
allocData.rootDeviceIndex = rootDeviceIndex;
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
auto allocation = drmMemoryManager.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
auto allocation = drmMemoryManger.allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
auto ret = drmMemoryManager.copyMemoryToAllocation(allocation, offset, dataToCopy.data(), dataToCopy.size());
|
||||
auto ret = drmMemoryManger.copyMemoryToAllocation(allocation, offset, dataToCopy.data(), dataToCopy.size());
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
for (auto index = 0u; index < 3; index++) {
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(drmMemoryManager.lockedLocalMemory[index].get(), offset), dataToCopy.data(), dataToCopy.size()));
|
||||
EXPECT_EQ(0, memcmp(ptrOffset(drmMemoryManger.lockedLocalMemory[index].get(), offset), dataToCopy.data(), dataToCopy.size()));
|
||||
}
|
||||
|
||||
drmMemoryManager.freeGraphicsMemory(allocation);
|
||||
drmMemoryManger.freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
typedef Test<DrmMemoryManagerFixturePrelim> DrmMemoryManagerTestPrelim;
|
||||
|
@ -62,7 +62,7 @@ TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreNotExportedTh
|
||||
device.getMemoryManager()->freeGraphicsMemory(alloc);
|
||||
}
|
||||
|
||||
TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreExportedThenMemoryIsAllocatedAsUsmDeviceAllocation) {
|
||||
TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreExportedThenMemoryIsAllocatedAsSvmAllocation) {
|
||||
MockDevice device{};
|
||||
REQUIRE_SVM_OR_SKIP(&device);
|
||||
MockMemoryManager memoryManager;
|
||||
@ -77,11 +77,10 @@ TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreExportedThenM
|
||||
|
||||
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), true /* constant */, &linkerInputExportGlobalConstants, initData.data());
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
ASSERT_EQ(MemoryConstants::pageSize64k, alloc->getUnderlyingBufferSize());
|
||||
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
||||
ASSERT_NE(nullptr, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress()))));
|
||||
EXPECT_TRUE(alloc->isMemObjectsAllocationWithWritableFlags());
|
||||
EXPECT_EQ(DEVICE_UNIFIED_MEMORY, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(alloc->getGpuAddress()))->memoryType);
|
||||
EXPECT_FALSE(alloc->isMemObjectsAllocationWithWritableFlags());
|
||||
svmAllocsManager.freeSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress())));
|
||||
|
||||
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), true /* constant */, &linkerInputExportGlobalVariables, initData.data());
|
||||
@ -100,11 +99,10 @@ TEST(AllocateGlobalSurfaceTest, GivenSvmAllocsManagerWhenGlobalsAreExportedThenM
|
||||
|
||||
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), false /* constant */, &linkerInputExportGlobalVariables, initData.data());
|
||||
ASSERT_NE(nullptr, alloc);
|
||||
ASSERT_EQ(MemoryConstants::pageSize64k, alloc->getUnderlyingBufferSize());
|
||||
ASSERT_EQ(initData.size(), alloc->getUnderlyingBufferSize());
|
||||
EXPECT_EQ(0, memcmp(alloc->getUnderlyingBuffer(), initData.data(), initData.size()));
|
||||
EXPECT_NE(nullptr, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress()))));
|
||||
EXPECT_TRUE(alloc->isMemObjectsAllocationWithWritableFlags());
|
||||
EXPECT_EQ(DEVICE_UNIFIED_MEMORY, svmAllocsManager.getSVMAlloc(reinterpret_cast<void *>(alloc->getGpuAddress()))->memoryType);
|
||||
svmAllocsManager.freeSVMAlloc(reinterpret_cast<void *>(static_cast<uintptr_t>(alloc->getGpuAddress())));
|
||||
}
|
||||
|
||||
@ -183,6 +181,26 @@ TEST(AllocateGlobalSurfaceTest, WhenGlobalsAreNotExportedAndAllocationFailsThenG
|
||||
EXPECT_EQ(nullptr, alloc);
|
||||
}
|
||||
|
||||
TEST(AllocateGlobalSurfaceTest, WhenGlobalsAreExportedAndAllocationFailsThenGracefullyReturnsNullptr) {
|
||||
MockDevice device{};
|
||||
MockMemoryManager memoryManager{*device.getExecutionEnvironment()};
|
||||
MockSVMAllocsManager svmAllocsManager(&memoryManager, false);
|
||||
memoryManager.failInAllocateWithSizeAndAlignment = true;
|
||||
WhiteBox<LinkerInput> linkerInputExportGlobalVariables;
|
||||
WhiteBox<LinkerInput> linkerInputExportGlobalConstants;
|
||||
linkerInputExportGlobalVariables.traits.exportsGlobalVariables = true;
|
||||
linkerInputExportGlobalConstants.traits.exportsGlobalConstants = true;
|
||||
std::vector<uint8_t> initData;
|
||||
initData.resize(64, 7U);
|
||||
GraphicsAllocation *alloc = nullptr;
|
||||
|
||||
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), true /* constant */, &linkerInputExportGlobalConstants, initData.data());
|
||||
EXPECT_EQ(nullptr, alloc);
|
||||
|
||||
alloc = allocateGlobalsSurface(&svmAllocsManager, device, initData.size(), false /* constant */, &linkerInputExportGlobalVariables, initData.data());
|
||||
EXPECT_EQ(nullptr, alloc);
|
||||
}
|
||||
|
||||
TEST(AllocateGlobalSurfaceTest, GivenAllocationInLocalMemoryWhichRequiresBlitterWhenAllocatingNonSvmAllocationThenBlitterIsUsed) {
|
||||
REQUIRE_SVM_OR_SKIP(defaultHwInfo.get());
|
||||
DebugManagerStateRestore restorer;
|
||||
|
Reference in New Issue
Block a user