Visual Servoing Platform  version 3.6.1 under development (2024-10-18)
cpu_x86.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See https://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  */
30 
31 /* cpu_x86.h
32  *
33  * Author : Alexander J. Yee
34  * Date Created : 04/12/2014
35  * Last Modified : 04/12/2014
36  *
37  */
38 
39 #pragma once
40 #ifndef CPU_X86_H
41 #define CPU_X86_H
46 // Dependencies
47 #include <stdint.h>
48 #include <string>
49 #ifndef DOXYGEN_SHOULD_SKIP_THIS
50 namespace FeatureDetector
51 {
56 struct cpuX86
57 {
58  // Vendor
59  bool Vendor_AMD;
60  bool Vendor_Intel;
61 
62  // OS Features
63  bool OS_x64;
64  bool OS_AVX;
65  bool OS_AVX512;
66 
67  // Misc.
68  bool HW_MMX;
69  bool HW_x64;
70  bool HW_ABM;
71  bool HW_RDRAND;
72  bool HW_BMI1;
73  bool HW_BMI2;
74  bool HW_ADX;
75  bool HW_PREFETCHWT1;
76  bool HW_MPX;
77 
78  // SIMD: 128-bit
79  bool HW_SSE;
80  bool HW_SSE2;
81  bool HW_SSE3;
82  bool HW_SSSE3;
83  bool HW_SSE41;
84  bool HW_SSE42;
85  bool HW_SSE4a;
86  bool HW_AES;
87  bool HW_SHA;
88 
89  // SIMD: 256-bit
90  bool HW_AVX;
91  bool HW_XOP;
92  bool HW_FMA3;
93  bool HW_FMA4;
94  bool HW_AVX2;
95 
96  // SIMD: 512-bit
97  bool HW_AVX512_F;
98  bool HW_AVX512_PF;
99  bool HW_AVX512_ER;
100  bool HW_AVX512_CD;
101  bool HW_AVX512_VL;
102  bool HW_AVX512_BW;
103  bool HW_AVX512_DQ;
104  bool HW_AVX512_IFMA;
105  bool HW_AVX512_VBMI;
106 
107 public:
108  cpuX86();
109 
110  void print() const;
111 
112  static void cpuid(uint32_t out[4], uint32_t x);
113  static std::string get_vendor_string();
114 
115 private:
116  void detect_host();
117  static void print(const char *label, bool yes);
118 
119  static bool detect_OS_x64();
120  static bool detect_OS_AVX();
121  static bool detect_OS_AVX512();
122 };
127 } // namespace FeatureDetector
128 #endif
129 #endif