Loading...
Searching...
No Matches
pot::HostIsa Struct Reference

#include <gpr/potentials/AotiPackageIsa.h>

Static Public Member Functions

static HostIsa detect () noexcept
 CPUID and XGETBV of the calling host; all false off x86-64.

Public Attributes

bool avx2 = false
bool fma = false
bool avx512f = false
bool avx512dq = false
bool avx512bw = false
bool avx512vl = false
bool avx512_vnni = false
bool avx512_bf16 = false
bool amx_tile = false
bool amx_bf16 = false
bool amx_int8 = false

Detailed Description

Extensions of the host CPU that the package ISA tokens refer to, each true only when CPUID reports it and the OS saves its register state.

Definition at line 37 of file AotiPackageIsa.h.

Member Function Documentation

◆ detect()

HostIsa pot::HostIsa::detect ( )
staticnoexcept

CPUID and XGETBV of the calling host; all false off x86-64.

Definition at line 173 of file AotiPackageIsa.cpp.

174{
175 HostIsa host;
176#if defined(__x86_64__) || defined(__i386__)
177 unsigned a = 0, b = 0, c = 0, d = 0;
178 if (!__get_cpuid(1, &a, &b, &c, &d)) return host;
179 const bool osxsave = c & (1u << 27);
180 const bool avx = c & (1u << 28);
181 const bool fma = c & (1u << 12);
182 const std::uint64_t xcr0 = osxsave ? extendedControlRegister() : 0;
183 // The OS saves YMM (bits 1, 2), the AVX-512 opmask and ZMM state
184 // (bits 5 to 7) and the AMX tile state (bits 17, 18).
185 const bool ymm = (xcr0 & 0x6) == 0x6;
186 const bool zmm = ymm && (xcr0 & 0xe0) == 0xe0;
187 const bool tiles = (xcr0 & (3ull << 17)) == (3ull << 17);
188 if (__get_cpuid_max(0, nullptr) < 7) return host;
189 unsigned leaf7a = 0;
190 __cpuid_count(7, 0, leaf7a, b, c, d);
191 host.fma = ymm && avx && fma;
192 host.avx2 = ymm && avx && (b & (1u << 5));
193 host.avx512f = zmm && (b & (1u << 16));
194 host.avx512dq = zmm && (b & (1u << 17));
195 host.avx512bw = zmm && (b & (1u << 30));
196 host.avx512vl = zmm && (b & (1u << 31));
197 host.avx512_vnni = zmm && (c & (1u << 11));
198 host.amx_bf16 = tiles && (d & (1u << 22));
199 host.amx_tile = tiles && (d & (1u << 24));
200 host.amx_int8 = tiles && (d & (1u << 25));
201 if (leaf7a >= 1) {
202 __cpuid_count(7, 1, a, b, c, d);
203 host.avx512_bf16 = zmm && (a & (1u << 5));
204 }
205#endif
206 return host;
207}

Member Data Documentation

◆ amx_bf16

bool pot::HostIsa::amx_bf16 = false

Definition at line 47 of file AotiPackageIsa.h.

◆ amx_int8

bool pot::HostIsa::amx_int8 = false

Definition at line 48 of file AotiPackageIsa.h.

◆ amx_tile

bool pot::HostIsa::amx_tile = false

Definition at line 46 of file AotiPackageIsa.h.

◆ avx2

bool pot::HostIsa::avx2 = false

Definition at line 38 of file AotiPackageIsa.h.

◆ avx512_bf16

bool pot::HostIsa::avx512_bf16 = false

Definition at line 45 of file AotiPackageIsa.h.

◆ avx512_vnni

bool pot::HostIsa::avx512_vnni = false

Definition at line 44 of file AotiPackageIsa.h.

◆ avx512bw

bool pot::HostIsa::avx512bw = false

Definition at line 42 of file AotiPackageIsa.h.

◆ avx512dq

bool pot::HostIsa::avx512dq = false

Definition at line 41 of file AotiPackageIsa.h.

◆ avx512f

bool pot::HostIsa::avx512f = false

Definition at line 40 of file AotiPackageIsa.h.

◆ avx512vl

bool pot::HostIsa::avx512vl = false

Definition at line 43 of file AotiPackageIsa.h.

◆ fma

bool pot::HostIsa::fma = false

Definition at line 39 of file AotiPackageIsa.h.


The documentation for this struct was generated from the following files: