mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Revert "fix: regression caused by tbx fault mngr"
This reverts commit 9a14fe2478.
Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
136e5b4f6c
commit
124e755b9d
@@ -13,11 +13,9 @@
|
||||
#include "shared/source/helpers/engine_node_helper.h"
|
||||
#include "shared/source/helpers/gfx_core_helper.h"
|
||||
#include "shared/source/helpers/hardware_context_controller.h"
|
||||
#include "shared/source/helpers/options.h"
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/source/memory_manager/memory_banks.h"
|
||||
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "shared/source/page_fault_manager/cpu_page_fault_manager.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/fixtures/mock_aub_center_fixture.h"
|
||||
#include "shared/test/common/fixtures/tbx_command_stream_fixture.h"
|
||||
@@ -1283,199 +1281,3 @@ HWTEST_F(TbxCommandStreamTests, givenTimestampBufferAllocationWhenTbxWriteMemory
|
||||
|
||||
memoryManager->freeGraphicsMemory(timestampAllocation);
|
||||
}
|
||||
|
||||
template <typename FamilyType, CommandStreamReceiverType csrType>
|
||||
struct TbxPageFaultTestFixture {
|
||||
|
||||
class MockTbxCsrForPageFaultTests : public MockTbxCsr<FamilyType> {
|
||||
public:
|
||||
using MockTbxCsr<FamilyType>::MockTbxCsr;
|
||||
|
||||
CpuPageFaultManager *getTbxPageFaultManager() override {
|
||||
return this->tbxFaultManager.get();
|
||||
}
|
||||
|
||||
using MockTbxCsr<FamilyType>::isAllocTbxFaultable;
|
||||
|
||||
std::unique_ptr<TbxPageFaultManager> tbxFaultManager = TbxPageFaultManager::create();
|
||||
};
|
||||
|
||||
static void runTest1(MockDevice *pDevice) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
debugManager.flags.SetCommandStreamReceiver.set(static_cast<int32_t>(csrType));
|
||||
std::unique_ptr<MockTbxCsrForPageFaultTests> tbxCsr(new MockTbxCsrForPageFaultTests(*pDevice->executionEnvironment, pDevice->getDeviceBitfield()));
|
||||
tbxCsr->setupContext(*pDevice->getDefaultEngine().osContext);
|
||||
|
||||
EXPECT_TRUE(tbxCsr->tbxFaultManager->checkFaultHandlerFromPageFaultManager());
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
|
||||
NEO::GraphicsAllocation *gfxAlloc1 = memoryManager->allocateGraphicsMemoryWithProperties(
|
||||
{pDevice->getRootDeviceIndex(),
|
||||
MemoryConstants::pageSize,
|
||||
AllocationType::bufferHostMemory,
|
||||
pDevice->getDeviceBitfield()});
|
||||
|
||||
uint64_t gpuAddress;
|
||||
void *cpuAddress;
|
||||
size_t size;
|
||||
|
||||
EXPECT_TRUE(tbxCsr->getParametersForMemory(*gfxAlloc1, gpuAddress, cpuAddress, size));
|
||||
|
||||
tbxCsr->writeMemory(*gfxAlloc1);
|
||||
EXPECT_FALSE(tbxCsr->isTbxWritable(*gfxAlloc1));
|
||||
|
||||
// accessing outside address range does not affect inserted host allocs
|
||||
auto ptrBelow = (void *)0x0;
|
||||
EXPECT_FALSE(tbxCsr->tbxFaultManager->verifyAndHandlePageFault(ptrBelow, true));
|
||||
auto ptrAbove = ptrOffset(cpuAddress, size + 1);
|
||||
EXPECT_FALSE(tbxCsr->tbxFaultManager->verifyAndHandlePageFault(ptrAbove, true));
|
||||
EXPECT_FALSE(tbxCsr->isTbxWritable(*gfxAlloc1));
|
||||
|
||||
*reinterpret_cast<char *>(cpuAddress) = 1;
|
||||
EXPECT_TRUE(tbxCsr->isTbxWritable(*gfxAlloc1));
|
||||
EXPECT_TRUE(tbxCsr->makeCoherentCalled);
|
||||
tbxCsr->makeCoherentCalled = false;
|
||||
|
||||
tbxCsr->writeMemory(*gfxAlloc1);
|
||||
EXPECT_FALSE(tbxCsr->isTbxWritable(*gfxAlloc1));
|
||||
|
||||
// accessing address with offset that is still in alloc range should
|
||||
// also make writable and download
|
||||
reinterpret_cast<char *>(cpuAddress)[1] = 1;
|
||||
EXPECT_TRUE(tbxCsr->isTbxWritable(*gfxAlloc1));
|
||||
EXPECT_TRUE(tbxCsr->makeCoherentCalled);
|
||||
tbxCsr->makeCoherentCalled = false;
|
||||
|
||||
// for coverage
|
||||
tbxCsr->tbxFaultManager->removeAllocation(static_cast<GraphicsAllocation *>(nullptr));
|
||||
tbxCsr->tbxFaultManager->removeAllocation(gfxAlloc1);
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAlloc1);
|
||||
}
|
||||
|
||||
static void runtTest2(MockDevice *pDevice) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
debugManager.flags.SetCommandStreamReceiver.set(static_cast<int32_t>(csrType));
|
||||
std::unique_ptr<MockTbxCsrForPageFaultTests> tbxCsr(new MockTbxCsrForPageFaultTests(*pDevice->executionEnvironment, pDevice->getDeviceBitfield()));
|
||||
tbxCsr->setupContext(*pDevice->getDefaultEngine().osContext);
|
||||
|
||||
EXPECT_TRUE(tbxCsr->tbxFaultManager->checkFaultHandlerFromPageFaultManager());
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
|
||||
NEO::GraphicsAllocation *gfxAlloc1 = memoryManager->allocateGraphicsMemoryWithProperties(
|
||||
{pDevice->getRootDeviceIndex(),
|
||||
MemoryConstants::pageSize,
|
||||
AllocationType::bufferHostMemory,
|
||||
pDevice->getDeviceBitfield()});
|
||||
|
||||
uint64_t gpuAddress;
|
||||
void *cpuAddress;
|
||||
size_t size;
|
||||
|
||||
EXPECT_TRUE(tbxCsr->getParametersForMemory(*gfxAlloc1, gpuAddress, cpuAddress, size));
|
||||
|
||||
tbxCsr->writeMemory(*gfxAlloc1);
|
||||
tbxCsr->downloadAllocationTbx(*gfxAlloc1);
|
||||
EXPECT_TRUE(!tbxCsr->isTbxWritable(*gfxAlloc1));
|
||||
|
||||
static_cast<float *>(cpuAddress)[0] = 1.0f;
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAlloc1);
|
||||
}
|
||||
|
||||
static void runtTest3(MockDevice *pDevice) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
debugManager.flags.SetCommandStreamReceiver.set(static_cast<int32_t>(csrType));
|
||||
std::unique_ptr<MockTbxCsrForPageFaultTests> tbxCsr(new MockTbxCsrForPageFaultTests(*pDevice->executionEnvironment, pDevice->getDeviceBitfield()));
|
||||
tbxCsr->setupContext(*pDevice->getDefaultEngine().osContext);
|
||||
|
||||
EXPECT_TRUE(tbxCsr->tbxFaultManager->checkFaultHandlerFromPageFaultManager());
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
|
||||
NEO::GraphicsAllocation *gfxAlloc1 = memoryManager->allocateGraphicsMemoryWithProperties(
|
||||
{pDevice->getRootDeviceIndex(),
|
||||
MemoryConstants::pageSize,
|
||||
AllocationType::bufferHostMemory,
|
||||
pDevice->getDeviceBitfield()});
|
||||
|
||||
auto cpuPtr = gfxAlloc1->getDriverAllocatedCpuPtr();
|
||||
|
||||
gfxAlloc1->setDriverAllocatedCpuPtr(nullptr);
|
||||
EXPECT_FALSE(tbxCsr->isAllocTbxFaultable(gfxAlloc1));
|
||||
|
||||
gfxAlloc1->setDriverAllocatedCpuPtr(cpuPtr);
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAlloc1);
|
||||
}
|
||||
|
||||
static void runTest4(MockDevice *pDevice) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
debugManager.flags.SetCommandStreamReceiver.set(static_cast<int32_t>(csrType));
|
||||
std::unique_ptr<MockTbxCsrForPageFaultTests> tbxCsr(new MockTbxCsrForPageFaultTests(*pDevice->executionEnvironment, pDevice->getDeviceBitfield()));
|
||||
tbxCsr->setupContext(*pDevice->getDefaultEngine().osContext);
|
||||
|
||||
EXPECT_TRUE(tbxCsr->tbxFaultManager->checkFaultHandlerFromPageFaultManager());
|
||||
|
||||
auto memoryManager = pDevice->getMemoryManager();
|
||||
|
||||
NEO::GraphicsAllocation *gfxAlloc1 = memoryManager->allocateGraphicsMemoryWithProperties(
|
||||
{pDevice->getRootDeviceIndex(),
|
||||
MemoryConstants::pageSize,
|
||||
AllocationType::bufferHostMemory,
|
||||
pDevice->getDeviceBitfield()});
|
||||
|
||||
uint64_t gpuAddress;
|
||||
void *cpuAddress;
|
||||
size_t size;
|
||||
|
||||
EXPECT_TRUE(tbxCsr->getParametersForMemory(*gfxAlloc1, gpuAddress, cpuAddress, size));
|
||||
*reinterpret_cast<char *>(cpuAddress) = 1;
|
||||
|
||||
tbxCsr->writeMemory(*gfxAlloc1);
|
||||
EXPECT_FALSE(tbxCsr->isTbxWritable(*gfxAlloc1));
|
||||
|
||||
auto readVal = *reinterpret_cast<char *>(cpuAddress);
|
||||
EXPECT_EQ(1, readVal);
|
||||
EXPECT_FALSE(tbxCsr->isTbxWritable(*gfxAlloc1));
|
||||
EXPECT_TRUE(tbxCsr->makeCoherentCalled);
|
||||
tbxCsr->makeCoherentCalled = false;
|
||||
|
||||
tbxCsr->writeMemory(*gfxAlloc1);
|
||||
EXPECT_FALSE(tbxCsr->isTbxWritable(*gfxAlloc1));
|
||||
|
||||
readVal = *reinterpret_cast<char *>(cpuAddress);
|
||||
EXPECT_EQ(1, readVal);
|
||||
EXPECT_FALSE(tbxCsr->isTbxWritable(*gfxAlloc1));
|
||||
EXPECT_TRUE(tbxCsr->makeCoherentCalled);
|
||||
tbxCsr->makeCoherentCalled = false;
|
||||
|
||||
// for coverage
|
||||
tbxCsr->tbxFaultManager->removeAllocation(static_cast<GraphicsAllocation *>(nullptr));
|
||||
tbxCsr->tbxFaultManager->removeAllocation(gfxAlloc1);
|
||||
|
||||
memoryManager->freeGraphicsMemory(gfxAlloc1);
|
||||
}
|
||||
};
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxModeWhenHostWritesHostAllocThenAllocShouldBeDownloadedAndWritable) {
|
||||
TbxPageFaultTestFixture<FamilyType, CommandStreamReceiverType::tbx>::runTest1(pDevice);
|
||||
}
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxWithAubModeWhenHostWritesHostAllocThenAllocShouldBeDownloadedAndWritable) {
|
||||
TbxPageFaultTestFixture<FamilyType, CommandStreamReceiverType::tbxWithAub>::runTest1(pDevice);
|
||||
}
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxWithModeWhenHostBufferNotWritableAndProtectedThenDownloadShouldNotCrash) {
|
||||
TbxPageFaultTestFixture<FamilyType, CommandStreamReceiverType::tbx>::runtTest2(pDevice);
|
||||
}
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenAllocationWithNoDriverAllocatedCpuPtrThenIsAllocTbxFaultableShouldReturnFalse) {
|
||||
TbxPageFaultTestFixture<FamilyType, CommandStreamReceiverType::tbx>::runtTest3(pDevice);
|
||||
}
|
||||
|
||||
HWTEST_F(TbxCommandStreamTests, givenTbxModeWhenHostReadsHostAllocThenAllocShouldBeDownloadedButNotWritable) {
|
||||
TbxPageFaultTestFixture<FamilyType, CommandStreamReceiverType::tbx>::runTest4(pDevice);
|
||||
}
|
||||
|
||||
@@ -452,21 +452,3 @@ TEST(DurationLogTest, givenDurationGetTimeStringThenTimeStringIsCorrect) {
|
||||
EXPECT_TRUE(std::isdigit(c) || c == '[' || c == ']' || c == '.' || c == ' ');
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, GivenTbxOrTbxWithAubCsrTypeWhenCallingIsTbxModeThenReturnTrue) {
|
||||
DebugManagerStateRestore restorer;
|
||||
NEO::debugManager.flags.SetCommandStreamReceiver.set(2);
|
||||
EXPECT_TRUE(NEO::debugManager.isTbxMode());
|
||||
|
||||
NEO::debugManager.flags.SetCommandStreamReceiver.set(4);
|
||||
EXPECT_TRUE(NEO::debugManager.isTbxMode());
|
||||
}
|
||||
|
||||
TEST(DebugSettingsManager, GivenHardwareOrHardwareWithAubCsrTypeWhenCallingIsTbxModeThenReturnFalse) {
|
||||
DebugManagerStateRestore restorer;
|
||||
NEO::debugManager.flags.SetCommandStreamReceiver.set(1);
|
||||
EXPECT_FALSE(NEO::debugManager.isTbxMode());
|
||||
|
||||
NEO::debugManager.flags.SetCommandStreamReceiver.set(3);
|
||||
EXPECT_FALSE(NEO::debugManager.isTbxMode());
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/options.h"
|
||||
#include "shared/source/page_fault_manager/tbx_page_fault_manager.h"
|
||||
#include "shared/test/common/fixtures/cpu_page_fault_manager_tests_fixture.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
@@ -23,7 +21,7 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocsWhenInsertingAllocsThenAllo
|
||||
EXPECT_EQ(pageFaultManager->memoryData.size(), 1u);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc1].size, 10u);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc1].cmdQ, cmdQ);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc1].domain, CpuPageFaultManager::AllocationDomain::cpu);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc1].domain, PageFaultManager::AllocationDomain::cpu);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc1].unifiedMemoryManager, unifiedMemoryManager.get());
|
||||
EXPECT_EQ(pageFaultManager->allowMemoryAccessCalled, 0);
|
||||
EXPECT_EQ(pageFaultManager->protectMemoryCalled, 0);
|
||||
@@ -35,11 +33,11 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocsWhenInsertingAllocsThenAllo
|
||||
EXPECT_EQ(pageFaultManager->memoryData.size(), 2u);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc1].size, 10u);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc1].cmdQ, cmdQ);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc1].domain, CpuPageFaultManager::AllocationDomain::cpu);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc1].domain, PageFaultManager::AllocationDomain::cpu);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc1].unifiedMemoryManager, unifiedMemoryManager.get());
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc2].size, 20u);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc2].cmdQ, cmdQ);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc2].domain, CpuPageFaultManager::AllocationDomain::cpu);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc2].domain, PageFaultManager::AllocationDomain::cpu);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc2].unifiedMemoryManager, unifiedMemoryManager.get());
|
||||
EXPECT_EQ(pageFaultManager->allowMemoryAccessCalled, 0);
|
||||
EXPECT_EQ(pageFaultManager->protectMemoryCalled, 0);
|
||||
@@ -64,7 +62,7 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocWhenRemovingProtectedAllocTh
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc1].size, 10u);
|
||||
EXPECT_EQ(pageFaultManager->memoryData[alloc1].unifiedMemoryManager, unifiedMemoryManager.get());
|
||||
|
||||
pageFaultManager->memoryData[alloc1].domain = CpuPageFaultManager::AllocationDomain::gpu;
|
||||
pageFaultManager->memoryData[alloc1].domain = PageFaultManager::AllocationDomain::gpu;
|
||||
|
||||
pageFaultManager->removeAllocation(alloc1);
|
||||
EXPECT_EQ(pageFaultManager->allowMemoryAccessCalled, 1);
|
||||
@@ -93,7 +91,7 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocWhenRemovingAllocsThenNonGpu
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs.size(), 1u);
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs[0], alloc2);
|
||||
|
||||
pageFaultManager->memoryData.at(alloc2).domain = CpuPageFaultManager::AllocationDomain::gpu;
|
||||
pageFaultManager->memoryData.at(alloc2).domain = PageFaultManager::AllocationDomain::gpu;
|
||||
pageFaultManager->removeAllocation(alloc2);
|
||||
EXPECT_EQ(pageFaultManager->allowMemoryAccessCalled, 1);
|
||||
EXPECT_EQ(pageFaultManager->allowedMemoryAccessAddress, alloc2);
|
||||
@@ -111,7 +109,7 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocWhenAllocNotPresentInNonGpuD
|
||||
|
||||
pageFaultManager->moveAllocationToGpuDomain(alloc1);
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs.size(), 0u);
|
||||
pageFaultManager->memoryData.at(alloc1).domain = CpuPageFaultManager::AllocationDomain::cpu;
|
||||
pageFaultManager->memoryData.at(alloc1).domain = PageFaultManager::AllocationDomain::cpu;
|
||||
pageFaultManager->removeAllocation(alloc1);
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs.size(), 0u);
|
||||
}
|
||||
@@ -129,7 +127,7 @@ TEST_F(PageFaultManagerTest, givenNonGpuAllocsContainerWhenMovingToGpuDomainMult
|
||||
pageFaultManager->moveAllocationToGpuDomain(alloc1);
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs.size(), 1u);
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs[0], alloc2);
|
||||
pageFaultManager->memoryData.at(alloc1).domain = CpuPageFaultManager::AllocationDomain::none;
|
||||
pageFaultManager->memoryData.at(alloc1).domain = PageFaultManager::AllocationDomain::none;
|
||||
pageFaultManager->moveAllocationToGpuDomain(alloc1);
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs.size(), 1u);
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs[0], alloc2);
|
||||
@@ -148,7 +146,7 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocsWhenMovingToGpuDomainAllocs
|
||||
pageFaultManager->insertAllocation(alloc3, 30, unifiedMemoryManager.get(), cmdQ, {});
|
||||
EXPECT_EQ(pageFaultManager->transferToCpuCalled, 0);
|
||||
EXPECT_EQ(pageFaultManager->memoryData.size(), 3u);
|
||||
pageFaultManager->memoryData.at(alloc3).domain = CpuPageFaultManager::AllocationDomain::gpu;
|
||||
pageFaultManager->memoryData.at(alloc3).domain = PageFaultManager::AllocationDomain::gpu;
|
||||
|
||||
pageFaultManager->moveAllocationsWithinUMAllocsManagerToGpuDomain(unifiedMemoryManager.get());
|
||||
|
||||
@@ -168,9 +166,9 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocWhenMovingAllocsOfGivenUMMan
|
||||
pageFaultManager->insertAllocation(alloc1, 10u, unifiedMemoryManager.get(), nullptr, {});
|
||||
pageFaultManager->insertAllocation(alloc2, 20u, unifiedMemoryManager.get(), nullptr, {});
|
||||
|
||||
pageFaultManager->memoryData.at(alloc2).domain = CpuPageFaultManager::AllocationDomain::gpu;
|
||||
pageFaultManager->memoryData.at(alloc2).domain = PageFaultManager::AllocationDomain::gpu;
|
||||
pageFaultManager->moveAllocationsWithinUMAllocsManagerToGpuDomain(unifiedMemoryManager.get());
|
||||
EXPECT_EQ(pageFaultManager->memoryData.at(alloc1).domain, CpuPageFaultManager::AllocationDomain::gpu);
|
||||
EXPECT_EQ(pageFaultManager->memoryData.at(alloc1).domain, PageFaultManager::AllocationDomain::gpu);
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs.size(), 0u);
|
||||
}
|
||||
|
||||
@@ -189,7 +187,7 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocsWhenMovingToGpuDomainWithPr
|
||||
pageFaultManager->insertAllocation(alloc3, 30, unifiedMemoryManager.get(), cmdQ, {});
|
||||
EXPECT_EQ(pageFaultManager->transferToCpuCalled, 0);
|
||||
EXPECT_EQ(pageFaultManager->memoryData.size(), 3u);
|
||||
pageFaultManager->memoryData.at(alloc3).domain = CpuPageFaultManager::AllocationDomain::gpu;
|
||||
pageFaultManager->memoryData.at(alloc3).domain = PageFaultManager::AllocationDomain::gpu;
|
||||
|
||||
testing::internal::CaptureStdout(); // start capturing
|
||||
|
||||
@@ -221,8 +219,8 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocsWhenMovingToGpuDomainAllocs
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs.size(), 2u);
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs[0], alloc1);
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs[1], alloc2);
|
||||
pageFaultManager->memoryData.at(alloc1).domain = CpuPageFaultManager::AllocationDomain::cpu;
|
||||
pageFaultManager->memoryData.at(alloc2).domain = CpuPageFaultManager::AllocationDomain::none;
|
||||
pageFaultManager->memoryData.at(alloc1).domain = PageFaultManager::AllocationDomain::cpu;
|
||||
pageFaultManager->memoryData.at(alloc2).domain = PageFaultManager::AllocationDomain::none;
|
||||
|
||||
pageFaultManager->moveAllocationsWithinUMAllocsManagerToGpuDomain(unifiedMemoryManager.get());
|
||||
|
||||
@@ -368,13 +366,13 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocWhenMovingToGpuDomainThenUpd
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs.size(), 2u);
|
||||
|
||||
pageFaultManager->moveAllocationToGpuDomain(alloc1);
|
||||
EXPECT_EQ(pageFaultManager->memoryData.at(alloc1).domain, CpuPageFaultManager::AllocationDomain::gpu);
|
||||
EXPECT_EQ(pageFaultManager->memoryData.at(alloc1).domain, PageFaultManager::AllocationDomain::gpu);
|
||||
const auto &allocsVec = unifiedMemoryManager->nonGpuDomainAllocs;
|
||||
EXPECT_EQ(std::find(allocsVec.cbegin(), allocsVec.cend(), alloc1), allocsVec.cend());
|
||||
EXPECT_EQ(allocsVec.size(), 1u);
|
||||
EXPECT_EQ(allocsVec[0], alloc2);
|
||||
|
||||
pageFaultManager->memoryData.at(alloc2).domain = CpuPageFaultManager::AllocationDomain::gpu;
|
||||
pageFaultManager->memoryData.at(alloc2).domain = PageFaultManager::AllocationDomain::gpu;
|
||||
pageFaultManager->moveAllocationToGpuDomain(alloc2);
|
||||
EXPECT_NE(std::find(allocsVec.cbegin(), allocsVec.cend(), alloc2), allocsVec.cend());
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs.size(), 1u);
|
||||
@@ -415,7 +413,7 @@ TEST_F(PageFaultManagerTest, givenUnifiedMemoryAllocInGpuDomainWhenMovingToGpuDo
|
||||
pageFaultManager->insertAllocation(alloc, 10, unifiedMemoryManager.get(), cmdQ, {});
|
||||
EXPECT_EQ(pageFaultManager->transferToCpuCalled, 0);
|
||||
EXPECT_EQ(pageFaultManager->memoryData.size(), 1u);
|
||||
pageFaultManager->memoryData.at(alloc).domain = CpuPageFaultManager::AllocationDomain::gpu;
|
||||
pageFaultManager->memoryData.at(alloc).domain = PageFaultManager::AllocationDomain::gpu;
|
||||
|
||||
pageFaultManager->moveAllocationToGpuDomain(alloc);
|
||||
EXPECT_EQ(pageFaultManager->allowMemoryAccessCalled, 0);
|
||||
@@ -541,15 +539,15 @@ TEST_F(PageFaultManagerTest, givenAllocsFromCpuDomainWhenVerifyingPageFaultThenD
|
||||
pageFaultManager->moveAllocationsWithinUMAllocsManagerToGpuDomain(unifiedMemoryManager.get());
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs.size(), 0u);
|
||||
|
||||
pageFaultManager->memoryData.at(alloc2).domain = CpuPageFaultManager::AllocationDomain::none;
|
||||
pageFaultManager->memoryData.at(alloc2).domain = PageFaultManager::AllocationDomain::none;
|
||||
pageFaultManager->verifyAndHandlePageFault(alloc2, true);
|
||||
EXPECT_EQ(pageFaultManager->memoryData.at(alloc2).domain, CpuPageFaultManager::AllocationDomain::cpu);
|
||||
EXPECT_EQ(pageFaultManager->memoryData.at(alloc2).domain, PageFaultManager::AllocationDomain::cpu);
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs.size(), 0u);
|
||||
|
||||
pageFaultManager->gpuDomainHandler = &MockPageFaultManager::unprotectAndTransferMemory;
|
||||
pageFaultManager->memoryData.at(alloc1).domain = CpuPageFaultManager::AllocationDomain::none;
|
||||
pageFaultManager->memoryData.at(alloc1).domain = PageFaultManager::AllocationDomain::none;
|
||||
pageFaultManager->verifyAndHandlePageFault(alloc1, true);
|
||||
EXPECT_EQ(pageFaultManager->memoryData.at(alloc1).domain, CpuPageFaultManager::AllocationDomain::cpu);
|
||||
EXPECT_EQ(pageFaultManager->memoryData.at(alloc1).domain, PageFaultManager::AllocationDomain::cpu);
|
||||
EXPECT_EQ(unifiedMemoryManager->nonGpuDomainAllocs.size(), 0u);
|
||||
}
|
||||
|
||||
@@ -904,7 +902,7 @@ struct PageFaultManagerTestWithDebugFlag : public ::testing::TestWithParam<uint3
|
||||
TEST_P(PageFaultManagerTestWithDebugFlag, givenDebugFlagWhenInsertingAllocationThenItOverridesHints) {
|
||||
DebugManagerStateRestore restore;
|
||||
debugManager.flags.UsmInitialPlacement.set(GetParam()); // Should be ignored by the driver, when passing hints
|
||||
const auto expectedDomain = GetParam() == 1 ? CpuPageFaultManager::AllocationDomain::none : CpuPageFaultManager::AllocationDomain::cpu;
|
||||
const auto expectedDomain = GetParam() == 1 ? PageFaultManager::AllocationDomain::none : PageFaultManager::AllocationDomain::cpu;
|
||||
|
||||
void *allocs[] = {
|
||||
reinterpret_cast<void *>(0x1),
|
||||
@@ -955,59 +953,24 @@ TEST_F(PageFaultManagerTest, givenNoUsmInitialPlacementFlagsWHenInsertingUsmAllo
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = 0;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = 0;
|
||||
pageFaultManager->insertAllocation(allocs[0], 10, unifiedMemoryManager.get(), cmdQ, memoryProperties);
|
||||
EXPECT_EQ(CpuPageFaultManager::AllocationDomain::cpu, pageFaultManager->memoryData.at(allocs[0]).domain);
|
||||
EXPECT_EQ(PageFaultManager::AllocationDomain::cpu, pageFaultManager->memoryData.at(allocs[0]).domain);
|
||||
EXPECT_EQ(allocs[0], unifiedMemoryManager->nonGpuDomainAllocs[0]);
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = 0;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = 1;
|
||||
pageFaultManager->insertAllocation(allocs[1], 10, unifiedMemoryManager.get(), cmdQ, memoryProperties);
|
||||
EXPECT_EQ(CpuPageFaultManager::AllocationDomain::none, pageFaultManager->memoryData.at(allocs[1]).domain);
|
||||
EXPECT_EQ(PageFaultManager::AllocationDomain::none, pageFaultManager->memoryData.at(allocs[1]).domain);
|
||||
EXPECT_EQ(allocs[1], unifiedMemoryManager->nonGpuDomainAllocs[1]);
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = 1;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = 0;
|
||||
pageFaultManager->insertAllocation(allocs[2], 10, unifiedMemoryManager.get(), cmdQ, memoryProperties);
|
||||
EXPECT_EQ(CpuPageFaultManager::AllocationDomain::cpu, pageFaultManager->memoryData.at(allocs[2]).domain);
|
||||
EXPECT_EQ(PageFaultManager::AllocationDomain::cpu, pageFaultManager->memoryData.at(allocs[2]).domain);
|
||||
EXPECT_EQ(allocs[2], unifiedMemoryManager->nonGpuDomainAllocs[2]);
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = 1;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = 1;
|
||||
pageFaultManager->insertAllocation(allocs[3], 10, unifiedMemoryManager.get(), cmdQ, memoryProperties);
|
||||
EXPECT_EQ(CpuPageFaultManager::AllocationDomain::cpu, pageFaultManager->memoryData.at(allocs[3]).domain);
|
||||
EXPECT_EQ(PageFaultManager::AllocationDomain::cpu, pageFaultManager->memoryData.at(allocs[3]).domain);
|
||||
EXPECT_EQ(allocs[3], unifiedMemoryManager->nonGpuDomainAllocs[3]);
|
||||
}
|
||||
|
||||
TEST_F(PageFaultManagerTest, givenTbxModeWhenAllocateSharedMemoryThenTbxFaultManagerShouldBehaveLikeCpuFaultManager) {
|
||||
auto memoryManager2 = std::make_unique<MockMemoryManager>(executionEnvironment);
|
||||
auto unifiedMemoryManager2 = std::make_unique<SVMAllocsManager>(memoryManager2.get(), false);
|
||||
auto pageFaultManager2 = std::make_unique<MockPageFaultManagerImpl<TbxPageFaultManager>>();
|
||||
void *cmdQ = reinterpret_cast<void *>(0xFFFF);
|
||||
|
||||
RootDeviceIndicesContainer rootDeviceIndices = {mockRootDeviceIndex};
|
||||
std::map<uint32_t, DeviceBitfield> deviceBitfields{{mockRootDeviceIndex, mockDeviceBitfield}};
|
||||
|
||||
auto properties = SVMAllocsManager::UnifiedMemoryProperties(InternalMemoryType::sharedUnifiedMemory, 1, rootDeviceIndices, deviceBitfields);
|
||||
void *ptr = unifiedMemoryManager2->createSharedUnifiedMemoryAllocation(10, properties, cmdQ);
|
||||
|
||||
pageFaultManager2->insertAllocation(ptr, 10, unifiedMemoryManager2.get(), cmdQ, {});
|
||||
|
||||
EXPECT_TRUE(pageFaultManager2->verifyAndHandlePageFault(ptr, true));
|
||||
EXPECT_EQ(pageFaultManager2->protectWritesCalled, 0);
|
||||
|
||||
unifiedMemoryManager2->freeSVMAlloc(ptr);
|
||||
}
|
||||
|
||||
TEST_F(PageFaultManagerTest, givenHardwareModeWhenCallTbxInsertOrRemoveApiThenNothing) {
|
||||
auto pageFaultManager2 = std::make_unique<MockPageFaultManagerImpl<CpuPageFaultManager>>();
|
||||
|
||||
auto ptr = reinterpret_cast<void *>(0XFFFF);
|
||||
auto gfxAlloc = reinterpret_cast<GraphicsAllocation *>(0xFFFF);
|
||||
auto csr = reinterpret_cast<CommandStreamReceiver *>(0xFFFF);
|
||||
pageFaultManager2->insertAllocation(csr, gfxAlloc, 0, ptr, 0);
|
||||
EXPECT_EQ(pageFaultManager2->memoryData.find(ptr), pageFaultManager2->memoryData.end());
|
||||
|
||||
pageFaultManager2->memoryData[ptr] = {};
|
||||
pageFaultManager2->removeAllocation(gfxAlloc);
|
||||
EXPECT_FALSE(pageFaultManager2->memoryData.find(ptr) == pageFaultManager2->memoryData.end());
|
||||
pageFaultManager2->memoryData.erase(ptr);
|
||||
}
|
||||
|
||||
@@ -156,4 +156,4 @@ TEST_F(PageFaultManagerTest,
|
||||
EXPECT_EQ(0u, csr->getEvictionAllocations().size());
|
||||
|
||||
unifiedMemoryManager->freeSVMAlloc(ptr);
|
||||
}
|
||||
}
|
||||
@@ -29,11 +29,11 @@ const char *neoMockSettingsFileName = "neo_mock.config";
|
||||
bool CompressionSelector::preferCompressedAllocation(const AllocationProperties &properties) {
|
||||
return false;
|
||||
}
|
||||
void CpuPageFaultManager::transferToCpu(void *ptr, size_t size, void *cmdQ) {
|
||||
void PageFaultManager::transferToCpu(void *ptr, size_t size, void *cmdQ) {
|
||||
}
|
||||
void CpuPageFaultManager::transferToGpu(void *ptr, void *cmdQ) {
|
||||
void PageFaultManager::transferToGpu(void *ptr, void *cmdQ) {
|
||||
}
|
||||
void CpuPageFaultManager::allowCPUMemoryEviction(bool evict, void *ptr, PageFaultData &pageFaultData) {
|
||||
void PageFaultManager::allowCPUMemoryEviction(bool evict, void *ptr, PageFaultData &pageFaultData) {
|
||||
}
|
||||
|
||||
void RootDeviceEnvironment::initApiGfxCoreHelper() {
|
||||
|
||||
Reference in New Issue
Block a user