Matrix Science header

ms_processors.hpp

00001 /*
00002 ##############################################################################
00003 # file: ms_processors.hpp                                                    #
00004 # 'msparser' toolkit                                                         #
00005 # Use this class to retrieve current CPU configuration                       #
00006 ##############################################################################
00007 # COPYRIGHT NOTICE                                                           #
00008 # Copyright 1998-2003 Matrix Science Limited  All Rights Reserved.           #
00009 #                                                                            #
00010 ##############################################################################
00011 #    $Archive:: /Mowse/ms_mascotresfile/include/ms_processors.hpp          $ #
00012 #     $Author: davidc $ #
00013 #       $Date: 2018/01/17 11:00:42 $ #
00014 #   $Revision: 1.17.2.1 $ #
00015 # $NoKeywords::                                                            $ #
00016 ##############################################################################
00017 */
00018 
00019 #ifndef MS_PROCESSORS_HPP
00020 #define MS_PROCESSORS_HPP
00021 
00022 #ifdef _WIN32
00023 #pragma warning(disable:4251)   // Don't want all classes to be exported
00024 #pragma warning(disable:4786)   // Debug symbols too long
00025 #   ifndef _MATRIX_USE_STATIC_LIB
00026 #       ifdef MS_MASCOTRESFILE_EXPORTS
00027 #           define MS_MASCOTRESFILE_API __declspec(dllexport)
00028 #       else
00029 #           define MS_MASCOTRESFILE_API __declspec(dllimport)
00030 #       endif
00031 #   else
00032 #       define MS_MASCOTRESFILE_API
00033 #   endif
00034 #else
00035 #   define MS_MASCOTRESFILE_API
00036 #endif
00037 
00038 // for the sake of #include <string>
00039 #ifdef __ALPHA_UNIX__
00040 #include <ctype.h>
00041 #endif
00042 #ifdef __SUNOS__
00043 #include <kstat.h>
00044 #endif
00045 #include <string>
00046 #include <vector>
00047 
00048 namespace msparser_internal {
00049     class ms_processors_impl;
00050 }
00051 
00052 namespace matrix_science {
00053 
00059 
00060 
00072     class MS_MASCOTRESFILE_API ms_processors: public ms_errors
00073     {
00074     public:
00076 
00083         enum HYPERTHREADING
00084         {
00085             HT_NOT_CAPABLE           = 0, 
00086             HT_ENABLED               = 1, 
00087             HT_DISABLED              = 2, 
00088             HT_SUPPORTED_NOT_ENABLED = 3, 
00089             HT_CANNOT_DETECT         = 4  
00090         };
00091 
00093 
00099         enum { 
00100             MAX_CORES_PER_LICENSE = 4 
00101         };
00102 
00104         ms_processors(bool checkLinuxHT, int numLicensed);
00105 
00107         ms_processors(const ms_processors& src);
00108 
00110         ~ms_processors();
00111 
00113         void copyFrom(const ms_processors* right);
00114 
00115 #ifndef SWIG
00116 
00117         ms_processors& operator=(const ms_processors& right);
00118 #endif
00119 
00120         int getNumOnSystem() const;
00121 
00123         int getNumAvailableToProcess() const;
00124 
00126         bool isProcessAffinitySupported() const;
00127 
00129         bool isUseProcessesNotThreads() const;
00130 
00132         UINT64 getWhichAvailableForMascot() const;
00133 
00135         std::vector<int> getWhichAvailableForMascot2() const;
00136 
00138         bool isLogicalCPUAvailableForMascot(const int cpu) const;
00139 
00141         int getNumProcessorGroups() const;
00142 
00144         int getNumPhysicalOnSystem() const;
00145 
00147         HYPERTHREADING getHyperThreadingState() const;
00148 
00150         int getNumLogicalPerPhysical(const int packageID = 0) const;
00151 
00153         int getNumCores(const int packageID = -1) const;
00154 
00156         int getPhysicalFromLogical(const int cpu) const;
00157 
00159         std::string getProcessorName() const;
00160 
00162         std::string getMultithreadedName() const;
00163 
00165         UINT64 getHyperThreadedCPUsMask() const; 
00166 
00168         bool isPrimaryLogicalProcessor(const int cpu) const;
00169 
00171         bool isThreadedLogicalProcessor(const int cpu) const;
00172 
00174         int getCoreFromLogical(const int cpu) const;
00175 
00177         int getHT_IDFromLogical(const int cpu) const;
00178 
00180         int getAutoDetectNumThreads(const int numLicensed) const;
00181        
00183         bool setProcessAffinity(const std::vector<unsigned int> & vecCpu) const;
00184 
00186         bool setProcessAffinity(const std::vector<int> & vecCpu) const;
00187 
00189         bool setThreadAffinity(const int logicalCpu) const;
00190 
00191     private:
00192         msparser_internal::ms_processors_impl * pImpl_;
00193     }; // class ms_processors // end of config_group
00195 } // namespace matrix_science
00196 
00197 #endif // MS_PROCESSORS_HPP
00198 
00199 /*------------------------------- End of File -------------------------------*/
00200 
Copyright © 2016 Matrix Science Ltd.  All Rights Reserved. Generated on Sat Apr 14 2018 01:45:12