SMIL  0.9.1
DCpuID.h
1 /*
2  * Copyright (c) 2011-2016, Matthieu FAESSEL and ARMINES
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of Matthieu FAESSEL, or ARMINES nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _DCPUID_H
30 #define _DCPUID_H
31 
32 #include "DTypes.h"
33 
34 #include <string>
35 #include <vector>
36 
37 namespace smil
38 {
40  {
41  bool MMX;
42  bool SSE;
43  bool SSE2;
44  bool SSE3;
45  bool SSSE3;
46  bool SSE41;
47  bool SSE42;
48  bool AES;
49  bool AVX;
50  };
51 
52  // Associativity.
53  enum { WDISABLED, W1, W2, W4=4, W8=6, W16=8, W32=10, W48, W64, W96, W128, WFULL };
54 
55  // Data cache information.
57  {
58  int type; // 1 : data, 2 : instructions, 3 : unified
59  int size;
60  int sets; // ???
61  int associativity;
62  int lines_per_tag;
63  int line_size;
64  };
65 
66  class CpuID
67  {
68 
69  public:
70 
71  CpuID();
72 
73  string getVendor() const { return vendor; }
74  unsigned getCores() const { return cores; }
75  unsigned getLogical() const { return logical; }
76  bool isHyperThreated() const { return hyperThreaded; }
77  const SIMD_Instructions &getSimdInstructions() const { return simdInstructions; }
78  const std::vector<Cache_Descriptors> &getCaches() const {
79  return L;
80  }
81  unsigned int getNbrCacheLevel() const { return L.size (); }
82 
83  protected:
84  UINT32 regs[4];
85  UINT32 &eax, &ebx, &ecx, &edx;
86  unsigned eaxFeatures, edxFeatures, ecxFeatures, ebxFeatures;
87 
88  unsigned cores;
89  unsigned logical;
90  string vendor;
91  bool hyperThreaded;
92  SIMD_Instructions simdInstructions;
93  std::vector<Cache_Descriptors> L;
94 
95  void load(unsigned i);
96 
97  };
98 } // namespace smil
99 
100 #endif // _DCPUID_H
Definition: DColorConvert.h:38
Definition: DCpuID.h:56
Definition: DCpuID.h:66
Definition: DCpuID.h:39