2012-05-02 16:46:10 +04:00
|
|
|
/*============================================================================
|
|
|
|
KWSys - Kitware System Library
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
|
|
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
|
|
|
#ifndef @KWSYS_NAMESPACE@_SystemInformation_h
|
|
|
|
#define @KWSYS_NAMESPACE@_SystemInformation_h
|
|
|
|
|
|
|
|
|
|
|
|
/* Define these macros temporarily to keep the code readable. */
|
|
|
|
#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
|
|
|
|
# define kwsys_stl @KWSYS_NAMESPACE@_stl
|
|
|
|
# define kwsys_ios @KWSYS_NAMESPACE@_ios
|
|
|
|
#endif
|
|
|
|
#include <@KWSYS_NAMESPACE@/stl/string>
|
|
|
|
#include <stddef.h> /* size_t */
|
|
|
|
|
|
|
|
namespace @KWSYS_NAMESPACE@
|
|
|
|
{
|
|
|
|
|
2012-10-01 22:58:49 +04:00
|
|
|
// forward declare the implementation class
|
2012-05-02 16:46:10 +04:00
|
|
|
class SystemInformationImplementation;
|
|
|
|
|
2012-10-01 22:58:49 +04:00
|
|
|
class @KWSYS_NAMESPACE@_EXPORT SystemInformation
|
|
|
|
{
|
|
|
|
#if @KWSYS_USE_LONG_LONG@
|
|
|
|
typedef long long LongLong;
|
|
|
|
#elif @KWSYS_USE___INT64@
|
|
|
|
typedef __int64 LongLong;
|
|
|
|
#else
|
|
|
|
# error "No Long Long"
|
|
|
|
#endif
|
|
|
|
friend class SystemInformationImplementation;
|
|
|
|
SystemInformationImplementation* Implementation;
|
2012-05-02 16:46:10 +04:00
|
|
|
public:
|
2012-10-01 22:58:49 +04:00
|
|
|
|
2012-05-02 16:46:10 +04:00
|
|
|
SystemInformation ();
|
|
|
|
~SystemInformation ();
|
|
|
|
|
|
|
|
const char * GetVendorString();
|
|
|
|
const char * GetVendorID();
|
|
|
|
kwsys_stl::string GetTypeID();
|
|
|
|
kwsys_stl::string GetFamilyID();
|
|
|
|
kwsys_stl::string GetModelID();
|
2012-10-01 22:58:49 +04:00
|
|
|
kwsys_stl::string GetModelName();
|
2012-05-02 16:46:10 +04:00
|
|
|
kwsys_stl::string GetSteppingCode();
|
|
|
|
const char * GetExtendedProcessorName();
|
|
|
|
const char * GetProcessorSerialNumber();
|
|
|
|
int GetProcessorCacheSize();
|
|
|
|
unsigned int GetLogicalProcessorsPerPhysical();
|
|
|
|
float GetProcessorClockFrequency();
|
|
|
|
int GetProcessorAPICID();
|
|
|
|
int GetProcessorCacheXSize(long int);
|
|
|
|
bool DoesCPUSupportFeature(long int);
|
2012-10-01 22:58:49 +04:00
|
|
|
|
|
|
|
// returns an informative general description of the cpu
|
|
|
|
// on this system.
|
|
|
|
kwsys_stl::string GetCPUDescription();
|
|
|
|
|
2012-05-02 16:46:10 +04:00
|
|
|
const char * GetHostname();
|
2012-10-01 22:58:49 +04:00
|
|
|
kwsys_stl::string GetFullyQualifiedDomainName();
|
|
|
|
|
|
|
|
const char * GetOSName();
|
2012-05-02 16:46:10 +04:00
|
|
|
const char * GetOSRelease();
|
|
|
|
const char * GetOSVersion();
|
|
|
|
const char * GetOSPlatform();
|
|
|
|
|
2012-10-01 22:58:49 +04:00
|
|
|
int GetOSIsWindows();
|
|
|
|
int GetOSIsLinux();
|
|
|
|
int GetOSIsApple();
|
|
|
|
|
|
|
|
// returns an informative general description of the os
|
|
|
|
// on this system.
|
|
|
|
kwsys_stl::string GetOSDescription();
|
|
|
|
|
2012-05-02 16:46:10 +04:00
|
|
|
bool Is64Bits();
|
|
|
|
|
|
|
|
unsigned int GetNumberOfLogicalCPU(); // per physical cpu
|
|
|
|
unsigned int GetNumberOfPhysicalCPU();
|
|
|
|
|
|
|
|
bool DoesCPUSupportCPUID();
|
|
|
|
|
2012-10-01 22:58:49 +04:00
|
|
|
// Retrieve id of the current running process
|
|
|
|
LongLong GetProcessId();
|
|
|
|
|
2012-05-02 16:46:10 +04:00
|
|
|
// Retrieve memory information in megabyte.
|
|
|
|
size_t GetTotalVirtualMemory();
|
|
|
|
size_t GetAvailableVirtualMemory();
|
|
|
|
size_t GetTotalPhysicalMemory();
|
2012-10-01 22:58:49 +04:00
|
|
|
size_t GetAvailablePhysicalMemory();
|
|
|
|
|
2012-10-17 01:12:23 +04:00
|
|
|
// returns an informative general description if the installed and
|
|
|
|
// available ram on this system. See the GetHostMmeoryTotal, and
|
|
|
|
// Get{Host,Proc}MemoryAvailable methods for more information.
|
|
|
|
kwsys_stl::string GetMemoryDescription(
|
|
|
|
const char *hostLimitEnvVarName=NULL,
|
|
|
|
const char *procLimitEnvVarName=NULL);
|
|
|
|
|
|
|
|
// Retrieve amount of physical memory installed on the system in KiB
|
|
|
|
// units.
|
|
|
|
LongLong GetHostMemoryTotal();
|
|
|
|
|
|
|
|
// 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
|
|
|
|
// are reported to us via an applicaiton specified environment variable.
|
|
|
|
LongLong GetHostMemoryAvailable(const char *hostLimitEnvVarName=NULL);
|
|
|
|
|
|
|
|
// 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-05-06 18:29:55 +04:00
|
|
|
// system via rlimit API. Resource limits that are not imposed via
|
|
|
|
// rlimit API may be reported to us via an application specified
|
2012-10-17 01:12:23 +04:00
|
|
|
// environment variable.
|
|
|
|
LongLong GetProcMemoryAvailable(
|
|
|
|
const char *hostLimitEnvVarName=NULL,
|
|
|
|
const char *procLimitEnvVarName=NULL);
|
|
|
|
|
|
|
|
// Get the system RAM used by all processes on the host, in units of KiB.
|
|
|
|
LongLong GetHostMemoryUsed();
|
|
|
|
|
|
|
|
// Get system RAM used by this process id in units of KiB.
|
|
|
|
LongLong GetProcMemoryUsed();
|
|
|
|
|
|
|
|
// 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.
|
2012-10-01 22:58:49 +04:00
|
|
|
static
|
|
|
|
void SetStackTraceOnError(int enable);
|
2012-05-02 16:46:10 +04:00
|
|
|
|
|
|
|
/** Run the different checks */
|
|
|
|
void RunCPUCheck();
|
|
|
|
void RunOSCheck();
|
|
|
|
void RunMemoryCheck();
|
|
|
|
};
|
2012-10-17 01:12:23 +04:00
|
|
|
|
2012-05-02 16:46:10 +04:00
|
|
|
} // namespace @KWSYS_NAMESPACE@
|
|
|
|
|
|
|
|
/* Undefine temporary macros. */
|
|
|
|
#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
|
|
|
|
# undef kwsys_stl
|
|
|
|
# undef kwsys_ios
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|