| 1 |
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
| 2 |
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */ |
| 3 |
#ifndef @KWSYS_NAMESPACE@_SystemInformation_h |
| 4 |
#define @KWSYS_NAMESPACE@_SystemInformation_h |
| 5 |
|
| 6 |
#include <@KWSYS_NAMESPACE@/Configure.hxx> |
| 7 |
|
| 8 |
#include <stddef.h> /* size_t */ |
| 9 |
#include <string> |
| 10 |
|
| 11 |
namespace @KWSYS_NAMESPACE@ { |
| 12 |
|
| 13 |
// forward declare the implementation class |
| 14 |
class SystemInformationImplementation; |
| 15 |
|
| 16 |
class @KWSYS_NAMESPACE@_EXPORT SystemInformation |
| 17 |
{ |
| 18 |
friend class SystemInformationImplementation; |
| 19 |
SystemInformationImplementation* Implementation; |
| 20 |
|
| 21 |
public: |
| 22 |
// possible parameter values for DoesCPUSupportFeature() |
| 23 |
static const long int CPU_FEATURE_MMX = 1 << 0; |
| 24 |
static const long int CPU_FEATURE_MMX_PLUS = 1 << 1; |
| 25 |
static const long int CPU_FEATURE_SSE = 1 << 2; |
| 26 |
static const long int CPU_FEATURE_SSE2 = 1 << 3; |
| 27 |
static const long int CPU_FEATURE_AMD_3DNOW = 1 << 4; |
| 28 |
static const long int CPU_FEATURE_AMD_3DNOW_PLUS = 1 << 5; |
| 29 |
static const long int CPU_FEATURE_IA64 = 1 << 6; |
| 30 |
static const long int CPU_FEATURE_MP_CAPABLE = 1 << 7; |
| 31 |
static const long int CPU_FEATURE_HYPERTHREAD = 1 << 8; |
| 32 |
static const long int CPU_FEATURE_SERIALNUMBER = 1 << 9; |
| 33 |
static const long int CPU_FEATURE_APIC = 1 << 10; |
| 34 |
static const long int CPU_FEATURE_SSE_FP = 1 << 11; |
| 35 |
static const long int CPU_FEATURE_SSE_MMX = 1 << 12; |
| 36 |
static const long int CPU_FEATURE_CMOV = 1 << 13; |
| 37 |
static const long int CPU_FEATURE_MTRR = 1 << 14; |
| 38 |
static const long int CPU_FEATURE_L1CACHE = 1 << 15; |
| 39 |
static const long int CPU_FEATURE_L2CACHE = 1 << 16; |
| 40 |
static const long int CPU_FEATURE_L3CACHE = 1 << 17; |
| 41 |
static const long int CPU_FEATURE_ACPI = 1 << 18; |
| 42 |
static const long int CPU_FEATURE_THERMALMONITOR = 1 << 19; |
| 43 |
static const long int CPU_FEATURE_TEMPSENSEDIODE = 1 << 20; |
| 44 |
static const long int CPU_FEATURE_FREQUENCYID = 1 << 21; |
| 45 |
static const long int CPU_FEATURE_VOLTAGEID_FREQUENCY = 1 << 22; |
| 46 |
static const long int CPU_FEATURE_FPU = 1 << 23; |
| 47 |
|
| 48 |
public: |
| 49 |
SystemInformation(); |
| 50 |
~SystemInformation(); |
| 51 |
|
| 52 |
SystemInformation(const SystemInformation&) = delete; |
| 53 |
SystemInformation& operator=(const SystemInformation&) = delete; |
| 54 |
|
| 55 |
const char* GetVendorString(); |
| 56 |
const char* GetVendorID(); |
| 57 |
std::string GetTypeID(); |
| 58 |
std::string GetFamilyID(); |
| 59 |
std::string GetModelID(); |
| 60 |
std::string GetModelName(); |
| 61 |
std::string GetSteppingCode(); |
| 62 |
const char* GetExtendedProcessorName(); |
| 63 |
const char* GetProcessorSerialNumber(); |
| 64 |
int GetProcessorCacheSize(); |
| 65 |
unsigned int GetLogicalProcessorsPerPhysical(); |
| 66 |
float GetProcessorClockFrequency(); |
| 67 |
int GetProcessorAPICID(); |
| 68 |
int GetProcessorCacheXSize(long int); |
| 69 |
bool DoesCPUSupportFeature(long int); |
| 70 |
|
| 71 |
// returns an informative general description of the cpu |
| 72 |
// on this system. |
| 73 |
std::string GetCPUDescription(); |
| 74 |
|
| 75 |
const char* GetHostname(); |
| 76 |
std::string GetFullyQualifiedDomainName(); |
| 77 |
|
| 78 |
const char* GetOSName(); |
| 79 |
const char* GetOSRelease(); |
| 80 |
const char* GetOSVersion(); |
| 81 |
const char* GetOSPlatform(); |
| 82 |
|
| 83 |
int GetOSIsWindows(); |
| 84 |
int GetOSIsLinux(); |
| 85 |
int GetOSIsApple(); |
| 86 |
|
| 87 |
// returns an informative general description of the os |
| 88 |
// on this system. |
| 89 |
std::string GetOSDescription(); |
| 90 |
|
| 91 |
// returns if the operating system is 64bit or not. |
| 92 |
bool Is64Bits(); |
| 93 |
|
| 94 |
unsigned int GetNumberOfLogicalCPU(); |
| 95 |
unsigned int GetNumberOfPhysicalCPU(); |
| 96 |
|
| 97 |
bool DoesCPUSupportCPUID(); |
| 98 |
|
| 99 |
// Retrieve id of the current running process |
| 100 |
long long GetProcessId(); |
| 101 |
|
| 102 |
// Retrieve memory information in MiB. |
| 103 |
size_t GetTotalVirtualMemory(); |
| 104 |
size_t GetAvailableVirtualMemory(); |
| 105 |
size_t GetTotalPhysicalMemory(); |
| 106 |
size_t GetAvailablePhysicalMemory(); |
| 107 |
|
| 108 |
// returns an informative general description if the installed and |
| 109 |
// available ram on this system. See the GetHostMemoryTotal, and |
| 110 |
// Get{Host,Proc}MemoryAvailable methods for more information. |
| 111 |
std::string GetMemoryDescription(const char* hostLimitEnvVarName = nullptr, |
| 112 |
const char* procLimitEnvVarName = nullptr); |
| 113 |
|
| 114 |
// Retrieve amount of physical memory installed on the system in KiB |
| 115 |
// units. |
| 116 |
long long GetHostMemoryTotal(); |
| 117 |
|
| 118 |
// Get total system RAM in units of KiB available colectivley to all |
| 119 |
// processes in a process group. An example of a process group |
| 120 |
// are the processes comprising an mpi program which is running in |
| 121 |
// parallel. The amount of memory reported may differ from the host |
| 122 |
// total if a host wide resource limit is applied. Such reource limits |
| 123 |
// are reported to us via an application specified environment variable. |
| 124 |
long long GetHostMemoryAvailable(const char* hostLimitEnvVarName = nullptr); |
| 125 |
|
| 126 |
// Get total system RAM in units of KiB available to this process. |
| 127 |
// This may differ from the host available if a per-process resource |
| 128 |
// limit is applied. per-process memory limits are applied on unix |
| 129 |
// system via rlimit API. Resource limits that are not imposed via |
| 130 |
// rlimit API may be reported to us via an application specified |
| 131 |
// environment variable. |
| 132 |
long long GetProcMemoryAvailable(const char* hostLimitEnvVarName = nullptr, |
| 133 |
const char* procLimitEnvVarName = nullptr); |
| 134 |
|
| 135 |
// Get the system RAM used by all processes on the host, in units of KiB. |
| 136 |
long long GetHostMemoryUsed(); |
| 137 |
|
| 138 |
// Get system RAM used by this process id in units of KiB. |
| 139 |
long long GetProcMemoryUsed(); |
| 140 |
|
| 141 |
// Return the load average of the machine or -0.0 if it cannot |
| 142 |
// be determined. |
| 143 |
double GetLoadAverage(); |
| 144 |
|
| 145 |
// enable/disable stack trace signal handler. In order to |
| 146 |
// produce an informative stack trace the application should |
| 147 |
// be dynamically linked and compiled with debug symbols. |
| 148 |
static void SetStackTraceOnError(int enable); |
| 149 |
|
| 150 |
// format and return the current program stack in a string. In |
| 151 |
// order to produce an informative stack trace the application |
| 152 |
// should be dynamically linked and compiled with debug symbols. |
| 153 |
static std::string GetProgramStack(int firstFrame, int wholePath); |
| 154 |
|
| 155 |
/** Run the different checks */ |
| 156 |
void RunCPUCheck(); |
| 157 |
void RunOSCheck(); |
| 158 |
void RunMemoryCheck(); |
| 159 |
}; |
| 160 |
|
| 161 |
} // namespace @KWSYS_NAMESPACE@ |
| 162 |
|
| 163 |
#endif |