cmake/Source/kwsys/SystemInformation.hxx.in

164 lines
6.0 KiB
C++
Raw Normal View History

2017-04-14 19:02:05 +02:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#ifndef @KWSYS_NAMESPACE@_SystemInformation_h
#define @KWSYS_NAMESPACE@_SystemInformation_h
2015-11-17 17:22:37 +01:00
#include <@KWSYS_NAMESPACE@/Configure.hxx>
2017-04-14 19:02:05 +02:00
2010-03-17 14:00:29 +02:00
#include <stddef.h> /* size_t */
2015-11-17 17:22:37 +01:00
#include <string>
2017-04-14 19:02:05 +02:00
namespace @KWSYS_NAMESPACE@ {
2013-03-16 19:13:01 +02:00
// forward declare the implementation class
class SystemInformationImplementation;
2013-03-16 19:13:01 +02:00
class @KWSYS_NAMESPACE@_EXPORT SystemInformation
{
friend class SystemInformationImplementation;
SystemInformationImplementation* Implementation;
2017-07-20 19:35:53 +02:00
public:
// possible parameter values for DoesCPUSupportFeature()
static const long int CPU_FEATURE_MMX = 1 << 0;
static const long int CPU_FEATURE_MMX_PLUS = 1 << 1;
static const long int CPU_FEATURE_SSE = 1 << 2;
static const long int CPU_FEATURE_SSE2 = 1 << 3;
static const long int CPU_FEATURE_AMD_3DNOW = 1 << 4;
static const long int CPU_FEATURE_AMD_3DNOW_PLUS = 1 << 5;
static const long int CPU_FEATURE_IA64 = 1 << 6;
static const long int CPU_FEATURE_MP_CAPABLE = 1 << 7;
static const long int CPU_FEATURE_HYPERTHREAD = 1 << 8;
static const long int CPU_FEATURE_SERIALNUMBER = 1 << 9;
static const long int CPU_FEATURE_APIC = 1 << 10;
static const long int CPU_FEATURE_SSE_FP = 1 << 11;
static const long int CPU_FEATURE_SSE_MMX = 1 << 12;
static const long int CPU_FEATURE_CMOV = 1 << 13;
static const long int CPU_FEATURE_MTRR = 1 << 14;
static const long int CPU_FEATURE_L1CACHE = 1 << 15;
static const long int CPU_FEATURE_L2CACHE = 1 << 16;
static const long int CPU_FEATURE_L3CACHE = 1 << 17;
static const long int CPU_FEATURE_ACPI = 1 << 18;
static const long int CPU_FEATURE_THERMALMONITOR = 1 << 19;
static const long int CPU_FEATURE_TEMPSENSEDIODE = 1 << 20;
static const long int CPU_FEATURE_FREQUENCYID = 1 << 21;
static const long int CPU_FEATURE_VOLTAGEID_FREQUENCY = 1 << 22;
static const long int CPU_FEATURE_FPU = 1 << 23;
2017-04-14 19:02:05 +02:00
public:
SystemInformation();
~SystemInformation();
2019-11-11 23:01:05 +01:00
SystemInformation(const SystemInformation&) = delete;
SystemInformation& operator=(const SystemInformation&) = delete;
2017-04-14 19:02:05 +02:00
const char* GetVendorString();
const char* GetVendorID();
2015-11-17 17:22:37 +01:00
std::string GetTypeID();
std::string GetFamilyID();
std::string GetModelID();
std::string GetModelName();
std::string GetSteppingCode();
2017-04-14 19:02:05 +02:00
const char* GetExtendedProcessorName();
const char* GetProcessorSerialNumber();
int GetProcessorCacheSize();
2009-10-04 10:30:41 +03:00
unsigned int GetLogicalProcessorsPerPhysical();
float GetProcessorClockFrequency();
int GetProcessorAPICID();
int GetProcessorCacheXSize(long int);
bool DoesCPUSupportFeature(long int);
2013-03-16 19:13:01 +02:00
// returns an informative general description of the cpu
// on this system.
2015-11-17 17:22:37 +01:00
std::string GetCPUDescription();
2013-03-16 19:13:01 +02:00
2017-04-14 19:02:05 +02:00
const char* GetHostname();
2015-11-17 17:22:37 +01:00
std::string GetFullyQualifiedDomainName();
2013-03-16 19:13:01 +02:00
2017-04-14 19:02:05 +02:00
const char* GetOSName();
const char* GetOSRelease();
const char* GetOSVersion();
const char* GetOSPlatform();
2013-03-16 19:13:01 +02:00
int GetOSIsWindows();
int GetOSIsLinux();
int GetOSIsApple();
// returns an informative general description of the os
// on this system.
2015-11-17 17:22:37 +01:00
std::string GetOSDescription();
2013-03-16 19:13:01 +02:00
2017-07-20 19:35:53 +02:00
// returns if the operating system is 64bit or not.
bool Is64Bits();
2017-07-20 19:35:53 +02:00
unsigned int GetNumberOfLogicalCPU();
unsigned int GetNumberOfPhysicalCPU();
bool DoesCPUSupportCPUID();
2013-03-16 19:13:01 +02:00
// Retrieve id of the current running process
2020-08-30 11:54:41 +02:00
long long GetProcessId();
2013-03-16 19:13:01 +02:00
2018-04-23 21:13:27 +02:00
// Retrieve memory information in MiB.
2010-03-17 14:00:29 +02:00
size_t GetTotalVirtualMemory();
size_t GetAvailableVirtualMemory();
size_t GetTotalPhysicalMemory();
2013-03-16 19:13:01 +02:00
size_t GetAvailablePhysicalMemory();
// returns an informative general description if the installed and
2018-04-23 21:13:27 +02:00
// available ram on this system. See the GetHostMemoryTotal, and
2013-03-16 19:13:01 +02:00
// Get{Host,Proc}MemoryAvailable methods for more information.
2020-02-01 23:06:01 +01:00
std::string GetMemoryDescription(const char* hostLimitEnvVarName = nullptr,
const char* procLimitEnvVarName = nullptr);
2013-03-16 19:13:01 +02:00
// Retrieve amount of physical memory installed on the system in KiB
// units.
2020-08-30 11:54:41 +02:00
long long GetHostMemoryTotal();
2013-03-16 19:13:01 +02:00
// Get total system RAM in units of KiB available colectivley to all
// processes in a process group. An example of a process group
// are the processes comprising an mpi program which is running in
// parallel. The amount of memory reported may differ from the host
// total if a host wide resource limit is applied. Such reource limits
2018-04-23 21:13:27 +02:00
// are reported to us via an application specified environment variable.
2020-08-30 11:54:41 +02:00
long long GetHostMemoryAvailable(const char* hostLimitEnvVarName = nullptr);
2013-03-16 19:13:01 +02:00
// Get total system RAM in units of KiB available to this process.
// This may differ from the host available if a per-process resource
// limit is applied. per-process memory limits are applied on unix
2013-11-03 12:27:13 +02:00
// system via rlimit API. Resource limits that are not imposed via
// rlimit API may be reported to us via an application specified
2013-03-16 19:13:01 +02:00
// environment variable.
2020-08-30 11:54:41 +02:00
long long GetProcMemoryAvailable(const char* hostLimitEnvVarName = nullptr,
const char* procLimitEnvVarName = nullptr);
2013-03-16 19:13:01 +02:00
// Get the system RAM used by all processes on the host, in units of KiB.
2020-08-30 11:54:41 +02:00
long long GetHostMemoryUsed();
2013-03-16 19:13:01 +02:00
// Get system RAM used by this process id in units of KiB.
2020-08-30 11:54:41 +02:00
long long GetProcMemoryUsed();
2013-03-16 19:13:01 +02:00
2015-11-17 17:22:37 +01:00
// Return the load average of the machine or -0.0 if it cannot
// be determined.
double GetLoadAverage();
2013-03-16 19:13:01 +02:00
// enable/disable stack trace signal handler. In order to
// produce an informative stack trace the application should
// be dynamically linked and compiled with debug symbols.
2017-04-14 19:02:05 +02:00
static void SetStackTraceOnError(int enable);
2013-11-03 12:27:13 +02:00
// format and return the current program stack in a string. In
// order to produce an informative stack trace the application
// should be dynamically linked and compiled with debug symbols.
2017-04-14 19:02:05 +02:00
static std::string GetProgramStack(int firstFrame, int wholePath);
2013-11-03 12:27:13 +02:00
/** Run the different checks */
void RunCPUCheck();
void RunOSCheck();
void RunMemoryCheck();
};
2013-03-16 19:13:01 +02:00
} // namespace @KWSYS_NAMESPACE@
#endif