SMIL
1.0.4
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
{
39
struct
SIMD_Instructions
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
// added 15/10/2021
52
bool
AVX2;
53
bool
AVX512;
54
bool
FMA;
55
};
56
57
// Associativity.
58
enum
{ WDISABLED, W1, W2, W4=4, W8=6, W16=8, W32=10, W48, W64, W96, W128, WFULL };
59
60
// Data cache information.
61
struct
Cache_Descriptors
62
{
63
int
type;
// 1 : data, 2 : instructions, 3 : unified
64
int
size;
65
int
sets;
// ???
66
int
associativity;
67
int
lines_per_tag;
68
int
line_size;
69
};
70
71
class
CpuID
72
{
73
74
public
:
75
76
CpuID
();
77
78
string
getVendor()
const
{
return
vendor; }
79
unsigned
getCores()
const
{
return
cores; }
80
unsigned
getLogical()
const
{
return
logical; }
81
bool
isHyperThreated()
const
{
return
hyperThreaded; }
82
const
SIMD_Instructions
&getSimdInstructions()
const
{
return
simdInstructions; }
83
const
std::vector<Cache_Descriptors> &getCaches()
const
{
84
return
L;
85
}
86
unsigned
int
getNbrCacheLevel()
const
{
return
L.size (); }
87
88
protected
:
89
UINT32 regs[4];
90
UINT32 &eax, &ebx, &ecx, &edx;
91
unsigned
eaxFeatures, edxFeatures, ecxFeatures, ebxFeatures;
92
93
unsigned
cores;
94
unsigned
logical;
95
string
vendor;
96
bool
hyperThreaded;
97
SIMD_Instructions
simdInstructions;
98
std::vector<Cache_Descriptors> L;
99
100
void
load(
unsigned
i);
101
102
};
103
}
// namespace smil
104
105
#endif
// _DCPUID_H
smil::CpuID
Definition:
DCpuID.h:72
smil::Cache_Descriptors
Definition:
DCpuID.h:62
smil::SIMD_Instructions
Definition:
DCpuID.h:40
Core
include
DCpuID.h
Generated on Wed Apr 24 2024 18:57:02 for SMIL by
1.9.1