Skip to content

Commit

Permalink
add detection of avx10/apx_f
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Dec 14, 2023
1 parent 835f6d2 commit 5315658
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sample/test_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions xbyak/xbyak_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand All @@ -481,6 +484,7 @@ class Cpu {
, dataCacheSize_()
, coresSharignDataCache_()
, dataCacheLevels_(0)
, avx10version_(0)
{
uint32_t data[4] = {};
const uint32_t& EAX = data[0];
Expand Down Expand Up @@ -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();
Expand All @@ -645,6 +655,7 @@ class Cpu {
{
return (type & type_) == type;
}
int getAVX10version() const { return avx10version_; }
};

#ifndef XBYAK_ONLY_CLASS_CPU
Expand Down

0 comments on commit 5315658

Please sign in to comment.