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