| 1 |
/* |
| 2 |
* Copyright (C) 2020-2023 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#pragma once |
| 9 |
#include "shared/source/os_interface/linux/drm_neo.h" |
| 10 |
|
| 11 |
#include "level_zero/tools/source/sysman/linux/os_sysman_imp.h" |
| 12 |
#include "level_zero/tools/source/sysman/scheduler/scheduler_imp.h" |
| 13 |
|
| 14 |
#include <string> |
| 15 |
|
| 16 |
namespace L0 { |
| 17 |
class SysfsAccess; |
| 18 |
struct Device; |
| 19 |
|
| 20 |
// Following below mappings of scheduler properties with sysfs nodes |
| 21 |
// zes_sched_timeslice_properties_t.interval = timeslice_duration_ms |
| 22 |
// zes_sched_timeslice_properties_t.yieldTimeout = preempt_timeout_ms |
| 23 |
// zes_sched_timeout_properties_t. watchdogTimeout = heartbeat_interval_ms |
| 24 |
class LinuxSchedulerImp : public OsScheduler, NEO::NonCopyableOrMovableClass { |
| 25 |
public: |
| 26 |
ze_result_t setExclusiveMode(ze_bool_t *pNeedReload) override; |
| 27 |
ze_result_t getCurrentMode(zes_sched_mode_t *pMode) override; |
| 28 |
ze_result_t getTimeoutModeProperties(ze_bool_t getDefaults, zes_sched_timeout_properties_t *pConfig) override; |
| 29 |
ze_result_t getTimesliceModeProperties(ze_bool_t getDefaults, zes_sched_timeslice_properties_t *pConfig) override; |
| 30 |
ze_result_t setTimeoutMode(zes_sched_timeout_properties_t *pProperties, ze_bool_t *pNeedReload) override; |
| 31 |
ze_result_t setTimesliceMode(zes_sched_timeslice_properties_t *pProperties, ze_bool_t *pNeedReload) override; |
| 32 |
ze_result_t getProperties(zes_sched_properties_t &properties) override; |
| 33 |
ze_result_t setComputeUnitDebugMode(ze_bool_t *pNeedReload) override; |
| 34 |
LinuxSchedulerImp() = default; |
| 35 |
LinuxSchedulerImp(OsSysman *pOsSysman, zes_engine_type_flag_t type, |
| 36 |
std::vector<std::string> &listOfEngines, ze_bool_t isSubdevice, uint32_t subdeviceId); |
| 37 |
~LinuxSchedulerImp() override = default; |
| 38 |
static const std::string engineDir; |
| 39 |
|
| 40 |
protected: |
| 41 |
LinuxSysmanImp *pLinuxSysmanImp = nullptr; |
| 42 |
SysfsAccess *pSysfsAccess = nullptr; |
| 43 |
Device *pDevice = nullptr; |
| 44 |
zes_engine_type_flag_t engineType = ZES_ENGINE_TYPE_FLAG_OTHER; |
| 45 |
ze_bool_t onSubdevice = 0; |
| 46 |
uint32_t subdeviceId = 0; |
| 47 |
ze_result_t setExclusiveModeImp(); |
| 48 |
ze_result_t updateComputeUnitDebugNode(uint64_t val); |
| 49 |
ze_result_t getPreemptTimeout(uint64_t &timeout, ze_bool_t getDefault); |
| 50 |
ze_result_t getTimesliceDuration(uint64_t ×lice, ze_bool_t getDefault); |
| 51 |
ze_result_t getHeartbeatInterval(uint64_t &heartbeat, ze_bool_t getDefault); |
| 52 |
ze_result_t setPreemptTimeout(uint64_t timeout); |
| 53 |
ze_result_t setTimesliceDuration(uint64_t timeslice); |
| 54 |
ze_result_t setHeartbeatInterval(uint64_t heartbeat); |
| 55 |
ze_bool_t canControlScheduler(); |
| 56 |
ze_result_t disableComputeUnitDebugMode(ze_bool_t *pNeedReload); |
| 57 |
bool isComputeUnitDebugModeEnabled(); |
| 58 |
|
| 59 |
private: |
| 60 |
static const std::string preemptTimeoutMilliSecs; |
| 61 |
static const std::string defaultPreemptTimeouttMilliSecs; |
| 62 |
static const std::string timesliceDurationMilliSecs; |
| 63 |
static const std::string defaultTimesliceDurationMilliSecs; |
| 64 |
static const std::string heartbeatIntervalMilliSecs; |
| 65 |
static const std::string defaultHeartbeatIntervalMilliSecs; |
| 66 |
static const std::string enableEuDebug; |
| 67 |
std::vector<std::string> listOfEngines = {}; |
| 68 |
}; |
| 69 |
|
| 70 |
} // namespace L0 |