mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 10:17:01 +08:00
Add UsmInitialPlacement debug flag
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
fc389b72f7
commit
7334920ed3
@@ -164,6 +164,7 @@ DisableIndirectAccess = -1
|
||||
ForceOCLVersion = 0
|
||||
ForceOCL21FeaturesSupport = -1
|
||||
ForcePreemptionMode = -1
|
||||
UsmInitialPlacement = -1
|
||||
ForceKernelPreemptionMode = -1
|
||||
NodeOrdinal = -1
|
||||
OverrideThreadArbitrationPolicy = -1
|
||||
|
||||
@@ -317,6 +317,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, PassBoundBOToExec, -1, "Pass bound BOs to exec c
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, EnableStaticPartitioning, -1, "Divide workload into partitions during dispatch, -1: default, 0: disabled, 1: enabled")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, UpdateTaskCountFromWait, -1, " Do not update task count after each enqueue, but send update request while wait, -1: default(disabled), 0: disabled, 1: enabled")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, DeferOsContextInitialization, -1, "-1: default, 0: create all contexts immediately, 1: defer, if possible")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, UsmInitialPlacement, -1, "-1: default, 0: optimize for first CPU access, 1: optimize for first GPU access")
|
||||
DECLARE_DEBUG_VARIABLE(int32_t, ForceHostPointerImport, -1, "-1: default, 0: disable, 1: enable, Forces the driver to import every host pointer coming into driver, WARNING this is not spec complaint.")
|
||||
DECLARE_DEBUG_VARIABLE(bool, UseMaxSimdSizeToDeduceMaxWorkgroupSize, false, "With this flag on, max workgroup size is deduced using SIMD32 instead of SIMD8, this causes the max wkg size to be 4 times bigger")
|
||||
DECLARE_DEBUG_VARIABLE(bool, ReturnRawGpuTimestamps, false, "Driver returns raw GPU tiemstamps instead of calculated ones.")
|
||||
|
||||
@@ -17,7 +17,16 @@
|
||||
|
||||
namespace NEO {
|
||||
void PageFaultManager::insertAllocation(void *ptr, size_t size, SVMAllocsManager *unifiedMemoryManager, void *cmdQ, const MemoryProperties &memoryProperties) {
|
||||
const bool initialPlacementCpu = !memoryProperties.allocFlags.usmInitialPlacementGpu;
|
||||
bool initialPlacementCpu = true;
|
||||
if (memoryProperties.allocFlags.usmInitialPlacementGpu) {
|
||||
initialPlacementCpu = false;
|
||||
}
|
||||
if (memoryProperties.allocFlags.usmInitialPlacementCpu) {
|
||||
initialPlacementCpu = true;
|
||||
}
|
||||
if (const int32_t debugFlag = DebugManager.flags.UsmInitialPlacement.get(); debugFlag != -1) {
|
||||
initialPlacementCpu = debugFlag != 1;
|
||||
}
|
||||
const auto domain = initialPlacementCpu ? AllocationDomain::Cpu : AllocationDomain::None;
|
||||
|
||||
std::unique_lock<SpinLock> lock{mtx};
|
||||
|
||||
@@ -451,3 +451,92 @@ TEST(PageFaultManager, givenHwCsrWhenSelectingHandlerThenHwGpuDomainHandlerIsSet
|
||||
EXPECT_EQ(defaultHandler, reinterpret_cast<void *>(pageFaultManager->gpuDomainHandler));
|
||||
}
|
||||
}
|
||||
|
||||
struct PageFaultManagerTestWithDebugFlag : public ::testing::TestWithParam<uint32_t> {
|
||||
void SetUp() {
|
||||
memoryManager = std::make_unique<MockMemoryManager>(executionEnvironment);
|
||||
unifiedMemoryManager = std::make_unique<SVMAllocsManager>(memoryManager.get(), false);
|
||||
pageFaultManager = std::make_unique<MockPageFaultManager>();
|
||||
cmdQ = reinterpret_cast<void *>(0xFFFF);
|
||||
}
|
||||
|
||||
MemoryProperties memoryProperties{};
|
||||
MockExecutionEnvironment executionEnvironment{};
|
||||
std::unique_ptr<MockMemoryManager> memoryManager;
|
||||
std::unique_ptr<SVMAllocsManager> unifiedMemoryManager;
|
||||
std::unique_ptr<MockPageFaultManager> pageFaultManager;
|
||||
void *cmdQ;
|
||||
};
|
||||
|
||||
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 ? PageFaultManager::AllocationDomain::None : PageFaultManager::AllocationDomain::Cpu;
|
||||
|
||||
void *allocs[] = {
|
||||
reinterpret_cast<void *>(0x1),
|
||||
reinterpret_cast<void *>(0x2),
|
||||
reinterpret_cast<void *>(0x3),
|
||||
reinterpret_cast<void *>(0x4),
|
||||
};
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = 0;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = 0;
|
||||
pageFaultManager->insertAllocation(allocs[0], 10, unifiedMemoryManager.get(), cmdQ, memoryProperties);
|
||||
EXPECT_EQ(expectedDomain, pageFaultManager->memoryData.at(allocs[0]).domain);
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = 0;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = 1;
|
||||
pageFaultManager->insertAllocation(allocs[1], 10, unifiedMemoryManager.get(), cmdQ, memoryProperties);
|
||||
EXPECT_EQ(expectedDomain, pageFaultManager->memoryData.at(allocs[1]).domain);
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = 1;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = 0;
|
||||
pageFaultManager->insertAllocation(allocs[2], 10, unifiedMemoryManager.get(), cmdQ, memoryProperties);
|
||||
EXPECT_EQ(expectedDomain, pageFaultManager->memoryData.at(allocs[2]).domain);
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = 1;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = 1;
|
||||
pageFaultManager->insertAllocation(allocs[3], 10, unifiedMemoryManager.get(), cmdQ, memoryProperties);
|
||||
EXPECT_EQ(expectedDomain, pageFaultManager->memoryData.at(allocs[3]).domain);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
PageFaultManagerTestWithDebugFlag,
|
||||
PageFaultManagerTestWithDebugFlag,
|
||||
::testing::Values(0, 1));
|
||||
|
||||
TEST_F(PageFaultManagerTest, givenNoUsmInitialPlacementFlagsWHenInsertingUsmAllocationThenUseTheDefaultDomain) {
|
||||
MemoryProperties memoryProperties{};
|
||||
MockExecutionEnvironment executionEnvironment{};
|
||||
auto memoryManager = std::make_unique<MockMemoryManager>(executionEnvironment);
|
||||
auto unifiedMemoryManager = std::make_unique<SVMAllocsManager>(memoryManager.get(), false);
|
||||
auto pageFaultManager = std::make_unique<MockPageFaultManager>();
|
||||
auto cmdQ = reinterpret_cast<void *>(0xFFFF);
|
||||
void *allocs[] = {
|
||||
reinterpret_cast<void *>(0x1),
|
||||
reinterpret_cast<void *>(0x2),
|
||||
reinterpret_cast<void *>(0x3),
|
||||
reinterpret_cast<void *>(0x4),
|
||||
};
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = 0;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = 0;
|
||||
pageFaultManager->insertAllocation(allocs[0], 10, unifiedMemoryManager.get(), cmdQ, memoryProperties);
|
||||
EXPECT_EQ(PageFaultManager::AllocationDomain::Cpu, pageFaultManager->memoryData.at(allocs[0]).domain);
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = 0;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = 1;
|
||||
pageFaultManager->insertAllocation(allocs[1], 10, unifiedMemoryManager.get(), cmdQ, memoryProperties);
|
||||
EXPECT_EQ(PageFaultManager::AllocationDomain::None, pageFaultManager->memoryData.at(allocs[1]).domain);
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = 1;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = 0;
|
||||
pageFaultManager->insertAllocation(allocs[2], 10, unifiedMemoryManager.get(), cmdQ, memoryProperties);
|
||||
EXPECT_EQ(PageFaultManager::AllocationDomain::Cpu, pageFaultManager->memoryData.at(allocs[2]).domain);
|
||||
|
||||
memoryProperties.allocFlags.usmInitialPlacementCpu = 1;
|
||||
memoryProperties.allocFlags.usmInitialPlacementGpu = 1;
|
||||
pageFaultManager->insertAllocation(allocs[3], 10, unifiedMemoryManager.get(), cmdQ, memoryProperties);
|
||||
EXPECT_EQ(PageFaultManager::AllocationDomain::Cpu, pageFaultManager->memoryData.at(allocs[3]).domain);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user