| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

Functions
instrset_detect.cpp File Reference
`#include "instrset.h"`
Include dependency graph for instrset_detect.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Functions
int | instrset_detect (void)
bool | hasFMA3 (void)
bool | hasFMA4 (void)
bool | hasXOP (void)
bool | hasF16C (void)
bool | hasAVX512ER (void)

## Function Documentation

bool hasAVX512ER | ( | void |  | ) |

Definition at line 186 of file instrset_detect.cpp.

187 {
188 if ( instrset_detect() < 9 ) return false; // must have AVX512F
189 int abcd[4]; // cpuid results
190 cpuid( abcd, 7 ); // call cpuid function 7
191 return ( ( abcd[1] & ( 1 << 27 ) ) != 0 ); // ebx bit 27 indicates AVX512ER
192 }
instrset_detect
int instrset_detect(void)
Definition: instrset_detect.cpp:101
cpuid
#define cpuid(func, eax, ebx, ecx, edx)
Definition: PfmCodeAnalyser.h:20

bool hasF16C | ( | void |  | ) |

Definition at line 177 of file instrset_detect.cpp.

178 {
179 if ( instrset_detect() < 7 ) return false; // must have AVX
180 int abcd[4]; // cpuid results
181 cpuid( abcd, 1 ); // call cpuid function 1
182 return ( ( abcd[2] & ( 1 << 29 ) ) != 0 ); // ecx bit 29 indicates F16C
183 }
instrset_detect
int instrset_detect(void)
Definition: instrset_detect.cpp:101
cpuid
#define cpuid(func, eax, ebx, ecx, edx)
Definition: PfmCodeAnalyser.h:20

bool hasFMA3 | ( | void |  | ) |

Definition at line 150 of file instrset_detect.cpp.

151 {
152 if ( instrset_detect() < 7 ) return false; // must have AVX
153 int abcd[4]; // cpuid results
154 cpuid( abcd, 1 ); // call cpuid function 1
155 return ( ( abcd[2] & ( 1 << 12 ) ) != 0 ); // ecx bit 12 indicates FMA3
156 }
instrset_detect
int instrset_detect(void)
Definition: instrset_detect.cpp:101
cpuid
#define cpuid(func, eax, ebx, ecx, edx)
Definition: PfmCodeAnalyser.h:20

bool hasFMA4 | ( | void |  | ) |

Definition at line 159 of file instrset_detect.cpp.

160 {
161 if ( instrset_detect() < 7 ) return false; // must have AVX
162 int abcd[4]; // cpuid results
163 cpuid( abcd, 0x80000001 ); // call cpuid function 0x80000001
164 return ( ( abcd[2] & ( 1 << 16 ) ) != 0 ); // ecx bit 16 indicates FMA4
165 }
instrset_detect
int instrset_detect(void)
Definition: instrset_detect.cpp:101
cpuid
#define cpuid(func, eax, ebx, ecx, edx)
Definition: PfmCodeAnalyser.h:20

bool hasXOP | ( | void |  | ) |

Definition at line 168 of file instrset_detect.cpp.

169 {
170 if ( instrset_detect() < 7 ) return false; // must have AVX
171 int abcd[4]; // cpuid results
172 cpuid( abcd, 0x80000001 ); // call cpuid function 0x80000001
173 return ( ( abcd[2] & ( 1 << 11 ) ) != 0 ); // ecx bit 11 indicates XOP
174 }
instrset_detect
int instrset_detect(void)
Definition: instrset_detect.cpp:101
cpuid
#define cpuid(func, eax, ebx, ecx, edx)
Definition: PfmCodeAnalyser.h:20

int instrset_detect | ( | void |  | ) |

Definition at line 101 of file instrset_detect.cpp.

102 {
103
104 static int iset = -1; // remember value for next call
105 if ( iset >= 0 ) {
106 return iset; // called before
107 }
108 iset = 0; // default value
109 int abcd[4] = {0, 0, 0, 0}; // cpuid results
110 cpuid( abcd, 0 ); // call cpuid function 0
111 if ( abcd[0] == 0 ) return iset; // no further cpuid function supported
112 cpuid( abcd, 1 ); // call cpuid function 1 for feature flags
113 if ( ( abcd[3] & ( 1 << 0 ) ) == 0 ) return iset; // no floating point
114 if ( ( abcd[3] & ( 1 << 23 ) ) == 0 ) return iset; // no MMX
115 if ( ( abcd[3] & ( 1 << 15 ) ) == 0 ) return iset; // no conditional move
116 if ( ( abcd[3] & ( 1 << 24 ) ) == 0 ) return iset; // no FXSAVE
117 if ( ( abcd[3] & ( 1 << 25 ) ) == 0 ) return iset; // no SSE
118 iset = 1; // 1: SSE supported
119 if ( ( abcd[3] & ( 1 << 26 ) ) == 0 ) return iset; // no SSE2
120 iset = 2; // 2: SSE2 supported
121 if ( ( abcd[2] & ( 1 << 0 ) ) == 0 ) return iset; // no SSE3
122 iset = 3; // 3: SSE3 supported
123 if ( ( abcd[2] & ( 1 << 9 ) ) == 0 ) return iset; // no SSSE3
124 iset = 4; // 4: SSSE3 supported
125 if ( ( abcd[2] & ( 1 << 19 ) ) == 0 ) return iset; // no SSE4.1
126 iset = 5; // 5: SSE4.1 supported
127 if ( ( abcd[2] & ( 1 << 23 ) ) == 0 ) return iset; // no POPCNT
128 if ( ( abcd[2] & ( 1 << 20 ) ) == 0 ) return iset; // no SSE4.2
129 iset = 6; // 6: SSE4.2 supported
130 if ( ( abcd[2] & ( 1 << 27 ) ) == 0 ) return iset; // no OSXSAVE
131 if ( ( xgetbv( 0 ) & 6 ) != 6 ) return iset; // AVX not enabled in O.S.
132 if ( ( abcd[2] & ( 1 << 28 ) ) == 0 ) return iset; // no AVX
133 iset = 7; // 7: AVX supported
134 cpuid( abcd, 7 ); // call cpuid leaf 7 for feature flags
135 if ( ( abcd[1] & ( 1 << 5 ) ) == 0 ) return iset; // no AVX2
136 iset = 8;
137 if ( ( abcd[1] & ( 1 << 16 ) ) == 0 ) return iset; // no AVX512
138 cpuid( abcd, 0xD ); // call cpuid leaf 0xD for feature flags
139 if ( ( abcd[0] & 0x60 ) != 0x60 ) return iset; // no AVX512
140 iset = 9;
141 cpuid( abcd, 7 ); // call cpuid leaf 7 for feature flags
142 if ( ( abcd[1] & ( 1 << 31 ) ) == 0 ) return iset; // no AVX512VL
143 iset = 10;
144 if ( ( abcd[1] & 0x40020000 ) != 0x40020000 ) return iset; // no AVX512BW, AVX512DQ
145 iset = 11;
146 return iset;
147 }
cpuid
#define cpuid(func, eax, ebx, ecx, edx)
Definition: PfmCodeAnalyser.h:20