From 723e852c09afe3004f1494547fcc80012ae05643 Mon Sep 17 00:00:00 2001 From: Kanhaiya Date: Wed, 16 Sep 2020 11:24:22 +0530 Subject: [PATCH] Moved all the constants used in sysman to the single header file Change-Id: I0bfa02e68c9aba1cc5d3105c37630b30b03e1b54 Signed-off-by: Kanhaiya --- .../sysman/engine/linux/os_engine_imp.h | 3 +- .../linux/os_global_operations_imp.cpp | 6 +-- .../sysman/memory/windows/os_memory_imp.h | 4 +- .../source/sysman/pci/linux/os_pci_imp.cpp | 4 +- level_zero/tools/source/sysman/pci/pci.h | 18 +------- .../sysman/power/linux/os_power_imp.cpp | 1 + .../tools/source/sysman/power/os_power.h | 2 - .../scheduler/linux/os_scheduler_imp.cpp | 1 - .../source/sysman/scheduler/scheduler_imp.cpp | 5 +-- level_zero/tools/source/sysman/sysman_const.h | 42 +++++++++++++++++++ .../temperature/linux/os_temperature_imp.cpp | 2 - .../tools/source/sysman/windows/kmd_sys.h | 2 +- 12 files changed, 54 insertions(+), 36 deletions(-) create mode 100644 level_zero/tools/source/sysman/sysman_const.h diff --git a/level_zero/tools/source/sysman/engine/linux/os_engine_imp.h b/level_zero/tools/source/sysman/engine/linux/os_engine_imp.h index c00224a1e6..d9b590ee59 100644 --- a/level_zero/tools/source/sysman/engine/linux/os_engine_imp.h +++ b/level_zero/tools/source/sysman/engine/linux/os_engine_imp.h @@ -9,6 +9,8 @@ #include "shared/source/helpers/non_copyable_or_moveable.h" #include "shared/source/os_interface/linux/drm_neo.h" +#include "level_zero/tools/source/sysman/sysman_const.h" + #include "sysman/engine/os_engine.h" namespace L0 { class PmuInterface; @@ -35,7 +37,6 @@ class LinuxEngineImp : public OsEngine, NEO::NonCopyableOrMovableClass { private: void init(); - const uint32_t microSecondsToNanoSeconds = 1000u; int64_t fd = -1; }; diff --git a/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp b/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp index 3152687144..5b19ed55e9 100644 --- a/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp +++ b/level_zero/tools/source/sysman/global_operations/linux/os_global_operations_imp.cpp @@ -10,15 +10,13 @@ #include "level_zero/core/source/device/device.h" #include "level_zero/tools/source/sysman/global_operations/global_operations_imp.h" #include "level_zero/tools/source/sysman/linux/fs_access.h" +#include "level_zero/tools/source/sysman/sysman_const.h" #include #include namespace L0 { -const std::string vendorIntel("Intel(R) Corporation"); -const std::string unknown("Unknown"); -const std::string intelPciId("0x8086"); const std::string LinuxGlobalOperationsImp::deviceDir("device"); const std::string LinuxGlobalOperationsImp::vendorFile("device/vendor"); const std::string LinuxGlobalOperationsImp::deviceFile("device/device"); @@ -33,7 +31,7 @@ const std::string LinuxGlobalOperationsImp::agamaVersionFile("/sys/module/i915/a // with engine enum defined in leve-zero spec // Note that entries with int 2 and 3(represented by i915 as CLASS_VIDEO and CLASS_VIDEO_ENHANCE) // are both mapped to MEDIA, as CLASS_VIDEO represents any media fixed-function hardware. -const std::map engineMap = { +static const std::map engineMap = { {0, ZES_ENGINE_TYPE_FLAG_3D}, {1, ZES_ENGINE_TYPE_FLAG_DMA}, {2, ZES_ENGINE_TYPE_FLAG_MEDIA}, diff --git a/level_zero/tools/source/sysman/memory/windows/os_memory_imp.h b/level_zero/tools/source/sysman/memory/windows/os_memory_imp.h index 235a94fcd5..7cbd47f9f7 100644 --- a/level_zero/tools/source/sysman/memory/windows/os_memory_imp.h +++ b/level_zero/tools/source/sysman/memory/windows/os_memory_imp.h @@ -8,14 +8,14 @@ #pragma once #include "shared/source/helpers/non_copyable_or_moveable.h" +#include "level_zero/tools/source/sysman/sysman_const.h" + #include "sysman/memory/os_memory.h" #include "sysman/windows/os_sysman_imp.h" namespace L0 { class KmdSysManager; -constexpr uint32_t MbpsToBytesPerSecond = 125000; - class WddmMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass { public: ze_result_t getProperties(zes_mem_properties_t *pProperties) override; diff --git a/level_zero/tools/source/sysman/pci/linux/os_pci_imp.cpp b/level_zero/tools/source/sysman/pci/linux/os_pci_imp.cpp index 55553c72e5..65d885ed6f 100644 --- a/level_zero/tools/source/sysman/pci/linux/os_pci_imp.cpp +++ b/level_zero/tools/source/sysman/pci/linux/os_pci_imp.cpp @@ -8,6 +8,7 @@ #include "level_zero/tools/source/sysman/pci/linux/os_pci_imp.h" #include "level_zero/tools/source/sysman/linux/fs_access.h" +#include "level_zero/tools/source/sysman/sysman_const.h" #include "sysman/linux/os_sysman_imp.h" #include "sysman/pci/pci_imp.h" @@ -18,9 +19,6 @@ const std::string LinuxPciImp::deviceDir("device"); const std::string LinuxPciImp::resourceFile("device/resource"); const std::string LinuxPciImp::maxLinkSpeedFile("device/max_link_speed"); const std::string LinuxPciImp::maxLinkWidthFile("device/max_link_width"); -constexpr uint8_t maxPciBars = 6; -// Linux kernel would report 255 link width, as an indication of unknown. -constexpr uint32_t unknownPcieLinkWidth = 255u; std::string LinuxPciImp::changeDirNLevelsUp(std::string realRootPath, uint8_t nLevel) { size_t loc; diff --git a/level_zero/tools/source/sysman/pci/pci.h b/level_zero/tools/source/sysman/pci/pci.h index db84ed246a..710d0b1140 100644 --- a/level_zero/tools/source/sysman/pci/pci.h +++ b/level_zero/tools/source/sysman/pci/pci.h @@ -6,26 +6,10 @@ */ #pragma once +#include "level_zero/tools/source/sysman/sysman_const.h" #include - namespace L0 { -namespace PciLinkSpeeds { -constexpr double Pci2_5GigatransfersPerSecond = 2.5; -constexpr double Pci5_0GigatransfersPerSecond = 5.0; -constexpr double Pci8_0GigatransfersPerSecond = 8.0; -constexpr double Pci16_0GigatransfersPerSecond = 16.0; -constexpr double Pci32_0GigatransfersPerSecond = 32.0; -} // namespace PciLinkSpeeds - -enum PciGenerations { - PciGen1 = 1, - PciGen2, - PciGen3, - PciGen4, - PciGen5, -}; - class Pci { public: virtual ~Pci(){}; diff --git a/level_zero/tools/source/sysman/power/linux/os_power_imp.cpp b/level_zero/tools/source/sysman/power/linux/os_power_imp.cpp index b72dd719fb..dc54c00124 100644 --- a/level_zero/tools/source/sysman/power/linux/os_power_imp.cpp +++ b/level_zero/tools/source/sysman/power/linux/os_power_imp.cpp @@ -8,6 +8,7 @@ #include "level_zero/tools/source/sysman/power/linux/os_power_imp.h" #include "level_zero/tools/source/sysman/linux/pmt.h" +#include "level_zero/tools/source/sysman/sysman_const.h" #include "sysman/linux/os_sysman_imp.h" diff --git a/level_zero/tools/source/sysman/power/os_power.h b/level_zero/tools/source/sysman/power/os_power.h index 5cfbc15194..36b4377249 100644 --- a/level_zero/tools/source/sysman/power/os_power.h +++ b/level_zero/tools/source/sysman/power/os_power.h @@ -26,6 +26,4 @@ class OsPower { virtual ~OsPower() = default; }; -constexpr uint64_t convertJouleToMicroJoule = 1000000u; - } // namespace L0 diff --git a/level_zero/tools/source/sysman/scheduler/linux/os_scheduler_imp.cpp b/level_zero/tools/source/sysman/scheduler/linux/os_scheduler_imp.cpp index cd98d184d1..55f6f35ebe 100644 --- a/level_zero/tools/source/sysman/scheduler/linux/os_scheduler_imp.cpp +++ b/level_zero/tools/source/sysman/scheduler/linux/os_scheduler_imp.cpp @@ -18,7 +18,6 @@ const std::string LinuxSchedulerImp::defaultTimesliceDurationMilliSecs(".default const std::string LinuxSchedulerImp::heartbeatIntervalMilliSecs("heartbeat_interval_ms"); const std::string LinuxSchedulerImp::defaultHeartbeatIntervalMilliSecs(".defaults/heartbeat_interval_ms"); const std::string LinuxSchedulerImp::engineDir("engine"); -constexpr uint16_t milliSecsToMicroSecs = 1000; ze_result_t LinuxSchedulerImp::getProperties(zes_sched_properties_t &schedProperties) { schedProperties.onSubdevice = false; diff --git a/level_zero/tools/source/sysman/scheduler/scheduler_imp.cpp b/level_zero/tools/source/sysman/scheduler/scheduler_imp.cpp index bdace8eaa5..5e64c99e69 100644 --- a/level_zero/tools/source/sysman/scheduler/scheduler_imp.cpp +++ b/level_zero/tools/source/sysman/scheduler/scheduler_imp.cpp @@ -9,10 +9,9 @@ #include "shared/source/helpers/debug_helpers.h" -namespace L0 { +#include "level_zero/tools/source/sysman/sysman_const.h" -constexpr uint64_t minTimeoutModeHeartbeat = 5000u; -constexpr uint64_t minTimeoutInMicroSeconds = 1000u; +namespace L0 { ze_result_t SchedulerImp::setExclusiveMode(ze_bool_t *pNeedReload) { uint64_t timeslice = 0, timeout = 0, heartbeat = 0; diff --git a/level_zero/tools/source/sysman/sysman_const.h b/level_zero/tools/source/sysman/sysman_const.h new file mode 100644 index 0000000000..ed4c5ce1ef --- /dev/null +++ b/level_zero/tools/source/sysman/sysman_const.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include +const std::string vendorIntel("Intel(R) Corporation"); +const std::string unknown("Unknown"); +const std::string intelPciId("0x8086"); +constexpr uint32_t MbpsToBytesPerSecond = 125000; + +namespace PciLinkSpeeds { +constexpr double Pci2_5GigatransfersPerSecond = 2.5; +constexpr double Pci5_0GigatransfersPerSecond = 5.0; +constexpr double Pci8_0GigatransfersPerSecond = 8.0; +constexpr double Pci16_0GigatransfersPerSecond = 16.0; +constexpr double Pci32_0GigatransfersPerSecond = 32.0; + +} // namespace PciLinkSpeeds +enum PciGenerations { + PciGen1 = 1, + PciGen2, + PciGen3, + PciGen4, + PciGen5, +}; + +constexpr uint8_t maxPciBars = 6; +// Linux kernel would report 255 link width, as an indication of unknown. +constexpr uint32_t unknownPcieLinkWidth = 255u; + +constexpr uint32_t microSecondsToNanoSeconds = 1000u; + +constexpr uint64_t convertJouleToMicroJoule = 1000000u; +constexpr uint64_t minTimeoutModeHeartbeat = 5000u; +constexpr uint64_t minTimeoutInMicroSeconds = 1000u; +constexpr uint16_t milliSecsToMicroSecs = 1000; +constexpr uint64_t numSocTemperatureEntries = 7; +constexpr uint32_t numCoreTemperatureEntries = 4; diff --git a/level_zero/tools/source/sysman/temperature/linux/os_temperature_imp.cpp b/level_zero/tools/source/sysman/temperature/linux/os_temperature_imp.cpp index 3f08bcaf4d..3a6b99d881 100644 --- a/level_zero/tools/source/sysman/temperature/linux/os_temperature_imp.cpp +++ b/level_zero/tools/source/sysman/temperature/linux/os_temperature_imp.cpp @@ -12,8 +12,6 @@ #include "sysman/linux/os_sysman_imp.h" namespace L0 { -constexpr uint64_t numSocTemperatureEntries = 7; -constexpr uint32_t numCoreTemperatureEntries = 4; ze_result_t LinuxTemperatureImp::getProperties(zes_temp_properties_t *pProperties) { pProperties->type = type; diff --git a/level_zero/tools/source/sysman/windows/kmd_sys.h b/level_zero/tools/source/sysman/windows/kmd_sys.h index a2f71acea0..6b7d404abc 100644 --- a/level_zero/tools/source/sysman/windows/kmd_sys.h +++ b/level_zero/tools/source/sysman/windows/kmd_sys.h @@ -513,4 +513,4 @@ struct ResponseProperty { uint8_t dataBuffer[MaxPropertyBufferSize] = {0}; }; } // namespace KmdSysman -} // namespace L0 \ No newline at end of file +} // namespace L0