Pass proper device bitfield when allocating global/constant surface

Related-To: NEO-4484
Change-Id: Iecb968bfc6ed3f7e3dc216dab3f26693c1b949d6
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-04-16 17:24:38 +02:00
committed by sys_ocldev
parent b58371df4e
commit a604eee07b
4 changed files with 35 additions and 1 deletions

View File

@@ -37,6 +37,7 @@ void *MockMemoryManager::allocateSystemMemory(size_t size, size_t alignment) {
}
GraphicsAllocation *MockMemoryManager::allocateGraphicsMemoryWithProperties(const AllocationProperties &properties) {
recentlyPassedDeviceBitfield = properties.subDevicesBitfield;
AllocationProperties adjustedProperties(properties);
adjustedProperties.size = redundancyRatio * properties.size;
return OsAgnosticMemoryManager::allocateGraphicsMemoryWithProperties(adjustedProperties);

View File

@@ -131,6 +131,7 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
bool cpuCopyRequired = false;
bool forceRenderCompressed = false;
std::unique_ptr<MockExecutionEnvironment> mockExecutionEnvironment;
DeviceBitfield recentlyPassedDeviceBitfield{};
};
using AllocationData = MockMemoryManager::AllocationData;

View File

@@ -182,6 +182,20 @@ TEST_F(ProgramDataTest, AllocateConstantMemorySurfaceProgramBinaryInfo) {
EXPECT_EQ(0, memcmp(constValue, pProgram->getConstantSurface()->getUnderlyingBuffer(), constSize));
}
TEST_F(ProgramDataTest, givenProgramWhenAllocatingConstantMemorySurfaceThenProperDeviceBitfieldIsPassed) {
auto executionEnvironment = pProgram->getDevice().getExecutionEnvironment();
auto memoryManager = new MockMemoryManager(*executionEnvironment);
std::unique_ptr<MemoryManager> memoryManagerBackup(memoryManager);
std::swap(memoryManagerBackup, executionEnvironment->memoryManager);
EXPECT_NE(pProgram->getDevice().getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield);
setupConstantAllocation();
buildAndDecodeProgramPatchList();
EXPECT_NE(nullptr, pProgram->getConstantSurface());
EXPECT_EQ(pProgram->getDevice().getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield);
std::swap(memoryManagerBackup, executionEnvironment->memoryManager);
}
TEST_F(ProgramDataTest, whenGlobalConstantsAreExportedThenAllocateSurfacesAsSvm) {
if (this->pContext->getSVMAllocsManager() == nullptr) {
return;
@@ -354,6 +368,20 @@ TEST_F(ProgramDataTest, AllocateGlobalMemorySurfaceProgramBinaryInfo) {
EXPECT_NE(nullptr, pProgram->getGlobalSurface());
EXPECT_EQ(0, memcmp(globalValue, pProgram->getGlobalSurface()->getUnderlyingBuffer(), globalSize));
}
TEST_F(ProgramDataTest, givenProgramWhenAllocatingGlobalMemorySurfaceThenProperDeviceBitfieldIsPassed) {
auto executionEnvironment = pProgram->getDevice().getExecutionEnvironment();
auto memoryManager = new MockMemoryManager(*executionEnvironment);
std::unique_ptr<MemoryManager> memoryManagerBackup(memoryManager);
std::swap(memoryManagerBackup, executionEnvironment->memoryManager);
EXPECT_NE(pProgram->getDevice().getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield);
setupGlobalAllocation();
buildAndDecodeProgramPatchList();
EXPECT_NE(nullptr, pProgram->getGlobalSurface());
EXPECT_EQ(pProgram->getDevice().getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield);
std::swap(memoryManagerBackup, executionEnvironment->memoryManager);
}
TEST_F(ProgramDataTest, Given32BitDeviceWhenGlobalMemorySurfaceIsPresentThenItHas32BitStorage) {
char globalValue[] = "55667788";

View File

@@ -41,7 +41,11 @@ GraphicsAllocation *allocateGlobalsSurface(NEO::SVMAllocsManager *const svmAlloc
return svmAllocManager->getSVMAlloc(ptr)->gpuAllocation;
} else {
auto allocationType = constant ? GraphicsAllocation::AllocationType::CONSTANT_SURFACE : GraphicsAllocation::AllocationType::GLOBAL_SURFACE;
auto gpuAlloc = device.getMemoryManager()->allocateGraphicsMemoryWithProperties({device.getRootDeviceIndex(), size, allocationType});
auto gpuAlloc = device.getMemoryManager()->allocateGraphicsMemoryWithProperties({device.getRootDeviceIndex(),
true, // allocateMemory
size, allocationType,
false, // isMultiStorageAllocation
device.getDeviceBitfield()});
DEBUG_BREAK_IF(gpuAlloc == nullptr);
if (gpuAlloc == nullptr) {
return nullptr;