Skip to content

Commit d45d62e

Browse files
Add debug flag to force nonblocking exec buffer calls when using prelim kernel
Related-To: NEO-7144 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 3b46954 commit d45d62e

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

shared/source/debug_settings/debug_variables_base.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, ForceStatelessMocsEncryptionBit, -1, "-1: defaul
223223
DECLARE_DEBUG_VARIABLE(int32_t, CopyHostPtrOnCpu, -1, "-1: default, 0: disable, 1:enable, In clCreateBuffer with CL_MEM_COPY_HOST_PTR, copy memory using locked ptr on cpu")
224224
DECLARE_DEBUG_VARIABLE(int32_t, ForceZeDeviceCanAccessPerReturnValue, -1, "-1: default, 0: zeDeviceCanAccessPeer always return false 1: zeDeviceCanAccessPeer always return true")
225225
DECLARE_DEBUG_VARIABLE(int32_t, AdjustThreadGroupDispatchSize, -1, "-1: default, 0: do not adjust thread group dispatch size 1: adjust thread group dispatch size (PVC)")
226+
DECLARE_DEBUG_VARIABLE(int32_t, ForceNonblockingExecbufferCalls, -1, "-1: default, 0: make execbuffer call blocking, 1: make execbuffer call nonblocking. Supported only in prelim i915 kernels.")
226227

227228
/*LOGGING FLAGS*/
228229
DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level")

shared/source/os_interface/linux/ioctl_helper_prelim.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ namespace NEO {
3131

3232
IoctlHelperPrelim20::IoctlHelperPrelim20(Drm &drmArg) : IoctlHelper(drmArg) {
3333
auto hwHelper = HwInfoConfig::get(this->drm.getRootDeviceEnvironment().getHardwareInfo()->platform.eProductFamily);
34-
if (hwHelper && hwHelper->isNonBlockingGpuSubmissionSupported()) {
35-
handleExecBufferInNonBlockMode = true;
34+
handleExecBufferInNonBlockMode = hwHelper && hwHelper->isNonBlockingGpuSubmissionSupported();
35+
if (DebugManager.flags.ForceNonblockingExecbufferCalls.get() != -1) {
36+
handleExecBufferInNonBlockMode = DebugManager.flags.ForceNonblockingExecbufferCalls.get();
37+
}
38+
if (handleExecBufferInNonBlockMode) {
3639
auto fileDescriptor = this->drm.getFileDescriptor();
3740
SysCalls::fcntl(fileDescriptor, F_SETFL, SysCalls::fcntl(fileDescriptor, F_GETFL) | O_NONBLOCK);
3841
}

shared/test/common/test_files/igdrcl.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,4 +477,5 @@ PrintCompletionFenceUsage = 0
477477
SetAmountOfReusableAllocations = -1
478478
ExperimentalSmallBufferPoolAllocator = -1
479479
ForceZeDeviceCanAccessPerReturnValue = -1
480-
AdjustThreadGroupDispatchSize = -1
480+
AdjustThreadGroupDispatchSize = -1
481+
ForceNonblockingExecbufferCalls = -1

shared/test/unit_test/os_interface/linux/ioctl_helper_tests_prelim.cpp

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,4 +464,47 @@ HWTEST2_F(IoctlPrelimHelperTests, givenNonXeHpcWhenCreatingIoctlHelperThenProper
464464

465465
EXPECT_EQ(0, SysCalls::getFileDescriptorFlagsCalled);
466466
EXPECT_EQ(0, SysCalls::setFileDescriptorFlagsCalled);
467-
}
467+
}
468+
469+
TEST_F(IoctlPrelimHelperTests, givenDisabledForceNonblockingExecbufferCallsFlagWhenCreatingIoctlHelperThenExecBufferIsHandledBlocking) {
470+
DebugManagerStateRestore restorer;
471+
472+
DebugManager.flags.ForceNonblockingExecbufferCalls.set(0);
473+
MockExecutionEnvironment executionEnvironment{};
474+
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
475+
476+
VariableBackup<decltype(SysCalls::getFileDescriptorFlagsCalled)> backupGetFlags(&SysCalls::getFileDescriptorFlagsCalled, 0);
477+
VariableBackup<decltype(SysCalls::setFileDescriptorFlagsCalled)> backupSetFlags(&SysCalls::setFileDescriptorFlagsCalled, 0);
478+
VariableBackup<decltype(SysCalls::passedFileDescriptorFlagsToSet)> backupPassedFlags(&SysCalls::passedFileDescriptorFlagsToSet, 0);
479+
480+
IoctlHelperPrelim20 ioctlHelper{*drm};
481+
482+
EXPECT_EQ(0, SysCalls::getFileDescriptorFlagsCalled);
483+
EXPECT_EQ(0, SysCalls::setFileDescriptorFlagsCalled);
484+
485+
EXPECT_TRUE(ioctlHelper.checkIfIoctlReinvokeRequired(EAGAIN, DrmIoctl::GemExecbuffer2));
486+
EXPECT_TRUE(ioctlHelper.checkIfIoctlReinvokeRequired(EAGAIN, DrmIoctl::GemVmBind));
487+
EXPECT_TRUE(ioctlHelper.checkIfIoctlReinvokeRequired(EBUSY, DrmIoctl::GemExecbuffer2));
488+
}
489+
490+
TEST_F(IoctlPrelimHelperTests, givenEnabledForceNonblockingExecbufferCallsFlagWhenCreatingIoctlHelperThenExecBufferIsHandledNonBlocking) {
491+
DebugManagerStateRestore restorer;
492+
493+
DebugManager.flags.ForceNonblockingExecbufferCalls.set(1);
494+
MockExecutionEnvironment executionEnvironment{};
495+
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
496+
497+
VariableBackup<decltype(SysCalls::getFileDescriptorFlagsCalled)> backupGetFlags(&SysCalls::getFileDescriptorFlagsCalled, 0);
498+
VariableBackup<decltype(SysCalls::setFileDescriptorFlagsCalled)> backupSetFlags(&SysCalls::setFileDescriptorFlagsCalled, 0);
499+
VariableBackup<decltype(SysCalls::passedFileDescriptorFlagsToSet)> backupPassedFlags(&SysCalls::passedFileDescriptorFlagsToSet, 0);
500+
501+
IoctlHelperPrelim20 ioctlHelper{*drm};
502+
503+
EXPECT_EQ(1, SysCalls::getFileDescriptorFlagsCalled);
504+
EXPECT_EQ(1, SysCalls::setFileDescriptorFlagsCalled);
505+
EXPECT_EQ((O_RDWR | O_NONBLOCK), SysCalls::passedFileDescriptorFlagsToSet);
506+
507+
EXPECT_FALSE(ioctlHelper.checkIfIoctlReinvokeRequired(EAGAIN, DrmIoctl::GemExecbuffer2));
508+
EXPECT_TRUE(ioctlHelper.checkIfIoctlReinvokeRequired(EAGAIN, DrmIoctl::GemVmBind));
509+
EXPECT_TRUE(ioctlHelper.checkIfIoctlReinvokeRequired(EBUSY, DrmIoctl::GemExecbuffer2));
510+
}

0 commit comments

Comments
 (0)