Compute Library
 21.08
CPPTypes.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2021 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef ARM_COMPUTE_CPP_TYPES_H
25 #define ARM_COMPUTE_CPP_TYPES_H
26 
27 #include "arm_compute/core/Error.h"
28 
29 #include <memory>
30 
31 namespace arm_compute
32 {
33 #define ARM_COMPUTE_CPU_MODEL_LIST \
34  X(GENERIC) \
35  X(GENERIC_FP16) \
36  X(GENERIC_FP16_DOT) \
37  X(A53) \
38  X(A55r0) \
39  X(A55r1) \
40  X(A35) \
41  X(A73) \
42  X(A510) \
43  X(X1) \
44  X(V1) \
45  X(A64FX)
46 
47 /** CPU models types
48  *
49  * @note We only need to detect CPUs we have microarchitecture-specific code for.
50  * @note Architecture features are detected via HWCAPs.
51  */
52 enum class CPUModel
53 {
54 #define X(model) model,
56 #undef X
57 };
58 
59 class CPUInfo final
60 {
61 protected:
62  CPUInfo();
63  ~CPUInfo();
64 
65 public:
66  /** Access the KernelLibrary singleton.
67  * This method has been deprecated and will be removed in future releases
68  * @return The KernelLibrary instance.
69  */
70  static CPUInfo &get();
71 
72  /* Delete move and copy constructors and assignment operator
73  s */
74  CPUInfo(CPUInfo const &) = delete; // Copy construct
75  CPUInfo(CPUInfo &&) = delete; // Move construct
76  CPUInfo &operator=(CPUInfo const &) = delete; // Copy assign
77  CPUInfo &operator=(CPUInfo &&) = delete; // Move assign
78 
79  /** Checks if the cpu model supports fp16.
80  *
81  * @return true of the cpu supports fp16, false otherwise
82  */
83  bool has_fp16() const;
84  /** Checks if the cpu model supports bf16.
85  *
86  * @return true of the cpu supports bf16, false otherwise
87  */
88  bool has_bf16() const;
89  /** Checks if the cpu model supports bf16.
90  *
91  * @return true of the cpu supports bf16, false otherwise
92  */
93  bool has_svebf16() const;
94  /** Checks if the cpu model supports dot product.
95  *
96  * @return true of the cpu supports dot product, false otherwise
97  */
98  bool has_dotprod() const;
99  /** Checks if the cpu model supports floating-point matrix multiplication.
100  *
101  * @return true of the cpu supports floating-point matrix multiplication, false otherwise
102  */
103  bool has_svef32mm() const;
104  /** Checks if the cpu model supports integer matrix multiplication.
105  *
106  * @return true of the cpu supports integer matrix multiplication, false otherwise
107  */
108  bool has_i8mm() const;
109  /** Checks if the cpu model supports integer matrix multiplication.
110  *
111  * @return true of the cpu supports integer matrix multiplication, false otherwise
112  */
113  bool has_svei8mm() const;
114  /** Checks if the cpu model supports sve.
115  *
116  * @return true of the cpu supports sve, false otherwise
117  */
118  bool has_sve() const;
119  /** Checks if the cpu model supports sve2.
120  *
121  * @return true of the cpu supports sve2, false otherwise
122  */
123  bool has_sve2() const;
124  /** Gets the cpu model for a given cpuid.
125  *
126  * @param[in] cpuid the id of the cpu core to be retrieved,
127  *
128  * @return the @ref CPUModel of the cpuid queiried.
129  */
130  CPUModel get_cpu_model(unsigned int cpuid) const;
131  /** Gets the current thread's cpu model
132  *
133  * @return Current thread's @ref CPUModel
134  */
135  CPUModel get_cpu_model() const;
136  /** Gets the L1 cache size
137  *
138  * @return the size of the L1 cache
139  */
140  unsigned int get_L1_cache_size() const;
141  /** Gets the L2 cache size
142  *
143  * @return the size of the L1 cache
144  */
145  unsigned int get_L2_cache_size() const;
146  /** Return the maximum number of CPUs present
147  *
148  * @return Number of CPUs
149  */
150  unsigned int get_cpu_num() const;
151 
152 private:
153  struct Impl;
154  std::unique_ptr<Impl> _impl;
155 };
156 
157 /** Information about executing thread and CPU. */
159 {
160  int thread_id{ 0 };
161  int num_threads{ 1 };
162  const CPUInfo *cpu_info{ nullptr };
163 };
164 } // namespace arm_compute
165 #endif /* ARM_COMPUTE_CPP_TYPES_H */
CPUModel
CPU models types.
Definition: CPPTypes.h:52
arm_compute::CPUInfo CPUInfo
Copyright (c) 2017-2021 Arm Limited.
#define ARM_COMPUTE_CPU_MODEL_LIST
Definition: CPPTypes.h:33
Information about executing thread and CPU.
Definition: CPPTypes.h:158