#include <iostream>
#include <immintrin.h>
// Verify CPU capabilities:
bool bAVXok = false;
int cpuInfo[4] = { 0,0,0,0 };
__cpuid(cpuInfo, 0);
if (cpuInfo[0] != 0) {
__cpuid(cpuInfo, 1);
if (cpuInfo[2] & (1 << 28)) {
bAVXok = true; // Note: this test only confirms CPU AVX capability, and does not check OS capability.
// to-do: check for AVX2 ...
}
}
if (bAVXok)
std::cout << "CPU supports AVX (ok)";
else {
std::cout << "Your CPU doesn't support AVX - please try a non-AVX build on this machine" << std::endl;
exit(EXIT_FAILURE);
}
Sample code to check if CPU supports AVX instructions. (Examples on MSDN and Intel are very big and complicated)
I will probably update this later for AVX2 and also OS support ...
I will probably update this later for AVX2 and also OS support ...
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.