2013-12-25 14:21:21 +09:00
|
|
|
// WTFPL
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
2016-12-03 19:04:58 +09:00
|
|
|
#include <cstdint>
|
2013-12-25 14:21:21 +09:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#if defined(__i386__) || defined(_M_IX86)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace spades {
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-12-25 14:21:21 +09:00
|
|
|
enum class CpuFeature {
|
|
|
|
MMX,
|
|
|
|
SSE,
|
|
|
|
SSE2,
|
|
|
|
SSE3,
|
|
|
|
SSSE3,
|
|
|
|
FMA,
|
|
|
|
AVX,
|
|
|
|
AVX2,
|
|
|
|
AVX512CD,
|
|
|
|
AVX512ER,
|
|
|
|
AVX512PF,
|
|
|
|
AVX512F,
|
|
|
|
SimultaneousMT
|
|
|
|
};
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2014-05-03 18:50:29 +09:00
|
|
|
#if defined(__i386__) || defined(_M_IX86) || defined(__amd64__) || defined(__x86_64__)
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-12-25 14:21:21 +09:00
|
|
|
class CpuID {
|
|
|
|
std::string vendor;
|
|
|
|
std::string brand;
|
|
|
|
uint32_t featureEcx;
|
|
|
|
uint32_t featureEdx;
|
|
|
|
uint32_t subfeature;
|
|
|
|
std::string info;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-12-25 14:21:21 +09:00
|
|
|
public:
|
|
|
|
CpuID();
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-12-25 14:21:21 +09:00
|
|
|
bool Supports(CpuFeature feature);
|
2016-12-03 18:23:47 +09:00
|
|
|
|
|
|
|
const std::string &GetVendorId() { return vendor; }
|
|
|
|
const std::string &GetBrand() { return brand; }
|
|
|
|
|
|
|
|
const std::string &GetMiscInfo() { return info; }
|
2013-12-25 14:21:21 +09:00
|
|
|
};
|
|
|
|
#else
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-12-25 14:21:21 +09:00
|
|
|
class CpuID {
|
|
|
|
public:
|
2016-12-03 18:23:47 +09:00
|
|
|
CpuID() {}
|
|
|
|
bool Supports(CpuFeature feature) { return false; }
|
|
|
|
|
2013-12-25 14:21:21 +09:00
|
|
|
std::string GetVendorId() { return "Unknown"; }
|
|
|
|
std::string GetBrand() { return "Unknown"; }
|
|
|
|
std::string GetMiscInfo() { return "(none)"; }
|
|
|
|
};
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-12-25 14:21:21 +09:00
|
|
|
#endif
|
|
|
|
}
|