2020-04-22 21:25:57 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#define XBYAK_NO_OP_NAMES
|
|
|
|
#include "xbyak/xbyak_util.h"
|
|
|
|
|
|
|
|
#define NUM_OF_ARRAY(x) (sizeof(x) / sizeof(x[0]))
|
|
|
|
|
|
|
|
struct PopCountTest : public Xbyak::CodeGenerator {
|
|
|
|
PopCountTest(int n)
|
|
|
|
{
|
|
|
|
mov(eax, n);
|
|
|
|
popcnt(eax, eax);
|
|
|
|
ret();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
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" },
|
|
|
|
{ Cpu::tAESNI, "aesni" },
|
|
|
|
{ Cpu::tRDTSCP, "rdtscp" },
|
|
|
|
{ Cpu::tOSXSAVE, "osxsave(xgetvb)" },
|
|
|
|
{ Cpu::tPCLMULQDQ, "pclmulqdq" },
|
|
|
|
{ Cpu::tAVX, "avx" },
|
|
|
|
{ Cpu::tFMA, "fma" },
|
|
|
|
{ Cpu::tAVX2, "avx2" },
|
|
|
|
{ Cpu::tBMI1, "bmi1" },
|
|
|
|
{ Cpu::tBMI2, "bmi2" },
|
|
|
|
{ Cpu::tLZCNT, "lzcnt" },
|
|
|
|
{ Cpu::tPREFETCHW, "prefetchw" },
|
|
|
|
{ Cpu::tENHANCED_REP, "enh_rep" },
|
|
|
|
{ Cpu::tRDRAND, "rdrand" },
|
|
|
|
{ Cpu::tADX, "adx" },
|
|
|
|
{ Cpu::tRDSEED, "rdseed" },
|
|
|
|
{ Cpu::tSMAP, "smap" },
|
|
|
|
{ Cpu::tHLE, "hle" },
|
|
|
|
{ Cpu::tRTM, "rtm" },
|
|
|
|
{ Cpu::tMPX, "mpx" },
|
|
|
|
{ Cpu::tSHA, "sha" },
|
|
|
|
{ Cpu::tPREFETCHWT1, "prefetchwt1" },
|
|
|
|
{ Cpu::tF16C, "f16c" },
|
|
|
|
{ Cpu::tMOVBE, "movbe" },
|
|
|
|
{ Cpu::tAVX512F, "avx512f" },
|
|
|
|
{ Cpu::tAVX512DQ, "avx512dq" },
|
Squashed 'externals/xbyak/' changes from d512551e..2794cde7
2794cde7 add xword, yword, etc. in Xbyak::util
fb9c04e4 fix document for vfpclassps
a51be78b fix test dependency
04fdfb1e update version
e6354f8b add vgf2p8mulb
09a12642 add gf2p8affineqb
d171ba0e add gf2p8affineinvqb
457f4fd0 add vpshufbitqmb
5af0ba39 add vpexpand{b,w}
e450f965 vpopcnt{d,q} supports ptr_b
48499eb1 add vpdpbusd(s), vpdpwssd(s)
9c745109 add vpdpbusd, vpdpbusds
0e1a11b4 add vpopcnt{b,w,d,q}
9acfc132 add vpshrd(v){w,d,q}
ac8de850 add vpshld(v){w,d,q}
f181c259 add vcompressb, vcompressw
5a402477 vpclmulqdq supports AVX-512
9e16b40b vaes* supports AVX-512
7fde08e0 add flags for intel's manual 319433-030.pdf
c5da3778 add test of v4fmaddps, vp4dpwssd, etc.
e4fc9d8a fix mpx encoding
d0b2fb62 add bnd(0xf2) prefix for MPX
f12b5678 use db for array
cd74ab44 remove bat file
git-subtree-dir: externals/xbyak
git-subtree-split: 2794cde79eb71e86490061cac9622ad0067b8d15
2020-04-22 21:45:52 +02:00
|
|
|
{ Cpu::tAVX512IFMA, "avx512_ifma" },
|
2020-04-22 21:25:57 +02:00
|
|
|
{ Cpu::tAVX512PF, "avx512pf" },
|
|
|
|
{ Cpu::tAVX512ER, "avx512er" },
|
|
|
|
{ Cpu::tAVX512CD, "avx512cd" },
|
|
|
|
{ Cpu::tAVX512BW, "avx512bw" },
|
|
|
|
{ Cpu::tAVX512VL, "avx512vl" },
|
Squashed 'externals/xbyak/' changes from d512551e..2794cde7
2794cde7 add xword, yword, etc. in Xbyak::util
fb9c04e4 fix document for vfpclassps
a51be78b fix test dependency
04fdfb1e update version
e6354f8b add vgf2p8mulb
09a12642 add gf2p8affineqb
d171ba0e add gf2p8affineinvqb
457f4fd0 add vpshufbitqmb
5af0ba39 add vpexpand{b,w}
e450f965 vpopcnt{d,q} supports ptr_b
48499eb1 add vpdpbusd(s), vpdpwssd(s)
9c745109 add vpdpbusd, vpdpbusds
0e1a11b4 add vpopcnt{b,w,d,q}
9acfc132 add vpshrd(v){w,d,q}
ac8de850 add vpshld(v){w,d,q}
f181c259 add vcompressb, vcompressw
5a402477 vpclmulqdq supports AVX-512
9e16b40b vaes* supports AVX-512
7fde08e0 add flags for intel's manual 319433-030.pdf
c5da3778 add test of v4fmaddps, vp4dpwssd, etc.
e4fc9d8a fix mpx encoding
d0b2fb62 add bnd(0xf2) prefix for MPX
f12b5678 use db for array
cd74ab44 remove bat file
git-subtree-dir: externals/xbyak
git-subtree-split: 2794cde79eb71e86490061cac9622ad0067b8d15
2020-04-22 21:45:52 +02:00
|
|
|
{ Cpu::tAVX512VBMI, "avx512_vbmi" },
|
2020-04-22 21:25:57 +02:00
|
|
|
{ Cpu::tAVX512_4VNNIW, "avx512_4vnniw" },
|
|
|
|
{ Cpu::tAVX512_4FMAPS, "avx512_4fmaps" },
|
Squashed 'externals/xbyak/' changes from d512551e..2794cde7
2794cde7 add xword, yword, etc. in Xbyak::util
fb9c04e4 fix document for vfpclassps
a51be78b fix test dependency
04fdfb1e update version
e6354f8b add vgf2p8mulb
09a12642 add gf2p8affineqb
d171ba0e add gf2p8affineinvqb
457f4fd0 add vpshufbitqmb
5af0ba39 add vpexpand{b,w}
e450f965 vpopcnt{d,q} supports ptr_b
48499eb1 add vpdpbusd(s), vpdpwssd(s)
9c745109 add vpdpbusd, vpdpbusds
0e1a11b4 add vpopcnt{b,w,d,q}
9acfc132 add vpshrd(v){w,d,q}
ac8de850 add vpshld(v){w,d,q}
f181c259 add vcompressb, vcompressw
5a402477 vpclmulqdq supports AVX-512
9e16b40b vaes* supports AVX-512
7fde08e0 add flags for intel's manual 319433-030.pdf
c5da3778 add test of v4fmaddps, vp4dpwssd, etc.
e4fc9d8a fix mpx encoding
d0b2fb62 add bnd(0xf2) prefix for MPX
f12b5678 use db for array
cd74ab44 remove bat file
git-subtree-dir: externals/xbyak
git-subtree-split: 2794cde79eb71e86490061cac9622ad0067b8d15
2020-04-22 21:45:52 +02: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" },
|
2020-04-22 21:25:57 +02: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");
|
|
|
|
if (cpu.has(Cpu::tPOPCNT)) {
|
|
|
|
const int n = 0x12345678; // bitcount = 13
|
|
|
|
const int ok = 13;
|
|
|
|
int r = PopCountTest(n).getCode<int (*)()>()();
|
|
|
|
if (r == ok) {
|
|
|
|
puts("popcnt ok");
|
|
|
|
} else {
|
|
|
|
printf("popcnt ng %d %d\n", r, ok);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
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();
|
2020-04-22 21:59:14 +02:00
|
|
|
if (!cpu.has(Cpu::tINTEL)) return;
|
2020-04-22 21:51:10 +02: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));
|
|
|
|
}
|
2020-04-22 21:59:14 +02:00
|
|
|
printf("SmtLevel =%u\n", cpu.getNumCores(Xbyak::util::SmtLevel));
|
|
|
|
printf("CoreLevel=%u\n", cpu.getNumCores(Xbyak::util::CoreLevel));
|
2020-04-22 21:25:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
#ifdef XBYAK32
|
|
|
|
puts("32bit");
|
|
|
|
#else
|
|
|
|
puts("64bit");
|
|
|
|
#endif
|
|
|
|
putCPUinfo();
|
|
|
|
}
|