mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
Redesign ULT by mocking sysfs and implementing for scheduler
- Redesign the ULT to implement OSSpecific ULT by mocking only sysfs - Fixing the Engine type "RCS" to use by default Change-Id: I551374ab02da03fe2e4168fd6a30aa8ccaf3dd3e Signed-off-by: Jitendra Sharma <jitendra.sharma@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
77e4ac0a18
commit
fe719f2665
@@ -81,13 +81,13 @@ class SysfsAccess : private FsAccess {
|
||||
|
||||
MOCKABLE_VIRTUAL ze_result_t read(const std::string file, std::string &val);
|
||||
ze_result_t read(const std::string file, int &val);
|
||||
ze_result_t read(const std::string file, uint64_t &val);
|
||||
MOCKABLE_VIRTUAL ze_result_t read(const std::string file, uint64_t &val);
|
||||
ze_result_t read(const std::string file, double &val);
|
||||
ze_result_t read(const std::string file, std::vector<std::string> &val);
|
||||
|
||||
ze_result_t write(const std::string file, const std::string val);
|
||||
ze_result_t write(const std::string file, const int val);
|
||||
ze_result_t write(const std::string file, const uint64_t val);
|
||||
MOCKABLE_VIRTUAL ze_result_t write(const std::string file, const uint64_t val);
|
||||
ze_result_t write(const std::string file, const double val);
|
||||
|
||||
ze_result_t readSymLink(const std::string path, std::string &buf);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
set(L0_SRCS_TOOLS_SYSMAN_SCHEDULER_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_scheduler_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_scheduler_imp.h
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
@@ -17,4 +18,4 @@ target_sources(${L0_STATIC_LIB_NAME}
|
||||
endif()
|
||||
|
||||
# Make our source files visible to parent
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_SCHEDULER_LINUX ${L0_SRCS_TOOLS_SYSMAN_SCHEDULER_LINUX})
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_SCHEDULER_LINUX ${L0_SRCS_TOOLS_SYSMAN_SCHEDULER_LINUX})
|
||||
|
||||
@@ -5,36 +5,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sysman/linux/os_sysman_imp.h"
|
||||
#include "sysman/scheduler/scheduler_imp.h"
|
||||
#include "level_zero/tools/source/sysman/scheduler/linux/os_scheduler_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
// Following below mappings of scheduler properties with sysfs nodes
|
||||
// zet_sched_timeslice_properties_t.interval = timeslice_duration_ms
|
||||
// zet_sched_timeslice_properties_t.yieldTimeout = preempt_timeout_ms
|
||||
// zet_sched_timeout_properties_t. watchdogTimeout = heartbeat_interval_ms
|
||||
class LinuxSchedulerImp : public NEO::NonCopyableClass, public OsScheduler {
|
||||
public:
|
||||
ze_result_t getPreemptTimeout(uint64_t &timeout) override;
|
||||
ze_result_t getTimesliceDuration(uint64_t ×lice) override;
|
||||
ze_result_t getHeartbeatInterval(uint64_t &heartbeat) override;
|
||||
ze_result_t setPreemptTimeout(uint64_t timeout) override;
|
||||
ze_result_t setTimesliceDuration(uint64_t timeslice) override;
|
||||
ze_result_t setHeartbeatInterval(uint64_t heartbeat) override;
|
||||
LinuxSchedulerImp(OsSysman *pOsSysman);
|
||||
~LinuxSchedulerImp() override = default;
|
||||
|
||||
private:
|
||||
SysfsAccess *pSysfsAccess;
|
||||
static const std::string preemptTimeoutMilliSecs;
|
||||
static const std::string timesliceDurationMilliSecs;
|
||||
static const std::string heartbeatIntervalMilliSecs;
|
||||
};
|
||||
|
||||
const std::string LinuxSchedulerImp::preemptTimeoutMilliSecs("vcs0/preempt_timeout_ms");
|
||||
const std::string LinuxSchedulerImp::timesliceDurationMilliSecs("vcs0/timeslice_duration_ms");
|
||||
const std::string LinuxSchedulerImp::heartbeatIntervalMilliSecs("vcs0/heartbeat_interval_ms");
|
||||
const std::string LinuxSchedulerImp::preemptTimeoutMilliSecs("engine/rcs0/preempt_timeout_ms");
|
||||
const std::string LinuxSchedulerImp::timesliceDurationMilliSecs("engine/rcs0/timeslice_duration_ms");
|
||||
const std::string LinuxSchedulerImp::heartbeatIntervalMilliSecs("engine/rcs0/heartbeat_interval_ms");
|
||||
constexpr uint16_t milliSecsToMicroSecs = 1000;
|
||||
|
||||
ze_result_t LinuxSchedulerImp::getPreemptTimeout(uint64_t &timeout) {
|
||||
@@ -86,4 +63,4 @@ OsScheduler *OsScheduler::create(OsSysman *pOsSysman) {
|
||||
return static_cast<OsScheduler *>(pLinuxSchedulerImp);
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
} // namespace L0
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "sysman/linux/os_sysman_imp.h"
|
||||
#include "sysman/scheduler/scheduler_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
// Following below mappings of scheduler properties with sysfs nodes
|
||||
// zet_sched_timeslice_properties_t.interval = timeslice_duration_ms
|
||||
// zet_sched_timeslice_properties_t.yieldTimeout = preempt_timeout_ms
|
||||
// zet_sched_timeout_properties_t. watchdogTimeout = heartbeat_interval_ms
|
||||
class LinuxSchedulerImp : public NEO::NonCopyableClass, public OsScheduler {
|
||||
public:
|
||||
ze_result_t getPreemptTimeout(uint64_t &timeout) override;
|
||||
ze_result_t getTimesliceDuration(uint64_t ×lice) override;
|
||||
ze_result_t getHeartbeatInterval(uint64_t &heartbeat) override;
|
||||
ze_result_t setPreemptTimeout(uint64_t timeout) override;
|
||||
ze_result_t setTimesliceDuration(uint64_t timeslice) override;
|
||||
ze_result_t setHeartbeatInterval(uint64_t heartbeat) override;
|
||||
LinuxSchedulerImp() = default;
|
||||
LinuxSchedulerImp(OsSysman *pOsSysman);
|
||||
~LinuxSchedulerImp() override = default;
|
||||
SysfsAccess *pSysfsAccess = nullptr;
|
||||
|
||||
private:
|
||||
static const std::string preemptTimeoutMilliSecs;
|
||||
static const std::string timesliceDurationMilliSecs;
|
||||
static const std::string heartbeatIntervalMilliSecs;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
@@ -11,6 +11,9 @@
|
||||
|
||||
namespace L0 {
|
||||
|
||||
constexpr uint64_t minTimeoutModeHeartbeat = 5000u;
|
||||
constexpr uint64_t minTimeoutInMicroSeconds = 1000u;
|
||||
|
||||
ze_result_t SchedulerImp::getCurrentMode(zet_sched_mode_t *pMode) {
|
||||
uint64_t timeout = 0;
|
||||
uint64_t timeslice = 0;
|
||||
@@ -78,7 +81,7 @@ ze_result_t SchedulerImp::setTimeoutMode(zet_sched_timeout_properties_t *pProper
|
||||
return result;
|
||||
}
|
||||
|
||||
if (pProperties->watchdogTimeout < 5000) {
|
||||
if (pProperties->watchdogTimeout < minTimeoutModeHeartbeat) {
|
||||
// watchdogTimeout(in usec) less than 5000 would be computed to
|
||||
// 0 milli seconds preempt timeout, and then after returning from
|
||||
// this method, we would end up in EXCLUSIVE mode
|
||||
@@ -105,7 +108,9 @@ ze_result_t SchedulerImp::setTimeoutMode(zet_sched_timeout_properties_t *pProper
|
||||
}
|
||||
|
||||
ze_result_t SchedulerImp::setTimesliceMode(zet_sched_timeslice_properties_t *pProperties, ze_bool_t *pNeedReboot) {
|
||||
if (pProperties->interval < 1) {
|
||||
if (pProperties->interval < minTimeoutInMicroSeconds) {
|
||||
// interval(in usec) less than 1000 would be computed to
|
||||
// 0 milli seconds interval.
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
*pNeedReboot = false;
|
||||
@@ -172,7 +177,8 @@ ze_result_t SchedulerImp::init() {
|
||||
SchedulerImp::~SchedulerImp() {
|
||||
if (nullptr != pOsScheduler) {
|
||||
delete pOsScheduler;
|
||||
pOsScheduler = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
} // namespace L0
|
||||
|
||||
@@ -6,6 +6,5 @@
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_scheduler.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_scheduler.h
|
||||
)
|
||||
add_subdirectories()
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(UNIX)
|
||||
target_sources(${TARGET_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_scheduler.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_sysfs_scheduler.h
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "level_zero/core/test/unit_tests/mock.h"
|
||||
|
||||
#include "sysman/linux/fs_access.h"
|
||||
#include "sysman/sysman.h"
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
|
||||
#endif
|
||||
|
||||
using ::testing::_;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
const std::string preemptTimeoutMilliSecs("engine/rcs0/preempt_timeout_ms");
|
||||
const std::string timesliceDurationMilliSecs("engine/rcs0/timeslice_duration_ms");
|
||||
const std::string heartbeatIntervalMilliSecs("engine/rcs0/heartbeat_interval_ms");
|
||||
|
||||
class SchedulerSysfsAccess : public SysfsAccess {};
|
||||
|
||||
template <>
|
||||
struct Mock<SchedulerSysfsAccess> : public SysfsAccess {
|
||||
uint64_t mockValPreemptTimeoutMilliSecs = 0;
|
||||
uint64_t mockValTimesliceDurationMilliSecs = 0;
|
||||
uint64_t mockValHeartbeatIntervalMilliSecs = 0;
|
||||
|
||||
ze_result_t getVal(const std::string file, uint64_t &val) {
|
||||
if (file.compare(preemptTimeoutMilliSecs) == 0) {
|
||||
val = mockValPreemptTimeoutMilliSecs;
|
||||
}
|
||||
if (file.compare(timesliceDurationMilliSecs) == 0) {
|
||||
val = mockValTimesliceDurationMilliSecs;
|
||||
}
|
||||
if (file.compare(heartbeatIntervalMilliSecs) == 0) {
|
||||
val = mockValHeartbeatIntervalMilliSecs;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
ze_result_t setVal(const std::string file, const uint64_t val) {
|
||||
if (file.compare(preemptTimeoutMilliSecs) == 0) {
|
||||
mockValPreemptTimeoutMilliSecs = val;
|
||||
}
|
||||
if (file.compare(timesliceDurationMilliSecs) == 0) {
|
||||
mockValTimesliceDurationMilliSecs = val;
|
||||
}
|
||||
if (file.compare(heartbeatIntervalMilliSecs) == 0) {
|
||||
mockValHeartbeatIntervalMilliSecs = val;
|
||||
}
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
Mock<SchedulerSysfsAccess>() = default;
|
||||
|
||||
MOCK_METHOD2(read, ze_result_t(const std::string file, uint64_t &val));
|
||||
MOCK_METHOD2(write, ze_result_t(const std::string file, const uint64_t val));
|
||||
};
|
||||
|
||||
class PublicLinuxSchedulerImp : public L0::LinuxSchedulerImp {
|
||||
public:
|
||||
using LinuxSchedulerImp::pSysfsAccess;
|
||||
};
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h"
|
||||
#include "level_zero/tools/source/sysman/scheduler/linux/os_scheduler_imp.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "mock_sysfs_scheduler.h"
|
||||
#include "sysman/scheduler/os_scheduler.h"
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::DoAll;
|
||||
using ::testing::InSequence;
|
||||
using ::testing::Invoke;
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::Return;
|
||||
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
constexpr uint64_t convertMilliToMicro = 1000u;
|
||||
constexpr uint64_t defaultTimeoutMilliSecs = 640u;
|
||||
constexpr uint64_t defaultTimesliceMilliSecs = 1u;
|
||||
constexpr uint64_t defaultHeartbeatMilliSecs = 2500u;
|
||||
constexpr uint64_t expectedHeartbeatTimeoutMicroSecs = defaultHeartbeatMilliSecs * convertMilliToMicro;
|
||||
constexpr uint64_t expectedTimeoutMicroSecs = defaultTimeoutMilliSecs * convertMilliToMicro;
|
||||
constexpr uint64_t expectedTimesliceMicroSecs = defaultTimesliceMilliSecs * convertMilliToMicro;
|
||||
|
||||
class SysmanSchedulerFixture : public DeviceFixture, public ::testing::Test {
|
||||
protected:
|
||||
SysmanImp *sysmanImp = nullptr;
|
||||
zet_sysman_handle_t hSysman;
|
||||
|
||||
OsScheduler *pOsScheduler = nullptr;
|
||||
Mock<SchedulerSysfsAccess> *pSysfsAccess = nullptr;
|
||||
L0::Scheduler *pSchedPrev = nullptr;
|
||||
L0::SchedulerImp schedImp;
|
||||
PublicLinuxSchedulerImp linuxSchedulerImp;
|
||||
|
||||
void SetUp() override {
|
||||
DeviceFixture::SetUp();
|
||||
sysmanImp = new SysmanImp(device->toHandle());
|
||||
pSysfsAccess = new NiceMock<Mock<SchedulerSysfsAccess>>;
|
||||
linuxSchedulerImp.pSysfsAccess = pSysfsAccess;
|
||||
pOsScheduler = static_cast<OsScheduler *>(&linuxSchedulerImp);
|
||||
pSysfsAccess->setVal(preemptTimeoutMilliSecs, defaultTimeoutMilliSecs);
|
||||
pSysfsAccess->setVal(timesliceDurationMilliSecs, defaultTimesliceMilliSecs);
|
||||
pSysfsAccess->setVal(heartbeatIntervalMilliSecs, defaultHeartbeatMilliSecs);
|
||||
|
||||
ON_CALL(*pSysfsAccess, read(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<SchedulerSysfsAccess>::getVal));
|
||||
ON_CALL(*pSysfsAccess, write(_, _))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess, &Mock<SchedulerSysfsAccess>::setVal));
|
||||
|
||||
pSchedPrev = sysmanImp->pSched;
|
||||
sysmanImp->pSched = static_cast<Scheduler *>(&schedImp);
|
||||
schedImp.pOsScheduler = pOsScheduler;
|
||||
schedImp.init();
|
||||
hSysman = sysmanImp->toHandle();
|
||||
}
|
||||
void TearDown() override {
|
||||
// restore state
|
||||
sysmanImp->pSched = pSchedPrev;
|
||||
schedImp.pOsScheduler = nullptr;
|
||||
|
||||
// cleanup
|
||||
if (pSysfsAccess != nullptr) {
|
||||
delete pSysfsAccess;
|
||||
pSysfsAccess = nullptr;
|
||||
}
|
||||
if (sysmanImp != nullptr) {
|
||||
delete sysmanImp;
|
||||
sysmanImp = nullptr;
|
||||
}
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
zet_sched_mode_t fixtureGetCurrentMode(zet_sysman_handle_t hSysman) {
|
||||
zet_sched_mode_t mode;
|
||||
ze_result_t result = zetSysmanSchedulerGetCurrentMode(hSysman, &mode);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
return mode;
|
||||
}
|
||||
|
||||
zet_sched_timeout_properties_t fixtureGetTimeoutModeProperties(zet_sysman_handle_t hSysman) {
|
||||
zet_sched_timeout_properties_t config;
|
||||
ze_result_t result = zetSysmanSchedulerGetTimeoutModeProperties(hSysman, false, &config);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
return config;
|
||||
}
|
||||
|
||||
zet_sched_timeslice_properties_t fixtureGetTimesliceModeProperties(zet_sysman_handle_t hSysman) {
|
||||
zet_sched_timeslice_properties_t config;
|
||||
ze_result_t result = zetSysmanSchedulerGetTimesliceModeProperties(hSysman, false, &config);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
return config;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(SysmanSchedulerFixture, GivenValidSysmanHandleWhenCallingzetSysmanSchedulerGetCurrentModeThenVerifyzetSysmanSchedulerGetCurrentModeCallSucceeds) {
|
||||
auto mode = fixtureGetCurrentMode(hSysman);
|
||||
EXPECT_EQ(mode, ZET_SCHED_MODE_TIMESLICE);
|
||||
}
|
||||
|
||||
TEST_F(SysmanSchedulerFixture, GivenValidSysmanHandleWhenCallingzetSysmanSchedulerGetTimeoutModePropertiesThenVerifyzetSysmanSchedulerGetTimeoutModePropertiesCallSucceeds) {
|
||||
auto config = fixtureGetTimeoutModeProperties(hSysman);
|
||||
EXPECT_EQ(config.watchdogTimeout, expectedHeartbeatTimeoutMicroSecs);
|
||||
}
|
||||
|
||||
TEST_F(SysmanSchedulerFixture, GivenValidSysmanHandleWhenCallingzetSysmanSchedulerGetTimesliceModePropertiesThenVerifyzetSysmanSchedulerGetTimesliceModePropertiesCallSucceeds) {
|
||||
auto config = fixtureGetTimesliceModeProperties(hSysman);
|
||||
EXPECT_EQ(config.interval, expectedTimesliceMicroSecs);
|
||||
EXPECT_EQ(config.yieldTimeout, expectedTimeoutMicroSecs);
|
||||
}
|
||||
|
||||
TEST_F(SysmanSchedulerFixture, GivenValidSysmanHandleWhenCallingzetSysmanSchedulerSetTimeoutModeThenVerifyzetSysmanSchedulerSetTimeoutModeCallSucceeds) {
|
||||
ze_bool_t needReboot;
|
||||
zet_sched_timeout_properties_t setConfig;
|
||||
setConfig.watchdogTimeout = 10000u;
|
||||
ze_result_t result = zetSysmanSchedulerSetTimeoutMode(hSysman, &setConfig, &needReboot);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_FALSE(needReboot);
|
||||
auto getConfig = fixtureGetTimeoutModeProperties(hSysman);
|
||||
EXPECT_EQ(getConfig.watchdogTimeout, setConfig.watchdogTimeout);
|
||||
auto mode = fixtureGetCurrentMode(hSysman);
|
||||
EXPECT_EQ(mode, ZET_SCHED_MODE_TIMEOUT);
|
||||
}
|
||||
|
||||
TEST_F(SysmanSchedulerFixture, GivenValidSysmanHandleWhenCallingzetSysmanSchedulerSetTimesliceModeThenVerifyzetSysmanSchedulerSetTimesliceModeCallSucceeds) {
|
||||
ze_bool_t needReboot;
|
||||
zet_sched_timeslice_properties_t setConfig;
|
||||
setConfig.interval = 1000u;
|
||||
setConfig.yieldTimeout = 1000u;
|
||||
ze_result_t result = zetSysmanSchedulerSetTimesliceMode(hSysman, &setConfig, &needReboot);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_FALSE(needReboot);
|
||||
auto getConfig = fixtureGetTimesliceModeProperties(hSysman);
|
||||
EXPECT_EQ(getConfig.interval, setConfig.interval);
|
||||
EXPECT_EQ(getConfig.yieldTimeout, setConfig.yieldTimeout);
|
||||
auto mode = fixtureGetCurrentMode(hSysman);
|
||||
EXPECT_EQ(mode, ZET_SCHED_MODE_TIMESLICE);
|
||||
}
|
||||
|
||||
TEST_F(SysmanSchedulerFixture, GivenValidSysmanHandleWhenCallingzetSysmanSchedulerSetExclusiveModeThenVerifyzetSysmanSchedulerSetExclusiveModeCallSucceeds) {
|
||||
ze_bool_t needReboot;
|
||||
ze_result_t result = zetSysmanSchedulerSetExclusiveMode(hSysman, &needReboot);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_FALSE(needReboot);
|
||||
auto mode = fixtureGetCurrentMode(hSysman);
|
||||
EXPECT_EQ(mode, ZET_SCHED_MODE_EXCLUSIVE);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
@@ -0,0 +1,14 @@
|
||||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${TARGET_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test_sysman_scheduler.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_scheduler.h
|
||||
)
|
||||
endif()
|
||||
@@ -21,6 +21,10 @@ using ::testing::Return;
|
||||
namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
constexpr uint64_t defaultTimeoutMilliSecs = 640u;
|
||||
constexpr uint64_t defaultTimesliceMilliSecs = 1000u;
|
||||
constexpr uint64_t defaultHeartbeatMilliSecs = 2500u;
|
||||
|
||||
class SysmanSchedulerFixture : public DeviceFixture, public ::testing::Test {
|
||||
protected:
|
||||
SysmanImp *sysmanImp;
|
||||
@@ -34,9 +38,9 @@ class SysmanSchedulerFixture : public DeviceFixture, public ::testing::Test {
|
||||
DeviceFixture::SetUp();
|
||||
sysmanImp = new SysmanImp(device->toHandle());
|
||||
pOsScheduler = new NiceMock<Mock<OsScheduler>>;
|
||||
pOsScheduler->setMockTimeout(640);
|
||||
pOsScheduler->setMockTimeslice(1);
|
||||
pOsScheduler->setMockHeartbeat(2500);
|
||||
pOsScheduler->setMockTimeout(defaultTimeoutMilliSecs);
|
||||
pOsScheduler->setMockTimeslice(defaultTimesliceMilliSecs);
|
||||
pOsScheduler->setMockHeartbeat(defaultHeartbeatMilliSecs);
|
||||
|
||||
ON_CALL(*pOsScheduler, getPreemptTimeout(_))
|
||||
.WillByDefault(Invoke(pOsScheduler, &Mock<OsScheduler>::getMockTimeout));
|
||||
@@ -102,24 +106,24 @@ TEST_F(SysmanSchedulerFixture, GivenValidSysmanHandleWhenCallingzetSysmanSchedul
|
||||
|
||||
TEST_F(SysmanSchedulerFixture, GivenValidSysmanHandleWhenCallingzetSysmanSchedulerGetTimeoutModePropertiesThenVerifyzetSysmanSchedulerGetTimeoutModePropertiesCallSucceeds) {
|
||||
auto config = fixtureGetTimeoutModeProperties(hSysman);
|
||||
EXPECT_EQ(config.watchdogTimeout, 2500ul);
|
||||
EXPECT_EQ(config.watchdogTimeout, defaultHeartbeatMilliSecs);
|
||||
}
|
||||
|
||||
TEST_F(SysmanSchedulerFixture, GivenValidSysmanHandleWhenCallingzetSysmanSchedulerGetTimesliceModePropertiesThenVerifyzetSysmanSchedulerGetTimesliceModePropertiesCallSucceeds) {
|
||||
auto config = fixtureGetTimesliceModeProperties(hSysman);
|
||||
EXPECT_EQ(config.interval, 1ul);
|
||||
EXPECT_EQ(config.yieldTimeout, 640ul);
|
||||
EXPECT_EQ(config.interval, defaultTimesliceMilliSecs);
|
||||
EXPECT_EQ(config.yieldTimeout, defaultTimeoutMilliSecs);
|
||||
}
|
||||
|
||||
TEST_F(SysmanSchedulerFixture, GivenValidSysmanHandleWhenCallingzetSysmanSchedulerSetTimeoutModeThenVerifyzetSysmanSchedulerSetTimeoutModeCallSucceeds) {
|
||||
ze_bool_t needReboot;
|
||||
zet_sched_timeout_properties_t setConfig;
|
||||
setConfig.watchdogTimeout = 5000;
|
||||
setConfig.watchdogTimeout = 5000u;
|
||||
ze_result_t result = zetSysmanSchedulerSetTimeoutMode(hSysman, &setConfig, &needReboot);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_FALSE(needReboot);
|
||||
auto getConfig = fixtureGetTimeoutModeProperties(hSysman);
|
||||
EXPECT_EQ(getConfig.watchdogTimeout, 5000ul);
|
||||
EXPECT_EQ(getConfig.watchdogTimeout, setConfig.watchdogTimeout);
|
||||
auto mode = fixtureGetCurrentMode(hSysman);
|
||||
EXPECT_EQ(mode, ZET_SCHED_MODE_TIMEOUT);
|
||||
}
|
||||
@@ -127,14 +131,14 @@ TEST_F(SysmanSchedulerFixture, GivenValidSysmanHandleWhenCallingzetSysmanSchedul
|
||||
TEST_F(SysmanSchedulerFixture, GivenValidSysmanHandleWhenCallingzetSysmanSchedulerSetTimesliceModeThenVerifyzetSysmanSchedulerSetTimesliceModeCallSucceeds) {
|
||||
ze_bool_t needReboot;
|
||||
zet_sched_timeslice_properties_t setConfig;
|
||||
setConfig.interval = 2;
|
||||
setConfig.yieldTimeout = 1000;
|
||||
setConfig.interval = 2000u;
|
||||
setConfig.yieldTimeout = 1000u;
|
||||
ze_result_t result = zetSysmanSchedulerSetTimesliceMode(hSysman, &setConfig, &needReboot);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_FALSE(needReboot);
|
||||
auto getConfig = fixtureGetTimesliceModeProperties(hSysman);
|
||||
EXPECT_EQ(getConfig.interval, 2ul);
|
||||
EXPECT_EQ(getConfig.yieldTimeout, 1000ul);
|
||||
EXPECT_EQ(getConfig.interval, setConfig.interval);
|
||||
EXPECT_EQ(getConfig.yieldTimeout, setConfig.yieldTimeout);
|
||||
auto mode = fixtureGetCurrentMode(hSysman);
|
||||
EXPECT_EQ(mode, ZET_SCHED_MODE_TIMESLICE);
|
||||
}
|
||||
Reference in New Issue
Block a user