2010-04-15 18:33:04 -07:00
|
|
|
#include <stdio.h>
|
2013-06-14 06:37:16 -07:00
|
|
|
#define XBYAK_NO_OP_NAMES
|
2010-04-15 18:33:04 -07:00
|
|
|
#include "xbyak/xbyak_util.h"
|
|
|
|
|
|
|
|
#define NUM_OF_ARRAY(x) (sizeof(x) / sizeof(x[0]))
|
|
|
|
|
2011-02-04 00:22:38 -07:00
|
|
|
struct PopCountTest : public Xbyak::CodeGenerator {
|
|
|
|
PopCountTest(int n)
|
|
|
|
{
|
|
|
|
mov(eax, n);
|
|
|
|
popcnt(eax, eax);
|
|
|
|
ret();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-04-15 18:33:04 -07:00
|
|
|
void putCPUinfo()
|
|
|
|
{
|
|
|
|
using namespace Xbyak::util;
|
|
|
|
Cpu cpu;
|
|
|
|
printf("vendor %s\n", cpu.has(Cpu::tINTEL) ? "intel" : "amd");
|
|
|
|
static const struct {
|
|
|
|
Cpu::Type type;
|
|
|
|
const char *str;
|
|
|
|
} tbl[] = {
|
|
|
|
{ Cpu::tMMX, "mmx" },
|
|
|
|
{ Cpu::tMMX2, "mmx2" },
|
|
|
|
{ Cpu::tCMOV, "cmov" },
|
|
|
|
{ Cpu::tSSE, "sse" },
|
|
|
|
{ Cpu::tSSE2, "sse2" },
|
|
|
|
{ Cpu::tSSE3, "sse3" },
|
|
|
|
{ Cpu::tSSSE3, "ssse3" },
|
|
|
|
{ Cpu::tSSE41, "sse41" },
|
|
|
|
{ Cpu::tSSE42, "sse42" },
|
|
|
|
{ Cpu::tPOPCNT, "popcnt" },
|
|
|
|
{ Cpu::t3DN, "3dn" },
|
|
|
|
{ Cpu::tE3DN, "e3dn" },
|
|
|
|
{ Cpu::tSSE4a, "sse4a" },
|
|
|
|
{ Cpu::tSSE5, "sse5" },
|
2011-02-04 00:22:38 -07:00
|
|
|
{ Cpu::tAESNI, "aesni" },
|
|
|
|
{ Cpu::tRDTSCP, "rdtscp" },
|
2011-03-23 23:48:58 -07:00
|
|
|
{ Cpu::tOSXSAVE, "osxsave(xgetvb)" },
|
2011-02-04 00:22:38 -07:00
|
|
|
{ Cpu::tPCLMULQDQ, "pclmulqdq" },
|
|
|
|
{ Cpu::tAVX, "avx" },
|
|
|
|
{ Cpu::tFMA, "fma" },
|
2013-05-30 00:46:13 -07:00
|
|
|
{ Cpu::tAVX2, "avx2" },
|
2013-08-23 14:33:53 -07:00
|
|
|
{ Cpu::tBMI1, "bmi1" },
|
|
|
|
{ Cpu::tBMI2, "bmi2" },
|
2013-05-30 01:03:40 -07:00
|
|
|
{ Cpu::tLZCNT, "lzcnt" },
|
2017-08-07 15:13:35 -07:00
|
|
|
{ Cpu::tPREFETCHW, "prefetchw" },
|
2013-09-05 06:10:49 -07:00
|
|
|
{ Cpu::tENHANCED_REP, "enh_rep" },
|
2014-04-10 14:30:46 -07:00
|
|
|
{ Cpu::tRDRAND, "rdrand" },
|
2015-01-27 20:38:08 -07:00
|
|
|
{ Cpu::tADX, "adx" },
|
2015-01-27 21:05:24 -07:00
|
|
|
{ Cpu::tRDSEED, "rdseed" },
|
|
|
|
{ Cpu::tSMAP, "smap" },
|
|
|
|
{ Cpu::tHLE, "hle" },
|
2015-01-27 21:16:44 -07:00
|
|
|
{ Cpu::tRTM, "rtm" },
|
2017-08-08 03:08:41 -07:00
|
|
|
{ Cpu::tMPX, "mpx" },
|
|
|
|
{ Cpu::tSHA, "sha" },
|
2017-01-25 14:38:59 -07:00
|
|
|
{ Cpu::tPREFETCHWT1, "prefetchwt1" },
|
2015-05-23 22:44:45 -07:00
|
|
|
{ Cpu::tF16C, "f16c" },
|
2015-06-15 19:43:09 -07:00
|
|
|
{ Cpu::tMOVBE, "movbe" },
|
2016-05-04 20:14:04 -07:00
|
|
|
{ Cpu::tAVX512F, "avx512f" },
|
|
|
|
{ Cpu::tAVX512DQ, "avx512dq" },
|
2017-12-29 18:22:48 -07:00
|
|
|
{ Cpu::tAVX512IFMA, "avx512_ifma" },
|
2016-05-04 20:14:04 -07:00
|
|
|
{ Cpu::tAVX512PF, "avx512pf" },
|
|
|
|
{ Cpu::tAVX512ER, "avx512er" },
|
|
|
|
{ Cpu::tAVX512CD, "avx512cd" },
|
|
|
|
{ Cpu::tAVX512BW, "avx512bw" },
|
|
|
|
{ Cpu::tAVX512VL, "avx512vl" },
|
2017-12-29 18:22:48 -07:00
|
|
|
{ Cpu::tAVX512VBMI, "avx512_vbmi" },
|
2016-11-26 18:11:06 -07:00
|
|
|
{ Cpu::tAVX512_4VNNIW, "avx512_4vnniw" },
|
2016-11-26 05:02:55 -07:00
|
|
|
{ Cpu::tAVX512_4FMAPS, "avx512_4fmaps" },
|
2017-12-29 18:22:48 -07:00
|
|
|
|
|
|
|
{ Cpu::tAVX512_VBMI2, "avx512_vbmi2" },
|
|
|
|
{ Cpu::tGFNI, "gfni" },
|
|
|
|
{ Cpu::tVAES, "vaes" },
|
|
|
|
{ Cpu::tVPCLMULQDQ, "vpclmulqdq" },
|
|
|
|
{ Cpu::tAVX512_VNNI, "avx512_vnni" },
|
|
|
|
{ Cpu::tAVX512_BITALG, "avx512_bitalg" },
|
|
|
|
{ Cpu::tAVX512_VPOPCNTDQ, "avx512_vpopcntdq" },
|
2019-05-23 23:08:19 -07:00
|
|
|
{ Cpu::tAVX512_BF16, "avx512_bf16" },
|
|
|
|
{ Cpu::tAVX512_VP2INTERSECT, "avx512_vp2intersect" },
|
2010-04-15 18:33:04 -07:00
|
|
|
};
|
|
|
|
for (size_t i = 0; i < NUM_OF_ARRAY(tbl); i++) {
|
|
|
|
if (cpu.has(tbl[i].type)) printf(" %s", tbl[i].str);
|
|
|
|
}
|
|
|
|
printf("\n");
|
2011-02-04 00:22:38 -07:00
|
|
|
if (cpu.has(Cpu::tPOPCNT)) {
|
|
|
|
const int n = 0x12345678; // bitcount = 13
|
|
|
|
const int ok = 13;
|
2013-01-12 02:03:39 -07:00
|
|
|
int r = PopCountTest(n).getCode<int (*)()>()();
|
2011-02-04 00:22:38 -07:00
|
|
|
if (r == ok) {
|
|
|
|
puts("popcnt ok");
|
|
|
|
} else {
|
|
|
|
printf("popcnt ng %d %d\n", r, ok);
|
|
|
|
}
|
|
|
|
}
|
2013-04-10 18:07:58 -07:00
|
|
|
/*
|
|
|
|
displayFamily displayModel
|
|
|
|
Opteron 2376 10 4
|
|
|
|
Core2 Duo T7100 6 F
|
|
|
|
Core i3-2120T 6 2A
|
|
|
|
Core i7-2600 6 2A
|
|
|
|
Xeon X5650 6 2C
|
|
|
|
Core i7-3517 6 3A
|
|
|
|
Core i7-3930K 6 2D
|
|
|
|
*/
|
|
|
|
cpu.putFamily();
|
2019-01-16 21:45:25 -07:00
|
|
|
if (!cpu.has(Cpu::tINTEL)) return;
|
2018-02-12 20:03:43 -07:00
|
|
|
for (unsigned int i = 0; i < cpu.getDataCacheLevels(); i++) {
|
|
|
|
printf("cache level=%u data cache size=%u cores sharing data cache=%u\n", i, cpu.getDataCacheSize(i), cpu.getCoresSharingDataCache(i));
|
|
|
|
}
|
2019-01-16 21:45:25 -07:00
|
|
|
printf("SmtLevel =%u\n", cpu.getNumCores(Xbyak::util::SmtLevel));
|
|
|
|
printf("CoreLevel=%u\n", cpu.getNumCores(Xbyak::util::CoreLevel));
|
2010-04-15 18:33:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
#ifdef XBYAK32
|
|
|
|
puts("32bit");
|
|
|
|
#else
|
|
|
|
puts("64bit");
|
|
|
|
#endif
|
|
|
|
putCPUinfo();
|
|
|
|
}
|