2019-02-16 13:05:13 +00:00
|
|
|
|
#pragma once
|
2017-07-18 12:21:29 +00:00
|
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
namespace utils
|
|
|
|
|
{
|
|
|
|
|
inline std::array<u32, 4> get_cpuid(u32 func, u32 subfunc)
|
|
|
|
|
{
|
|
|
|
|
int regs[4];
|
2017-12-16 00:19:21 +00:00
|
|
|
|
#ifdef _MSC_VER
|
2017-07-18 12:21:29 +00:00
|
|
|
|
__cpuidex(regs, func, subfunc);
|
2017-12-16 00:19:21 +00:00
|
|
|
|
#else
|
2017-07-18 12:21:29 +00:00
|
|
|
|
__asm__ volatile("cpuid" : "=a" (regs[0]), "=b" (regs[1]), "=c" (regs[2]), "=d" (regs[3]) : "a" (func), "c" (subfunc));
|
2017-12-16 00:19:21 +00:00
|
|
|
|
#endif
|
2017-07-18 12:21:29 +00:00
|
|
|
|
return {0u+regs[0], 0u+regs[1], 0u+regs[2], 0u+regs[3]};
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-23 22:08:13 +00:00
|
|
|
|
inline u64 get_xgetbv(u32 xcr)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
return _xgetbv(xcr);
|
|
|
|
|
#else
|
|
|
|
|
u32 eax, edx;
|
|
|
|
|
__asm__ volatile( "xgetbv" : "=a"(eax), "=d"(edx) : "c"(xcr));
|
|
|
|
|
return eax | (u64(edx) << 32);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-09 17:33:18 +00:00
|
|
|
|
bool has_ssse3();
|
2017-07-18 12:21:29 +00:00
|
|
|
|
|
2018-04-09 14:45:37 +00:00
|
|
|
|
bool has_sse41();
|
|
|
|
|
|
2017-11-09 17:33:18 +00:00
|
|
|
|
bool has_avx();
|
2017-07-18 12:21:29 +00:00
|
|
|
|
|
2017-12-16 00:19:21 +00:00
|
|
|
|
bool has_avx2();
|
|
|
|
|
|
2017-11-09 17:33:18 +00:00
|
|
|
|
bool has_rtm();
|
2017-07-18 17:03:47 +00:00
|
|
|
|
|
2019-06-01 03:34:46 +00:00
|
|
|
|
bool has_tsx_force_abort();
|
|
|
|
|
|
2018-06-13 11:54:16 +00:00
|
|
|
|
bool has_mpx();
|
|
|
|
|
|
2017-12-16 00:19:21 +00:00
|
|
|
|
bool has_512();
|
|
|
|
|
|
2018-01-16 11:32:57 +00:00
|
|
|
|
bool has_xop();
|
|
|
|
|
|
2019-11-14 16:09:34 +00:00
|
|
|
|
bool has_clwb();
|
|
|
|
|
|
2020-02-20 02:55:25 +00:00
|
|
|
|
std::string get_cpu_brand();
|
|
|
|
|
|
2017-07-18 12:21:29 +00:00
|
|
|
|
std::string get_system_info();
|
2019-02-16 13:05:13 +00:00
|
|
|
|
|
|
|
|
|
std::string get_firmware_version();
|
2019-04-19 12:05:47 +00:00
|
|
|
|
|
|
|
|
|
std::string get_OS_version();
|
2019-07-15 14:20:12 +00:00
|
|
|
|
|
|
|
|
|
ullong get_tsc_freq();
|
2020-02-20 02:55:25 +00:00
|
|
|
|
|
|
|
|
|
u64 get_total_memory();
|
|
|
|
|
|
|
|
|
|
u32 get_thread_count();
|
2017-07-18 12:21:29 +00:00
|
|
|
|
}
|