#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2023 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_PLATFORM_HARDWARE_CPUINFO_H #define NUCLEX_PLATFORM_HARDWARE_CPUINFO_H #include "Nuclex/Platform/Config.h" #include // for std::size_t #include // for std::string #include // for std::vector #include // for std::optional namespace Nuclex { namespace Platform { namespace Hardware { // ------------------------------------------------------------------------------------------- // class CoreInfo; // declared further down in this file // ------------------------------------------------------------------------------------------- // /// Informations about a physical CPU installed in the system class NUCLEX_PLATFORM_TYPE CpuInfo { /// Manufacturer and model name of the CPU, if available /// /// This is only for display and plausibility checking to spot when the hardware /// querying code reports numbers that do not match the CPU's specifications. /// The model name will be something like "Intel Xeon E5-2680", /// "Intel Core i5-4300U&" or "AMD Ryzen X5900" if it can be /// determined. On Windows systems it can also state "e;"e; because /// Windows hardware APIs are all undocumented, broken or simply too slow to query. /// public: std::string ModelName; /// Number of cores on the CPU /// /// On plain CPUs, one core equals one unit capable of independent, parallel execution /// of code. In this case, the number of cores and processors reported will be the same. /// If HyperThreading or SMT is supported and enabled, each core may be split into /// multiple processors, so the number of processors may, for example, be double /// the number of cores. /// public: std::size_t CoreCount; /// Number of 'eco' cores on the CPU /// /// Some newer CPUs have a mix of performance cores ("p-cores") which provide excellent /// per-thread performance and eco cores ("e-cores") which are slower but more energy /// efficient. If this value is present, the current system uses such a CPU and we were /// able to detect it as such. If empty, the core types could not be determined. /// public: std::optional EcoCoreCount; /// Number of independent units able to execute code in this CPU /// /// This indicates the number of threads that can run independently and in parallel on /// hardware on this CPU. It can be used to tune a thread pool or to control the number /// of tasks that will be launched in parallel. /// public: std::size_t ThreadCount; /// Detailed information about the CPU's cores public: std::vector Cores; }; // ------------------------------------------------------------------------------------------- // /// Informations about a physical CPU installed in the system class NUCLEX_PLATFORM_TYPE CoreInfo { /// Frequency of the CPU in Megahertz /// /// This may or may not include opportunistic overclocking (but if the hardware /// detection has a choice, it will be without). It is for display and possibly /// performance-prioritized scheduling (if a CPU has performance + eco cores). /// public: double FrequencyInMHz; /// Estimated average instructions per second this core can execute /// /// This value is not an accurate benchmark in any way, it just provides a vague idea of /// what performance can be expected from this CPU. You can use it to warn about seriously /// underpowered systems, for complex multi-system/-socket task balancing and perhaps to /// estimate how much there is to gain from running on a P-core versus an E-core. /// public: std::optional BogoMips; /// Whether this core is a slower but power-efficient eco core /// /// Modern CPUs can contain different types of cores, usually split between /// "performance cores" and "eco cores". P-cores are intended to /// offer good single-thread performance for old and/or low-threaded applications /// while the additional E-cores can be used for non-time-critical tasks or recruited /// by high-threaded appications to achieve maximum throughput. /// public: std::optional IsEcoCore; /// Number of threads that can run on this core /// /// With HyperThreading and similar techniques, CPU cores are treated as two or more /// processors (aka hardware threads). While such processors share some or all of /// the underlying circuits, the hardware itself can be able to run some instructions /// in parallel or seamlessly continue running the other processor's instructions when /// one of them is waiting (i.e. for a memory access, an FPU calculation or such). /// public: std::size_t ThreadCount; }; // ------------------------------------------------------------------------------------------- // // QueryTemperature() as separate method // QueryCurrentFrequency() as separate method // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Platform::Hardware #endif // NUCLEX_PLATFORM_HARDWARE_CPUINFO_H