From 5315658ad67791f56296c202fe2acefa9b95d3ae Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Thu, 14 Dec 2023 17:26:26 +0900 Subject: [PATCH] add detection of avx10/apx_f --- sample/test_util.cpp | 5 +++++ xbyak/xbyak_util.h | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/sample/test_util.cpp b/sample/test_util.cpp index 35c2fa84..66869ee9 100644 --- a/sample/test_util.cpp +++ b/sample/test_util.cpp @@ -103,12 +103,17 @@ void putCPUinfo(bool onlyCpuidFeature) { Cpu::tSM3, "sm3" }, { Cpu::tSM4, "sm4" }, { Cpu::tAVX_VNNI_INT16, "avx_vnni_int16" }, + { Cpu::tAPX_F, "apx_f" }, + { Cpu::tAVX10, "avx10" }, }; 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 (onlyCpuidFeature) return; + if (cpu.has(Cpu::tAVX10)) { + printf("AVX10 version %d\n", cpu.getAVX10version()); + } if (cpu.has(Cpu::tPOPCNT)) { const int n = 0x12345678; // bitcount = 13 const int ok = 13; diff --git a/xbyak/xbyak_util.h b/xbyak/xbyak_util.h index 0bcc1349..950cc2d0 100644 --- a/xbyak/xbyak_util.h +++ b/xbyak/xbyak_util.h @@ -144,6 +144,7 @@ class Cpu { uint32_t dataCacheSize_[maxNumberCacheLevels]; uint32_t coresSharignDataCache_[maxNumberCacheLevels]; uint32_t dataCacheLevels_; + uint32_t avx10version_; uint32_t get32bitAsBE(const char *x) const { @@ -470,6 +471,8 @@ class Cpu { XBYAK_DEFINE_TYPE(79, tSM3); XBYAK_DEFINE_TYPE(80, tSM4); XBYAK_DEFINE_TYPE(81, tAVX_VNNI_INT16); + XBYAK_DEFINE_TYPE(82, tAPX_F); + XBYAK_DEFINE_TYPE(83, tAVX10); #undef XBYAK_SPLIT_ID #undef XBYAK_DEFINE_TYPE @@ -481,6 +484,7 @@ class Cpu { , dataCacheSize_() , coresSharignDataCache_() , dataCacheLevels_(0) + , avx10version_(0) { uint32_t data[4] = {}; const uint32_t& EAX = data[0]; @@ -627,8 +631,14 @@ class Cpu { if (EDX & (1U << 5)) type_ |= tAVX_NE_CONVERT; if (EDX & (1U << 10)) type_ |= tAVX_VNNI_INT16; if (EDX & (1U << 14)) type_ |= tPREFETCHITI; + if (EDX & (1U << 19)) type_ |= tAVX10; + if (EDX & (1U << 21)) type_ |= tAPX_F; } } + if (has(tAVX10) && maxNum >= 24) { + getCpuidEx(0x24, 0, data); + avx10version_ = EBX & mask(7); + } setFamily(); setNumCores(); setCacheHierarchy(); @@ -645,6 +655,7 @@ class Cpu { { return (type & type_) == type; } + int getAVX10version() const { return avx10version_; } }; #ifndef XBYAK_ONLY_CLASS_CPU