Flush tlb only when new resource is bound

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2021-04-14 14:40:23 +00:00
committed by Compute-Runtime-Automation
parent 46c51cb8a9
commit 83a1a52bdc
13 changed files with 255 additions and 14 deletions

View File

@@ -903,7 +903,7 @@ HWTEST_F(DirectSubmissionTest,
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
*osContext.get());
EXPECT_FALSE(UllsDefaults::defaultDisableCacheFlush);
EXPECT_TRUE(UllsDefaults::defaultDisableCacheFlush);
EXPECT_FALSE(UllsDefaults::defaultDisableMonitorFence);
EXPECT_TRUE(directSubmission.disableCacheFlush);
EXPECT_FALSE(directSubmission.disableMonitorFence);
@@ -938,7 +938,7 @@ HWTEST_F(DirectSubmissionTest,
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
*osContext.get());
EXPECT_FALSE(UllsDefaults::defaultDisableCacheFlush);
EXPECT_TRUE(UllsDefaults::defaultDisableCacheFlush);
EXPECT_FALSE(UllsDefaults::defaultDisableMonitorFence);
EXPECT_TRUE(directSubmission.disableCacheFlush);
EXPECT_FALSE(directSubmission.disableMonitorFence);
@@ -973,7 +973,7 @@ HWTEST_F(DirectSubmissionTest,
NEO::IoFunctions::mockFcloseCalled = 0u;
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
*osContext.get());
EXPECT_FALSE(UllsDefaults::defaultDisableCacheFlush);
EXPECT_TRUE(UllsDefaults::defaultDisableCacheFlush);
EXPECT_FALSE(UllsDefaults::defaultDisableMonitorFence);
EXPECT_TRUE(directSubmission.disableCacheFlush);
EXPECT_FALSE(directSubmission.disableMonitorFence);
@@ -1014,7 +1014,7 @@ HWTEST_F(DirectSubmissionTest,
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
*osContext.get());
uint32_t expectedSemaphoreValue = directSubmission.currentQueueWorkCount;
EXPECT_FALSE(UllsDefaults::defaultDisableCacheFlush);
EXPECT_TRUE(UllsDefaults::defaultDisableCacheFlush);
EXPECT_FALSE(UllsDefaults::defaultDisableMonitorFence);
EXPECT_TRUE(directSubmission.disableCacheFlush);
EXPECT_TRUE(directSubmission.disableMonitorFence);
@@ -1039,7 +1039,7 @@ HWTEST_F(DirectSubmissionTest,
EXPECT_EQ(expectedSize, directSubmission.ringCommandStream.getUsed());
EXPECT_EQ(expectedSemaphoreValue, directSubmission.currentQueueWorkCount);
EXPECT_FALSE(directSubmission.disableCacheFlush);
EXPECT_TRUE(directSubmission.disableCacheFlush);
EXPECT_FALSE(directSubmission.disableMonitorFence);
EXPECT_EQ(0u, directSubmission.workloadMode);
EXPECT_EQ(nullptr, directSubmission.diagnostic.get());
@@ -1101,7 +1101,7 @@ HWTEST_F(DirectSubmissionTest,
MockDirectSubmissionHw<FamilyType, Dispatcher> directSubmission(*pDevice,
*osContext.get());
uint32_t expectedSemaphoreValue = directSubmission.currentQueueWorkCount;
EXPECT_FALSE(UllsDefaults::defaultDisableCacheFlush);
EXPECT_TRUE(UllsDefaults::defaultDisableCacheFlush);
EXPECT_FALSE(UllsDefaults::defaultDisableMonitorFence);
EXPECT_TRUE(directSubmission.disableCacheFlush);
EXPECT_TRUE(directSubmission.disableMonitorFence);
@@ -1127,7 +1127,7 @@ HWTEST_F(DirectSubmissionTest,
EXPECT_EQ(expectedSize, directSubmission.ringCommandStream.getUsed());
EXPECT_EQ(expectedSemaphoreValue, directSubmission.currentQueueWorkCount);
EXPECT_FALSE(directSubmission.disableCacheFlush);
EXPECT_TRUE(directSubmission.disableCacheFlush);
EXPECT_FALSE(directSubmission.disableMonitorFence);
EXPECT_EQ(0u, directSubmission.workloadMode);
EXPECT_EQ(nullptr, directSubmission.diagnostic.get());

View File

@@ -8,6 +8,8 @@
#include "shared/source/direct_submission/dispatchers/render_dispatcher.h"
#include "shared/source/direct_submission/linux/drm_direct_submission.h"
#include "shared/source/os_interface/linux/os_context_linux.h"
#include "shared/test/common/cmd_parse/hw_parse.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/helpers/ult_hw_config.h"
#include "shared/test/common/mocks/mock_device.h"
@@ -46,8 +48,11 @@ struct MockDrmDirectSubmission : public DrmDirectSubmission<GfxFamily, Dispatche
using BaseClass::allocateResources;
using BaseClass::currentTagData;
using BaseClass::DrmDirectSubmission;
using BaseClass::getSizeNewResourceHandler;
using BaseClass::getTagAddressValue;
using BaseClass::handleNewResourcesSubmission;
using BaseClass::handleResidency;
using BaseClass::isNewResourceHandleNeeded;
using BaseClass::submit;
using BaseClass::switchRingBuffers;
using BaseClass::tagAddress;
@@ -101,3 +106,154 @@ HWTEST_F(DrmDirectSubmissionTest, whenCheckForDirectSubmissionSupportThenProperV
auto &hwHelper = HwHelper::get(device->getHardwareInfo().platform.eRenderCoreFamily);
EXPECT_EQ(directSubmissionSupported, hwHelper.isDirectSubmissionSupported() && executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->getDrm()->isVmBindAvailable());
}
HWTEST_F(DrmDirectSubmissionTest, givenDirectSubmissionNewResourceTlbFlushWhenDispatchCommandBufferThenTlbIsFlushed) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using Dispatcher = RenderDispatcher<FamilyType>;
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionNewResourceTlbFlush.set(1);
MockDrmDirectSubmission<FamilyType, Dispatcher> directSubmission(*device.get(),
*osContext.get());
bool ret = directSubmission.allocateResources();
EXPECT_TRUE(ret);
EXPECT_EQ(directSubmission.getSizeNewResourceHandler(), sizeof(PIPE_CONTROL));
directSubmission.handleNewResourcesSubmission();
HardwareParse hwParse;
hwParse.parsePipeControl = true;
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, 0);
hwParse.findHardwareCommands<FamilyType>();
auto *pipeControl = hwParse.getCommand<PIPE_CONTROL>();
EXPECT_TRUE(pipeControl->getTlbInvalidate());
EXPECT_EQ(directSubmission.getSizeNewResourceHandler(), sizeof(PIPE_CONTROL));
}
HWTEST_F(DrmDirectSubmissionTest, givenNewResourceBoundhWhenDispatchCommandBufferThenTlbIsFlushed) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using Dispatcher = RenderDispatcher<FamilyType>;
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionNewResourceTlbFlush.set(-1);
MockDrmDirectSubmission<FamilyType, Dispatcher> directSubmission(*device.get(),
*osContext.get());
bool ret = directSubmission.allocateResources();
EXPECT_TRUE(ret);
auto drm = static_cast<DrmMock *>(executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->getDrm());
drm->setNewResourceBound(true);
EXPECT_EQ(directSubmission.getSizeNewResourceHandler(), sizeof(PIPE_CONTROL));
directSubmission.handleNewResourcesSubmission();
HardwareParse hwParse;
hwParse.parsePipeControl = true;
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, 0);
hwParse.findHardwareCommands<FamilyType>();
auto *pipeControl = hwParse.getCommand<PIPE_CONTROL>();
EXPECT_TRUE(pipeControl->getTlbInvalidate());
EXPECT_FALSE(drm->getNewResourceBound());
EXPECT_EQ(directSubmission.getSizeNewResourceHandler(), 0u);
}
HWTEST_F(DrmDirectSubmissionTest, givennoNewResourceBoundhWhenDispatchCommandBufferThenTlbIsNotFlushed) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using Dispatcher = RenderDispatcher<FamilyType>;
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionNewResourceTlbFlush.set(-1);
MockDrmDirectSubmission<FamilyType, Dispatcher> directSubmission(*device.get(),
*osContext.get());
bool ret = directSubmission.allocateResources();
EXPECT_TRUE(ret);
auto drm = static_cast<DrmMock *>(executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->getDrm());
drm->setNewResourceBound(false);
EXPECT_EQ(directSubmission.getSizeNewResourceHandler(), 0u);
directSubmission.handleNewResourcesSubmission();
HardwareParse hwParse;
hwParse.parsePipeControl = true;
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, 0);
hwParse.findHardwareCommands<FamilyType>();
auto *pipeControl = hwParse.getCommand<PIPE_CONTROL>();
EXPECT_EQ(pipeControl, nullptr);
EXPECT_FALSE(drm->getNewResourceBound());
EXPECT_EQ(directSubmission.getSizeNewResourceHandler(), 0u);
}
HWTEST_F(DrmDirectSubmissionTest, givenDirectSubmissionNewResourceTlbFlusZeroAndNewResourceBoundhWhenDispatchCommandBufferThenTlbIsNotFlushed) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using Dispatcher = RenderDispatcher<FamilyType>;
DebugManagerStateRestore restorer;
DebugManager.flags.DirectSubmissionNewResourceTlbFlush.set(0);
MockDrmDirectSubmission<FamilyType, Dispatcher> directSubmission(*device.get(),
*osContext.get());
bool ret = directSubmission.allocateResources();
EXPECT_TRUE(ret);
auto drm = static_cast<DrmMock *>(executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->getDrm());
drm->setNewResourceBound(true);
EXPECT_EQ(directSubmission.getSizeNewResourceHandler(), 0u);
directSubmission.handleNewResourcesSubmission();
HardwareParse hwParse;
hwParse.parsePipeControl = true;
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, 0);
hwParse.findHardwareCommands<FamilyType>();
auto *pipeControl = hwParse.getCommand<PIPE_CONTROL>();
EXPECT_EQ(pipeControl, nullptr);
EXPECT_FALSE(drm->getNewResourceBound());
EXPECT_EQ(directSubmission.getSizeNewResourceHandler(), 0u);
}
HWTEST_F(DrmDirectSubmissionTest, givenBlitterDispatcherWhenHandleNewResourceThenDoNotFlushTlb) {
using MI_FLUSH = typename FamilyType::MI_FLUSH_DW;
using Dispatcher = BlitterDispatcher<FamilyType>;
auto osContext = std::make_unique<OsContextLinux>(*executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->getDrm(),
0u, device->getDeviceBitfield(), EngineTypeUsage{aub_stream::ENGINE_BCS, EngineUsage::Regular}, PreemptionMode::ThreadGroup,
false);
MockDrmDirectSubmission<FamilyType, Dispatcher> directSubmission(*device.get(),
*osContext.get());
bool ret = directSubmission.allocateResources();
EXPECT_TRUE(ret);
auto drm = static_cast<DrmMock *>(executionEnvironment.rootDeviceEnvironments[0]->osInterface->get()->getDrm());
drm->setNewResourceBound(true);
EXPECT_EQ(directSubmission.getSizeNewResourceHandler(), 0u);
directSubmission.handleNewResourcesSubmission();
HardwareParse hwParse;
hwParse.parsePipeControl = true;
hwParse.parseCommands<FamilyType>(directSubmission.ringCommandStream, 0);
hwParse.findHardwareCommands<FamilyType>();
auto *miFlush = hwParse.getCommand<MI_FLUSH>();
EXPECT_EQ(miFlush, nullptr);
EXPECT_TRUE(drm->getNewResourceBound());
EXPECT_EQ(directSubmission.getSizeNewResourceHandler(), 0u);
}