123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- #ifndef BASE_CPU_H_
- #define BASE_CPU_H_
- #include <string>
- #include <tuple>
- #include <vector>
- #include "base/base_export.h"
- #include "base/time/time.h"
- #include "build/build_config.h"
- namespace base {
- #if defined(ARCH_CPU_X86_FAMILY)
- namespace internal {
- BASE_EXPORT std::tuple<int, int, int, int> ComputeX86FamilyAndModel(
- const std::string& vendor,
- int signature);
- }
- #endif // defined(ARCH_CPU_X86_FAMILY)
- class BASE_EXPORT CPU final {
- public:
- CPU();
- enum IntelMicroArchitecture {
- PENTIUM,
- SSE,
- SSE2,
- SSE3,
- SSSE3,
- SSE41,
- SSE42,
- AVX,
- AVX2,
- MAX_INTEL_MICRO_ARCHITECTURE
- };
-
- const std::string& vendor_name() const { return cpu_vendor_; }
- int signature() const { return signature_; }
- int stepping() const { return stepping_; }
- int model() const { return model_; }
- int family() const { return family_; }
- int type() const { return type_; }
- int extended_model() const { return ext_model_; }
- int extended_family() const { return ext_family_; }
- bool has_mmx() const { return has_mmx_; }
- bool has_sse() const { return has_sse_; }
- bool has_sse2() const { return has_sse2_; }
- bool has_sse3() const { return has_sse3_; }
- bool has_ssse3() const { return has_ssse3_; }
- bool has_sse41() const { return has_sse41_; }
- bool has_sse42() const { return has_sse42_; }
- bool has_popcnt() const { return has_popcnt_; }
- bool has_avx() const { return has_avx_; }
- bool has_avx2() const { return has_avx2_; }
- bool has_aesni() const { return has_aesni_; }
- bool has_non_stop_time_stamp_counter() const {
- return has_non_stop_time_stamp_counter_;
- }
- bool is_running_in_vm() const { return is_running_in_vm_; }
- IntelMicroArchitecture GetIntelMicroArchitecture() const;
- const std::string& cpu_brand() const { return cpu_brand_; }
- #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) || \
- defined(OS_AIX)
- enum class CoreType {
- kUnknown = 0,
- kOther,
- kSymmetric,
- kBigLittle_Little,
- kBigLittle_Big,
- kBigLittleBigger_Little,
- kBigLittleBigger_Big,
- kBigLittleBigger_Bigger,
- kMaxValue = kBigLittleBigger_Bigger
- };
-
-
-
-
-
-
- static std::vector<CoreType> GuessCoreTypes();
- struct TimeInStateEntry {
- CPU::CoreType core_type;
- uint32_t cluster_core_index;
- uint64_t core_frequency_khz;
- TimeDelta cumulative_cpu_time;
- };
- using TimeInState = std::vector<TimeInStateEntry>;
-
-
-
-
-
-
-
-
-
-
- static bool GetTimeInState(TimeInState&);
- #endif // defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_ANDROID) ||
-
- private:
-
- void Initialize();
- int signature_;
- int type_;
- int family_;
- int model_;
- int stepping_;
- int ext_model_;
- int ext_family_;
- bool has_mmx_;
- bool has_sse_;
- bool has_sse2_;
- bool has_sse3_;
- bool has_ssse3_;
- bool has_sse41_;
- bool has_sse42_;
- bool has_popcnt_;
- bool has_avx_;
- bool has_avx2_;
- bool has_aesni_;
- bool has_non_stop_time_stamp_counter_;
- bool is_running_in_vm_;
- std::string cpu_vendor_;
- std::string cpu_brand_;
- };
- }
- #endif // BASE_CPU_H_
|