do not sleep in ULTs

Signed-off-by: Artur Harasimiuk <artur.harasimiuk@intel.com>
This commit is contained in:
Artur Harasimiuk
2022-10-21 10:50:55 +00:00
committed by Compute-Runtime-Automation
parent 3724807eed
commit 9ad3f6190f
15 changed files with 76 additions and 32 deletions

View File

@@ -8,6 +8,7 @@
#include "level_zero/experimental/source/tracing/tracing_imp.h"
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/helpers/sleep.h"
namespace L0 {
@@ -277,7 +278,7 @@ ze_result_t APITracerContextImp::finalizeDisableImpTracingWait(struct APITracerI
case disabledWaitingState:
while (testAndFreeRetiredTracers() != 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
NEO::sleep(std::chrono::milliseconds(1));
}
tracerImp->tracingState = disabledState;
result = ZE_RESULT_SUCCESS;

View File

@@ -10,6 +10,7 @@
#include "shared/source/built_ins/sip.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/helpers/sleep.h"
#include "shared/source/helpers/string.h"
#include "level_zero/core/source/device/device_imp.h"
@@ -1264,7 +1265,7 @@ ze_result_t DebugSessionImp::waitForCmdReady(EuThread::ThreadId threadId, uint16
if (sipCommand.command == static_cast<uint32_t>(NEO::SipKernel::COMMAND::READY)) {
break;
}
std::this_thread::sleep_for(std::chrono::microseconds(100));
NEO::sleep(std::chrono::microseconds(100));
}
if (sipCommand.command != static_cast<uint32_t>(NEO::SipKernel::COMMAND::READY)) {

View File

@@ -7,6 +7,7 @@
#include "level_zero/tools/source/sysman/diagnostics/linux/os_diagnostics_imp.h"
#include "shared/source/helpers/sleep.h"
#include "shared/source/helpers/string.h"
#include "level_zero/core/source/device/device_imp.h"
@@ -84,7 +85,7 @@ ze_result_t LinuxDiagnosticsImp::waitForQuiescentCompletion() {
result = pSysfsAccess->write(quiescentGpuFile, intVal);
if (ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE == result) {
count++;
this->pSleepFunctionSecs(1); // Sleep for 1second every loop, gives enough time for KMD to clear all allocations and wedge the system
NEO::sleep(std::chrono::seconds(1)); // Sleep for 1second every loop, gives enough time for KMD to clear all allocations and wedge the system
auto processResult = gpuProcessCleanup();
if (ZE_RESULT_SUCCESS != processResult) {
return processResult;

View File

@@ -25,7 +25,6 @@ class LinuxDiagnosticsImp : public OsDiagnostics, NEO::NonCopyableOrMovableClass
LinuxDiagnosticsImp(OsSysman *pOsSysman, const std::string &diagTests);
~LinuxDiagnosticsImp() override = default;
std::string osDiagType = "unknown";
decltype(&L0::SysmanUtils::sleep) pSleepFunctionSecs = L0::SysmanUtils::sleep;
protected:
LinuxSysmanImp *pLinuxSysmanImp = nullptr;

View File

@@ -7,6 +7,7 @@
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h"
#include "shared/source/helpers/sleep.h"
#include "shared/source/memory_manager/memory_manager.h"
#include "shared/source/os_interface/device_factory.h"
@@ -328,7 +329,7 @@ void LinuxSysmanImp::clearHPIE(int fd) {
this->preadFunction(fd, &value, 0x01, offset);
resetValue = value & (~PCI_EXP_SLTCTL_HPIE);
this->pwriteFunction(fd, &resetValue, 0x01, offset);
this->pSleepFunctionSecs(10); // Sleep for 10seconds just to make sure the change is propagated.
NEO::sleep(std::chrono::seconds(10)); // Sleep for 10seconds just to make sure the change is propagated.
}
// A 'warm reset' is a conventional reset that is triggered across a PCI express link.
@@ -353,9 +354,9 @@ ze_result_t LinuxSysmanImp::osWarmReset() {
return result;
}
if (diagnosticsReset) {
this->pSleepFunctionSecs(30); // Sleep for 30seconds to make sure that the config spaces of all devices are saved correctly after IFR
NEO::sleep(std::chrono::seconds(30)); // Sleep for 30seconds to make sure that the config spaces of all devices are saved correctly after IFR
} else {
this->pSleepFunctionSecs(10); // Sleep for 10seconds to make sure that the config spaces of all devices are saved correctly
NEO::sleep(std::chrono::seconds(10)); // Sleep for 10seconds to make sure that the config spaces of all devices are saved correctly
}
clearHPIE(fd);
@@ -367,18 +368,18 @@ ze_result_t LinuxSysmanImp::osWarmReset() {
this->preadFunction(fd, &value, 0x01, offset);
resetValue = value | PCI_BRIDGE_CTL_BUS_RESET;
this->pwriteFunction(fd, &resetValue, 0x01, offset);
this->pSleepFunctionSecs(10); // Sleep for 10seconds just to make sure the change is propagated.
NEO::sleep(std::chrono::seconds(10)); // Sleep for 10seconds just to make sure the change is propagated.
this->pwriteFunction(fd, &value, 0x01, offset);
this->pSleepFunctionSecs(10); // Sleep for 10seconds to make sure the change is propagated. before rescan is done.
NEO::sleep(std::chrono::seconds(10)); // Sleep for 10seconds to make sure the change is propagated. before rescan is done.
result = pFsAccess->write(rootPortPath + '/' + "rescan", "1");
if (ZE_RESULT_SUCCESS != result) {
return result;
}
if (diagnosticsReset) {
this->pSleepFunctionSecs(30); // Sleep for 30seconds to make sure that the config spaces of all devices are saved correctly after IFR
NEO::sleep(std::chrono::seconds(30)); // Sleep for 30seconds to make sure that the config spaces of all devices are saved correctly after IFR
} else {
this->pSleepFunctionSecs(10); // Sleep for 10seconds, allows the rescan to complete on all devices attached to the root port.
NEO::sleep(std::chrono::seconds(10)); // Sleep for 10seconds, allows the rescan to complete on all devices attached to the root port.
}
int ret = this->closeFunction(fd);
@@ -418,7 +419,7 @@ ze_result_t LinuxSysmanImp::osColdReset() {
if (ZE_RESULT_SUCCESS != result) {
return result;
}
std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Sleep for 100 milliseconds just to make sure, 1 ms is defined as part of spec
NEO::sleep(std::chrono::milliseconds(100)); // Sleep for 100 milliseconds just to make sure, 1 ms is defined as part of spec
result = pFsAccess->write((slotPath + slot + "/power"), "1"); // turn on power
if (ZE_RESULT_SUCCESS != result) {
return result;

View File

@@ -74,7 +74,6 @@ class LinuxSysmanImp : public OsSysman, NEO::NonCopyableOrMovableClass {
decltype(&NEO::SysCalls::close) closeFunction = NEO::SysCalls::close;
decltype(&NEO::SysCalls::pread) preadFunction = NEO::SysCalls::pread;
decltype(&NEO::SysCalls::pwrite) pwriteFunction = NEO::SysCalls::pwrite;
decltype(&L0::SysmanUtils::sleep) pSleepFunctionSecs = L0::SysmanUtils::sleep;
std::string devicePciBdf = "";
uint32_t rootDeviceIndex = 0u;
NEO::ExecutionEnvironment *executionEnvironment = nullptr;

View File

@@ -7,6 +7,8 @@
#include "level_zero/tools/source/sysman/sysman.h"
#include "shared/source/helpers/sleep.h"
#include "level_zero/core/source/device/device_imp.h"
#include "level_zero/core/source/driver/driver.h"
#include "level_zero/core/source/driver/driver_handle_imp.h"
@@ -68,7 +70,7 @@ ze_result_t DriverHandleImp::sysmanEventsListen(
if (gotSysmanEvent) {
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(10)); // Sleep for 10 milliseconds before next check of events
NEO::sleep(std::chrono::milliseconds(10)); // Sleep for 10 milliseconds before next check of events
} while ((L0::steadyClock::now() <= timeToExitLoop));
return ZE_RESULT_SUCCESS;
@@ -94,7 +96,7 @@ ze_result_t DriverHandleImp::sysmanEventsListenEx(
if (gotSysmanEvent) {
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(10)); // Sleep for 10 milliseconds before next check of events
NEO::sleep(std::chrono::milliseconds(10)); // Sleep for 10 milliseconds before next check of events
} while ((L0::steadyClock::now() <= timeToExitLoop));
return ZE_RESULT_SUCCESS;

View File

@@ -7,6 +7,8 @@
#include "level_zero/tools/source/sysman/sysman_imp.h"
#include "shared/source/helpers/sleep.h"
#include "level_zero/core/source/driver/driver.h"
#include "level_zero/core/source/driver/driver_handle_imp.h"
#include "level_zero/tools/source/sysman/ecc/ecc_imp.h"
@@ -213,9 +215,4 @@ ze_result_t SysmanDeviceImp::deviceSetEccState(const zes_device_ecc_desc_t *newS
return pEcc->setEccState(newState, pState);
}
namespace SysmanUtils {
void sleep(int64_t seconds) {
std::this_thread::sleep_for(std::chrono::seconds(seconds));
}
} // namespace SysmanUtils
} // namespace L0

View File

@@ -87,7 +87,4 @@ struct SysmanDeviceImp : SysmanDevice, NEO::NonCopyableOrMovableClass {
}
}
};
namespace SysmanUtils {
void sleep(int64_t seconds);
}
} // namespace L0

View File

@@ -504,8 +504,6 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenQuiescentFailsConti
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp->pDevice = pLinuxSysmanImp->getDeviceHandle();
pPublicLinuxDiagnosticsImp->pSleepFunctionSecs = mockSleepFunctionSecs;
pMockSysfsAccess->setErrorAfterCount(12, ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE);
EXPECT_EQ(ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE, pPublicLinuxDiagnosticsImp->waitForQuiescentCompletion());
}
@@ -532,7 +530,6 @@ TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetThen
pLinuxSysmanImp->closeFunction = closeMockDiag;
pLinuxSysmanImp->preadFunction = preadMockDiag;
pLinuxSysmanImp->pwriteFunction = pwriteMockDiag;
pLinuxSysmanImp->pSleepFunctionSecs = mockSleepFunctionSecs;
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxSysmanImp->osWarmReset());
}
@@ -543,7 +540,6 @@ TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetfrom
pLinuxSysmanImp->closeFunction = closeMockDiag;
pLinuxSysmanImp->preadFunction = preadMockDiag;
pLinuxSysmanImp->pwriteFunction = pwriteMockDiag;
pLinuxSysmanImp->pSleepFunctionSecs = mockSleepFunctionSecs;
pLinuxSysmanImp->diagnosticsReset = true;
EXPECT_EQ(ZE_RESULT_SUCCESS, pLinuxSysmanImp->osWarmReset());
@@ -555,7 +551,6 @@ TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetAndR
pLinuxSysmanImp->closeFunction = closeMockDiag;
pLinuxSysmanImp->preadFunction = preadMockDiag;
pLinuxSysmanImp->pwriteFunction = pwriteMockDiag;
pLinuxSysmanImp->pSleepFunctionSecs = mockSleepFunctionSecs;
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, pLinuxSysmanImp->osWarmReset());
}
@@ -566,7 +561,6 @@ TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetAndR
pLinuxSysmanImp->closeFunction = closeMockDiagFail;
pLinuxSysmanImp->preadFunction = preadMockDiag;
pLinuxSysmanImp->pwriteFunction = pwriteMockDiag;
pLinuxSysmanImp->pSleepFunctionSecs = mockSleepFunctionSecs;
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, pLinuxSysmanImp->osWarmReset());
}
@@ -577,7 +571,6 @@ TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetAndC
pLinuxSysmanImp->closeFunction = closeMockDiag;
pLinuxSysmanImp->preadFunction = preadMockDiag;
pLinuxSysmanImp->pwriteFunction = pwriteMockDiag;
pLinuxSysmanImp->pSleepFunctionSecs = mockSleepFunctionSecs;
pMockFsAccess->mockWriteError = ZE_RESULT_ERROR_NOT_AVAILABLE;
EXPECT_EQ(ZE_RESULT_ERROR_NOT_AVAILABLE, pLinuxSysmanImp->osWarmReset());
@@ -589,7 +582,6 @@ TEST_F(ZesDiagnosticsFixture, GivenValidSysmanImpPointerWhenCallingWarmResetAndR
pLinuxSysmanImp->closeFunction = closeMockDiag;
pLinuxSysmanImp->preadFunction = preadMockDiag;
pLinuxSysmanImp->pwriteFunction = pwriteMockDiag;
pLinuxSysmanImp->pSleepFunctionSecs = mockSleepFunctionSecs;
pMockFsAccess->checkErrorAfterCount = 1;
pMockFsAccess->mockWriteError = ZE_RESULT_ERROR_NOT_AVAILABLE;

View File

@@ -118,6 +118,8 @@ set(NEO_CORE_HELPERS
${CMAKE_CURRENT_SOURCE_DIR}/register_offsets.h
${CMAKE_CURRENT_SOURCE_DIR}/registered_method_dispatcher.h
${CMAKE_CURRENT_SOURCE_DIR}/simd_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/sleep.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sleep.h
${CMAKE_CURRENT_SOURCE_DIR}/state_base_address.h
${CMAKE_CURRENT_SOURCE_DIR}/state_base_address_base.inl
${CMAKE_CURRENT_SOURCE_DIR}/state_base_address_bdw.inl

View File

@@ -0,0 +1,19 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include <thread>
namespace NEO {
template <class T>
void sleep(const T &sleepDuration) {
std::this_thread::sleep_for(sleepDuration);
}
template void sleep<std::chrono::microseconds>(const std::chrono::microseconds &);
template void sleep<std::chrono::milliseconds>(const std::chrono::milliseconds &);
template void sleep<std::chrono::seconds>(const std::chrono::seconds &);
} // namespace NEO

View File

@@ -0,0 +1,13 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include <thread>
namespace NEO {
template <class T>
void sleep(const T &sleepDuration);
} // namespace NEO

View File

@@ -108,10 +108,11 @@ set(neo_libult_common_SRCS_LIB_ULT
${NEO_SHARED_TEST_DIRECTORY}/common/libult/global_environment.h
${NEO_SHARED_TEST_DIRECTORY}/common/libult/io_functions.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/libult/options_unit_tests.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/libult/signal_utils.h
${NEO_SHARED_TEST_DIRECTORY}/common/libult/sleep.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/libult/source_level_debugger_library.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/libult/source_level_debugger_library.h
${NEO_SHARED_TEST_DIRECTORY}/common/libult/source_level_debugger_ult.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/libult/signal_utils.h
${NEO_SHARED_TEST_DIRECTORY}/common/libult/ult_aub_command_stream_receiver.h
${NEO_SHARED_TEST_DIRECTORY}/common/libult/ult_command_stream_receiver.h
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_memory_manager.cpp

View File

@@ -0,0 +1,19 @@
/*
* Copyright (C) 2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include <thread>
namespace NEO {
template <class T>
void sleep(const T &sleepDuration) {
// Do not sleep in ULTs
}
template void sleep<std::chrono::microseconds>(const std::chrono::microseconds &);
template void sleep<std::chrono::milliseconds>(const std::chrono::milliseconds &);
template void sleep<std::chrono::seconds>(const std::chrono::seconds &);
} // namespace NEO