Implement scheduler APIs

Add logic to implement following scheduler APIs
-zetSysmanSchedulerGetCurrentMode
-zetSysmanSchedulerGetTimeoutModeProperties
-zetSysmanSchedulerGetTimesliceModeProperties
-zetSysmanSchedulerSetTimeoutMode
-zetSysmanSchedulerSetTimesliceMode
-zetSysmanSchedulerSetExclusiveMode

Change-Id: I134b200ffd6b13bc50b1f38e955dd584455b4b38
Signed-off-by: Jitendra Sharma <jitendra.sharma@intel.com>
This commit is contained in:
Jitendra Sharma
2020-04-15 13:16:36 +05:30
parent 49f2a5157a
commit 5374a0ffc1
12 changed files with 312 additions and 41 deletions

View File

@@ -17,4 +17,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})

View File

@@ -9,22 +9,75 @@
#include "sysman/scheduler/scheduler_imp.h"
namespace L0 {
class LinuxSchedulerImp : public OsScheduler {
// 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 &timeslice) 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;
// Don't allow copies of the LinuxSchedulerImp object
LinuxSchedulerImp(const LinuxSchedulerImp &obj) = delete;
LinuxSchedulerImp &operator=(const LinuxSchedulerImp &obj) = delete;
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");
constexpr uint16_t milliSecsToMicroSecs = 1000;
ze_result_t LinuxSchedulerImp::getPreemptTimeout(uint64_t &timeout) {
ze_result_t result = pSysfsAccess->read(preemptTimeoutMilliSecs, timeout);
if (result == ZE_RESULT_SUCCESS) {
timeout = timeout * milliSecsToMicroSecs;
}
return result;
}
ze_result_t LinuxSchedulerImp::getTimesliceDuration(uint64_t &timeslice) {
ze_result_t result = pSysfsAccess->read(timesliceDurationMilliSecs, timeslice);
if (result == ZE_RESULT_SUCCESS) {
timeslice = timeslice * milliSecsToMicroSecs;
}
return result;
}
ze_result_t LinuxSchedulerImp::getHeartbeatInterval(uint64_t &heartbeat) {
ze_result_t result = pSysfsAccess->read(heartbeatIntervalMilliSecs, heartbeat);
if (result == ZE_RESULT_SUCCESS) {
heartbeat = heartbeat * milliSecsToMicroSecs;
}
return result;
}
ze_result_t LinuxSchedulerImp::setPreemptTimeout(uint64_t timeout) {
timeout = timeout / milliSecsToMicroSecs;
return pSysfsAccess->write(preemptTimeoutMilliSecs, timeout);
}
ze_result_t LinuxSchedulerImp::setTimesliceDuration(uint64_t timeslice) {
timeslice = timeslice / milliSecsToMicroSecs;
return pSysfsAccess->write(timesliceDurationMilliSecs, timeslice);
}
ze_result_t LinuxSchedulerImp::setHeartbeatInterval(uint64_t heartbeat) {
heartbeat = heartbeat / milliSecsToMicroSecs;
return pSysfsAccess->write(heartbeatIntervalMilliSecs, heartbeat);
}
LinuxSchedulerImp::LinuxSchedulerImp(OsSysman *pOsSysman) {
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
pSysfsAccess = &pLinuxSysmanImp->getSysfsAccess();
}