forked from yvt/terravox
-
Notifications
You must be signed in to change notification settings - Fork 2
/
cpu.h
50 lines (44 loc) · 797 Bytes
/
cpu.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef CPU_H
#define CPU_H
#include <xmmintrin.h>
namespace CpuId
{
enum class Feature
{
Mmx,
Sse,
Sse2,
Sse3,
Ssse3,
Sse41,
Sse42,
Sse4a,
Avx,
F16c,
Lzcnt,
Popcnt,
Prefetchw
};
template <class...T>
bool supports(Feature feature, T...rest)
{
return supports(feature) && supports<>(rest...);
}
template<>
bool supports(Feature feature);
}
class SseRoundingModeScope
{
unsigned int oldMode;
public:
SseRoundingModeScope(unsigned int newMode) :
oldMode(_MM_GET_ROUNDING_MODE())
{
_MM_SET_ROUNDING_MODE(newMode);
}
~SseRoundingModeScope()
{
_MM_SET_ROUNDING_MODE(oldMode);
}
};
#endif // CPU_H