Add flags to control addresing mode of direct submission allocations

Related-To: NEO-4338

Change-Id: I40ff0110d0f414a0e2d0167e86d9a148b17a0921
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2020-03-25 14:55:23 +01:00
committed by sys_ocldev
parent b9ffd012be
commit 2dde71fa74
4 changed files with 113 additions and 18 deletions

View File

@ -739,6 +739,78 @@ TEST(MemoryManagerTest, givenDirectSemaphorePlacementSetWhenOverrideToSystemThen
EXPECT_EQ(1u, allocationData.flags.useSystemMemory);
}
TEST(MemoryManagerTest, givenDirectBufferAddressingWhenOverrideToNo48BitThenExpect48BitFlagFalse) {
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionBufferAddressing.set(0);
AllocationData allocationData;
AllocationProperties properties(0, 0x1000, GraphicsAllocation::AllocationType::RING_BUFFER);
allocationData.flags.resource48Bit = 1;
MockMemoryManager::overrideAllocationData(allocationData, properties);
EXPECT_EQ(0u, allocationData.flags.resource48Bit);
}
TEST(MemoryManagerTest, givenDirectBufferAddressingWhenOverrideTo48BitThenExpect48BitFlagTrue) {
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionBufferAddressing.set(1);
AllocationData allocationData;
AllocationProperties properties(0, 0x1000, GraphicsAllocation::AllocationType::RING_BUFFER);
allocationData.flags.resource48Bit = 0;
MockMemoryManager::overrideAllocationData(allocationData, properties);
EXPECT_EQ(1u, allocationData.flags.resource48Bit);
}
TEST(MemoryManagerTest, givenDirectBufferAddressingDefaultWhenNoOverrideThenExpect48BitFlagSame) {
AllocationData allocationData;
AllocationProperties properties(0, 0x1000, GraphicsAllocation::AllocationType::RING_BUFFER);
allocationData.flags.resource48Bit = 0;
MockMemoryManager::overrideAllocationData(allocationData, properties);
EXPECT_EQ(0u, allocationData.flags.resource48Bit);
allocationData.flags.resource48Bit = 1;
MockMemoryManager::overrideAllocationData(allocationData, properties);
EXPECT_EQ(1u, allocationData.flags.resource48Bit);
}
TEST(MemoryManagerTest, givenDirectSemaphoreAddressingWhenOverrideToNo48BitThenExpect48BitFlagFalse) {
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionSemaphoreAddressing.set(0);
AllocationData allocationData;
AllocationProperties properties(0, 0x1000, GraphicsAllocation::AllocationType::SEMAPHORE_BUFFER);
allocationData.flags.resource48Bit = 1;
MockMemoryManager::overrideAllocationData(allocationData, properties);
EXPECT_EQ(0u, allocationData.flags.resource48Bit);
}
TEST(MemoryManagerTest, givenDirectSemaphoreAddressingWhenOverrideTo48BitThenExpect48BitFlagTrue) {
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionSemaphoreAddressing.set(1);
AllocationData allocationData;
AllocationProperties properties(0, 0x1000, GraphicsAllocation::AllocationType::SEMAPHORE_BUFFER);
allocationData.flags.resource48Bit = 0;
MockMemoryManager::overrideAllocationData(allocationData, properties);
EXPECT_EQ(1u, allocationData.flags.resource48Bit);
}
TEST(MemoryManagerTest, givenDirectSemaphoreAddressingDefaultWhenNoOverrideThenExpect48BitFlagSame) {
AllocationData allocationData;
AllocationProperties properties(0, 0x1000, GraphicsAllocation::AllocationType::SEMAPHORE_BUFFER);
allocationData.flags.resource48Bit = 0;
MockMemoryManager::overrideAllocationData(allocationData, properties);
EXPECT_EQ(0u, allocationData.flags.resource48Bit);
allocationData.flags.resource48Bit = 1;
MockMemoryManager::overrideAllocationData(allocationData, properties);
EXPECT_EQ(1u, allocationData.flags.resource48Bit);
}
using MemoryManagerGetAlloctionDataHaveToBeForcedTo48BitTest = testing::TestWithParam<std::tuple<GraphicsAllocation::AllocationType, bool>>;
TEST_P(MemoryManagerGetAlloctionDataHaveToBeForcedTo48BitTest, givenAllocationTypesHaveToBeForcedTo48BitThenAllocationDataResource48BitIsSet) {

View File

@ -138,4 +138,6 @@ WddmResidencyLogger = 0
DirectSubmissionEnableDebugBuffer = 0
DirectSubmissionDisableCacheFlush = 0
DirectSubmissionDisableMonitorFence = 0
ForceFineGrainedSVMSupport = -1
ForceFineGrainedSVMSupport = -1
DirectSubmissionBufferAddressing = -1
DirectSubmissionSemaphoreAddressing = -1

View File

@ -83,6 +83,8 @@ DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagn
DECLARE_DEBUG_VARIABLE(int32_t, EnableDirectSubmission, -1, "-1: default (disabled), 0: disable, 1:enable. Enables direct submission of command buffers bypassing KMD")
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionBufferPlacement, -1, "-1: do not override, 0: non-system, 1: system")
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionSemaphorePlacement, -1, "-1: do not override, 0: non-system, 1: system")
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionBufferAddressing, -1, "-1: do not override, 0: not use 48bit, 1: use 48bit")
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionSemaphoreAddressing, -1, "-1: do not override, 0: not use 48bit, 1: use 48bit")
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionDisableCpuCacheFlush, -1, "-1: do not override, 0: disable, 1: enable")
DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionEnableDebugBuffer, 0, "0: diagnostic feature disabled - dispatch regular workload, 1: dispatch diagnostic buffer - mode 1 - single SDI command, 2: dispatch diagnostic buffer - mode 2 - no command")
DECLARE_DEBUG_VARIABLE(bool, DirectSubmissionDisableCacheFlush, false, "Disable dispatching cache flush commands")

View File

@ -588,26 +588,45 @@ bool MemoryManager::isCopyRequired(ImageInfo &imgInfo, const void *hostPtr) {
void MemoryManager::overrideAllocationData(AllocationData &allocationData, const AllocationProperties &properties) {
int32_t directRingPlacement = DebugManager.flags.DirectSubmissionBufferPlacement.get();
if (properties.allocationType == GraphicsAllocation::AllocationType::RING_BUFFER &&
directRingPlacement != -1) {
if (directRingPlacement == 0) {
allocationData.flags.requiresCpuAccess = true;
allocationData.flags.useSystemMemory = false;
} else {
allocationData.flags.requiresCpuAccess = false;
allocationData.flags.useSystemMemory = true;
int32_t directRingAddressing = DebugManager.flags.DirectSubmissionBufferAddressing.get();
if (properties.allocationType == GraphicsAllocation::AllocationType::RING_BUFFER) {
if (directRingPlacement != -1) {
if (directRingPlacement == 0) {
allocationData.flags.requiresCpuAccess = true;
allocationData.flags.useSystemMemory = false;
} else {
allocationData.flags.requiresCpuAccess = false;
allocationData.flags.useSystemMemory = true;
}
}
if (directRingAddressing != -1) {
if (directRingAddressing == 0) {
allocationData.flags.resource48Bit = false;
} else {
allocationData.flags.resource48Bit = true;
}
}
}
int32_t directSemaphorePlacement = DebugManager.flags.DirectSubmissionSemaphorePlacement.get();
if (properties.allocationType == GraphicsAllocation::AllocationType::SEMAPHORE_BUFFER &&
directSemaphorePlacement != -1) {
if (directSemaphorePlacement == 0) {
allocationData.flags.requiresCpuAccess = true;
allocationData.flags.useSystemMemory = false;
} else {
allocationData.flags.requiresCpuAccess = false;
allocationData.flags.useSystemMemory = true;
int32_t directSemaphoreAddressing = DebugManager.flags.DirectSubmissionSemaphoreAddressing.get();
if (properties.allocationType == GraphicsAllocation::AllocationType::SEMAPHORE_BUFFER) {
if (directSemaphorePlacement != -1) {
if (directSemaphorePlacement == 0) {
allocationData.flags.requiresCpuAccess = true;
allocationData.flags.useSystemMemory = false;
} else {
allocationData.flags.requiresCpuAccess = false;
allocationData.flags.useSystemMemory = true;
}
}
if (directSemaphoreAddressing != -1) {
if (directSemaphoreAddressing == 0) {
allocationData.flags.resource48Bit = false;
} else {
allocationData.flags.resource48Bit = true;
}
}
}
}
} // namespace NEO
} // namespace NEO