YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/src/yb/gutil/cpu.h
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
//
5
// The following only applies to changes made to this file as part of YugaByte development.
6
//
7
// Portions Copyright (c) YugaByte, Inc.
8
//
9
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
10
// in compliance with the License.  You may obtain a copy of the License at
11
//
12
// http://www.apache.org/licenses/LICENSE-2.0
13
//
14
// Unless required by applicable law or agreed to in writing, software distributed under the License
15
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
16
// or implied.  See the License for the specific language governing permissions and limitations
17
// under the License.
18
//
19
20
#ifndef BASE_CPU_H_
21
#define BASE_CPU_H_
22
23
#include <string>
24
25
namespace base {
26
27
// Query information about the processor.
28
class CPU {
29
 public:
30
  // Constructor
31
  CPU();
32
33
  enum IntelMicroArchitecture {
34
    PENTIUM,
35
    SSE,
36
    SSE2,
37
    SSE3,
38
    SSSE3,
39
    SSE41,
40
    SSE42,
41
    AVX,
42
    AVX2,
43
    MAX_INTEL_MICRO_ARCHITECTURE
44
  };
45
46
  // Accessors for CPU information.
47
0
  const std::string& vendor_name() const { return cpu_vendor_; }
48
0
  int signature() const { return signature_; }
49
0
  int stepping() const { return stepping_; }
50
0
  int model() const { return model_; }
51
0
  int family() const { return family_; }
52
0
  int type() const { return type_; }
53
0
  int extended_model() const { return ext_model_; }
54
0
  int extended_family() const { return ext_family_; }
55
0
  bool has_mmx() const { return has_mmx_; }
56
0
  bool has_sse() const { return has_sse_; }
57
0
  bool has_sse2() const { return has_sse2_; }
58
0
  bool has_sse3() const { return has_sse3_; }
59
0
  bool has_ssse3() const { return has_ssse3_; }
60
0
  bool has_sse41() const { return has_sse41_; }
61
0
  bool has_sse42() const { return has_sse42_; }
62
0
  bool has_avx() const { return has_avx_; }
63
0
  bool has_avx2() const { return has_avx2_; }
64
0
  bool has_aesni() const { return has_aesni_; }
65
0
  bool has_non_stop_time_stamp_counter() const {
66
0
    return has_non_stop_time_stamp_counter_;
67
0
  }
68
  // has_broken_neon is only valid on ARM chips. If true, it indicates that we
69
  // believe that the NEON unit on the current CPU is flawed and cannot execute
70
  // some code. See https://code.google.com/p/chromium/issues/detail?id=341598
71
0
  bool has_broken_neon() const { return has_broken_neon_; }
72
73
  IntelMicroArchitecture GetIntelMicroArchitecture() const;
74
0
  const std::string& cpu_brand() const { return cpu_brand_; }
75
76
 private:
77
  // Query the processor for CPUID information.
78
  void Initialize();
79
80
  int signature_;  // raw form of type, family, model, and stepping
81
  int type_;  // process type
82
  int family_;  // family of the processor
83
  int model_;  // model of processor
84
  int stepping_;  // processor revision number
85
  int ext_model_;
86
  int ext_family_;
87
  bool has_mmx_;
88
  bool has_sse_;
89
  bool has_sse2_;
90
  bool has_sse3_;
91
  bool has_ssse3_;
92
  bool has_sse41_;
93
  bool has_sse42_;
94
  bool has_avx_;
95
  bool has_avx2_;
96
  bool has_aesni_;
97
  bool has_non_stop_time_stamp_counter_;
98
  bool has_broken_neon_;
99
  std::string cpu_vendor_;
100
  std::string cpu_brand_;
101
};
102
103
}  // namespace base
104
105
#endif  // BASE_CPU_H_