cpu

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package cpu implements processor feature detection used by the Go standard library.

Index

Constants

View Source
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
)
View Source
const CacheLinePadSize = 64

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

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.

func Name

func Name() string

Name returns the CPU name given by the vendor. If the CPU name can not be determined an empty string is returned.

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

func (*ARM64Features) Set

func (x *ARM64Features) Set(feat string, enable bool) (enabled bool, found bool)

type ARMFeatures

type ARMFeatures uint32
const (
	ARMFeature_vfpv4 ARMFeatures = 1 << iota
	ARMFeature_idiva
)

func (ARMFeatures) HasAll

func (x ARMFeatures) HasAll(want ARMFeatures) bool

func (*ARMFeatures) Set

func (x *ARMFeatures) Set(feat string, enable bool) (enabled bool, found bool)

type FeatureChecker

type FeatureChecker[Self any] interface {
	// HasAll checks whether wanted features are all present
	HasAll(want Self) bool
}

type FeatureSet

type FeatureSet[Self any] interface {
	// Set `feat` state to `enable`
	//
	// known = false when the feat is unknown to this feature set
	// enabled = true
	Set(feat string, enable bool) (enabled, found bool)
}

type MIPS64Features

type MIPS64Features uint32
const (
	MIPS64Feature_msa MIPS64Features = 1 << iota // MIPS SIMD architecture
)

func (MIPS64Features) HasAll

func (x MIPS64Features) HasAll(want MIPS64Features) bool

func (*MIPS64Features) Set

func (x *MIPS64Features) Set(feat string, enable bool) (enabled bool, found 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

func (*PPC64Features) Set

func (x *PPC64Features) Set(feat string, enable bool) (enabled bool, found 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

func (*S390XFeatures) Set

func (x *S390XFeatures) Set(feat string, enable bool) (enabled bool, found bool)

type WASMFeatures

type WASMFeatures uint32

func (WASMFeatures) HasAll

func (x WASMFeatures) HasAll(want WASMFeatures) bool

func (*WASMFeatures) Set

func (x *WASMFeatures) Set(feat string, enable bool) (enabled, found bool)

type X86Features

type X86Features uint32

func (X86Features) HasAll

func (x X86Features) HasAll(want X86Features) bool

func (*X86Features) Set

func (x *X86Features) Set(feat string, enable bool) (enabled, found bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL