ML Reference
MeVis/Foundation/Sources/MLUtilities/mlCPUInfo.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00004 
00009 //----------------------------------------------------------------------------------
00010 
00011 #ifndef __mlCPUInfo_H
00012 #define __mlCPUInfo_H
00013 
00014 #include "mlUtilsSystem.h"
00015 
00016 ML_UTILS_START_NAMESPACE
00017 
00018 //=============================================================================
00036 //=============================================================================
00037 class ML_UTILS_EXPORT CPUInfo
00038 {
00039 public:
00040   // --------------------------------------------------------------------------
00044   // --------------------------------------------------------------------------
00045   static CPUInfo &getInstance();
00046 
00047 protected:
00048   // --------------------------------------------------------------------------
00052   // --------------------------------------------------------------------------
00053   CPUInfo();
00054 
00055 public:
00056   // --------------------------------------------------------------------------
00058   // --------------------------------------------------------------------------
00059   bool        isPentium()    const { return _isPentium; };
00060   // --------------------------------------------------------------------------
00062   // --------------------------------------------------------------------------
00063   bool        hasMMX()       const { return _hasMMX; };
00064   // --------------------------------------------------------------------------
00066   // --------------------------------------------------------------------------
00067   bool        hasSSE()       const { return _hasSSE; };
00068   // --------------------------------------------------------------------------
00070   // --------------------------------------------------------------------------
00071   bool        hasSSE2()      const { return _hasSSE2; };
00072   // --------------------------------------------------------------------------
00074   // --------------------------------------------------------------------------
00075   bool        hasSSE3()      const { return _hasSSE3; };
00076   // --------------------------------------------------------------------------
00078   // --------------------------------------------------------------------------
00079   bool        hasSSSE3()     const { return _hasSSSE3; };
00080   // --------------------------------------------------------------------------
00082   // --------------------------------------------------------------------------
00083   bool        hasSSE4_1()    const { return _hasSSE4_1; };
00084   // --------------------------------------------------------------------------
00086   // --------------------------------------------------------------------------
00087   bool        hasSSE4_2()    const { return _hasSSE4_2; };
00088   // --------------------------------------------------------------------------
00090   // --------------------------------------------------------------------------
00091   bool        hasSSE4a()      const { return _hasSSE4a; };
00092   // --------------------------------------------------------------------------
00094   // --------------------------------------------------------------------------
00095   bool        hasSSE5()      const { return _hasSSE5; };
00096   // --------------------------------------------------------------------------
00098   // --------------------------------------------------------------------------
00099   bool        hasAVX()       const { return _hasAVX; };
00100   // --------------------------------------------------------------------------
00102   // --------------------------------------------------------------------------
00103   bool        has3DNow()     const { return _has3DNow; };
00104   // --------------------------------------------------------------------------
00106   // --------------------------------------------------------------------------
00107   bool        has3DNowP()    const { return _has3DNowP; };
00108   // --------------------------------------------------------------------------
00110   // --------------------------------------------------------------------------
00111   void        getCacheSizes(unsigned int &csize_l1,
00112                             unsigned int &csize_l2) const;
00113   // --------------------------------------------------------------------------
00116   // --------------------------------------------------------------------------
00117   const std::string &getVendorID()  const { return _vendorID; };
00118   // --------------------------------------------------------------------------
00120   // --------------------------------------------------------------------------
00121   const std::string &getModelID()   const { return _modelID; };
00122   // --------------------------------------------------------------------------
00128   // --------------------------------------------------------------------------
00129   void        getCPUCount(unsigned int &numPhysicalProcessors,
00130                           unsigned int &numCores,
00131                           unsigned int &numVirtualProcessors);
00132 
00133   // --------------------------------------------------------------------------
00135   // --------------------------------------------------------------------------
00136   unsigned int getNumPhysicalProcessors() const;
00137   // --------------------------------------------------------------------------
00139   // --------------------------------------------------------------------------
00140   unsigned int getNumCores() const;
00141   // --------------------------------------------------------------------------
00143   // --------------------------------------------------------------------------
00144   unsigned int getNumVirtualProcessors() const;
00145 
00146   // --------------------------------------------------------------------------
00148   // --------------------------------------------------------------------------
00149   unsigned int getCPUFrequency() const;
00150 
00151   // --------------------------------------------------------------------------
00153   // --------------------------------------------------------------------------
00154   void        printInfo(std::ostream &ostr);
00155 
00156 private:
00158   std::string  _vendorID;
00160   std::string  _modelID;
00162   bool         _isPentium;
00164   bool         _hasMMX;
00166   bool         _hasSSE;
00168   bool         _hasSSE2;
00170   bool         _hasSSE3;
00172   bool         _hasSSSE3;
00174   bool         _hasSSE4_1;
00176   bool         _hasSSE4_2;
00178   bool         _hasSSE4a;
00180   bool         _hasSSE5;
00182   bool         _hasAVX;
00184   bool         _has3DNow;
00186   bool         _has3DNowP;
00188   unsigned int _cpuFrequency;
00190   unsigned int _csize_l1;
00192   unsigned int _csize_l2;
00194   unsigned int _numVirtualProcessors;
00196   unsigned int _numCores;
00198   unsigned int _numPhysicalProcessors;
00199 };
00200 
00201 ML_UTILS_END_NAMESPACE
00202 #endif