Documentation
¶
Overview ¶
Package cpu implements processor feature detection used by the Go standard library.
Index ¶
Constants ¶
const ( X86Feature_adx = 1 << iota X86Feature_aes X86Feature_erms X86Feature_pclmulqdq X86Feature_rdtscp X86Feature_popcnt X86Feature_sse3 X86Feature_sse41 X86Feature_sse42 X86Feature_ssse3 X86Feature_avx X86Feature_avx2 X86Feature_bmi1 X86Feature_bmi2 X86Feature_fma )
const CacheLinePadSize = 64
const DebugOptions = 0| os.IsAix| os.IsDarwin| os.IsIos| os.IsDragonfly| os.IsFreebsd| os.IsNetbsd| os.IsOpenbsd| os.IsIllumos| os.IsSolaris| os.IsLinux| 0 != 0
DebugOptions is set to true by the runtime if the OS supports reading GODEBUG early in runtime startup. This should not be changed after it is initialized.
Variables ¶
var ( ARM ARMFeatures X86 X86Features ARM64 ARM64Features MIPS64 MIPS64Features PPC64 PPC64Features S390X S390XFeatures WASM WASMFeatures )
Functions ¶
func Initialize ¶
func Initialize(env string)
Initialize examines the processor and sets the relevant variables above. This is called by the runtime package early in program initialization, before normal init functions are run. env is set by runtime if the OS supports cpu feature options in GODEBUG.
Types ¶
type ARM64Features ¶
type ARM64Features uint32
const ( ARM64Feature_aes ARM64Features = 1 << iota ARM64Feature_pmull ARM64Feature_sha1 ARM64Feature_sha2 ARM64Feature_sha512 ARM64Feature_crc32 ARM64Feature_atomics ARM64Feature_cpuid ARM64Feature_is_neoversen1 ARM64Feature_is_zeus )
func (ARM64Features) HasAll ¶
func (x ARM64Features) HasAll(want ARM64Features) bool
type ARMFeatures ¶
type ARMFeatures uint32
const ( ARMFeature_vfpv4 ARMFeatures = 1 << iota ARMFeature_idiva )
func (ARMFeatures) HasAll ¶
func (x ARMFeatures) HasAll(want ARMFeatures) bool
type FeatureChecker ¶
type FeatureSet ¶
type MIPS64Features ¶
type MIPS64Features uint32
const (
MIPS64Feature_msa MIPS64Features = 1 << iota // MIPS SIMD architecture
)
func (MIPS64Features) HasAll ¶
func (x MIPS64Features) HasAll(want MIPS64Features) bool
type PPC64Features ¶
type PPC64Features uint32
For ppc64(le), it is safe to check only for ISA level starting on ISA v3.00, since there are no optional categories. There are some exceptions that also require kernel support to work (darn, scv), so there are feature bits for those as well. The minimum processor requirement is POWER8 (ISA 2.07). The struct is padded to avoid false sharing.
const ( PPC64Feature_darn PPC64Features = 1 << iota // Hardware random number generator (requires kernel enablement) PPC64Feature_scv // Syscall vectored (requires kernel enablement) PPC64Feature_is_power8 // ISA v2.07 (POWER8) PPC64Feature_is_power9 // ISA v3.00 (POWER9) PPC64Feature_is_power10 // ISA v3.1 (POWER10) )
func (PPC64Features) HasAll ¶
func (x PPC64Features) HasAll(want PPC64Features) bool
type S390XFeatures ¶
type S390XFeatures uint32
const ( S390XFeature_zarch S390XFeatures = 1 << iota // z architecture mode is active [mandatory] S390XFeature_stfle // store facility list extended [mandatory] S390XFeature_ldisp // long (20-bit) displacements [mandatory] S390XFeature_eimm // 32-bit immediates [mandatory] S390XFeature_dfp // decimal floating point S390XFeature_etf3eh // ETF-3 enhanced S390XFeature_msa // message security assist (CPACF) S390XFeature_aes // KM-AES{128,192,256} functions S390XFeature_aescbc // KMC-AES{128,192,256} functions S390XFeature_aesctr // KMCTR-AES{128,192,256} functions S390XFeature_aesgcm // KMA-GCM-AES{128,192,256} functions S390XFeature_ghash // KIMD-GHASH function S390XFeature_sha1 // K{I,L}MD-SHA-1 functions S390XFeature_sha256 // K{I,L}MD-SHA-256 functions S390XFeature_sha512 // K{I,L}MD-SHA-512 functions S390XFeature_sha3 // K{I,L}MD-SHA3-{224,256,384,512} and K{I,L}MD-SHAKE-{128,256} functions S390XFeature_vx // vector facility. Note: the runtime sets this when it processes auxv records. S390XFeature_vxe // vector-enhancements facility 1 S390XFeature_kdsa // elliptic curve functions S390XFeature_ecdsa // NIST curves S390XFeature_eddsa // Edwards curves )
func (S390XFeatures) HasAll ¶
func (x S390XFeatures) HasAll(want S390XFeatures) bool
type WASMFeatures ¶
type WASMFeatures uint32
func (WASMFeatures) HasAll ¶
func (x WASMFeatures) HasAll(want WASMFeatures) bool
type X86Features ¶
type X86Features uint32
func (X86Features) HasAll ¶
func (x X86Features) HasAll(want X86Features) bool