1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

cpu: update ARM CPU flags through v9.2

This commit is contained in:
Yaakov Selkowitz 2022-10-13 16:54:37 -04:00
parent ddfccb4907
commit 70883df5f6

View file

@ -23,6 +23,9 @@ package cpu
unsigned long gethwcap() {
return getauxval(AT_HWCAP);
}
unsigned long gethwcap2() {
return getauxval(AT_HWCAP2);
}
*/
import "C"
@ -63,6 +66,44 @@ const (
CPU_ARM64_FEATURE_PACG
)
const (
/* extension instructions */
CPU_ARM64_FEATURE2_DCPODP = 1 << iota
CPU_ARM64_FEATURE2_SVE2
CPU_ARM64_FEATURE2_SVEAES
CPU_ARM64_FEATURE2_SVEPMULL
CPU_ARM64_FEATURE2_SVEBITPERM
CPU_ARM64_FEATURE2_SVESHA3
CPU_ARM64_FEATURE2_SVESM4
CPU_ARM64_FEATURE2_FLAGM2
CPU_ARM64_FEATURE2_FRINT
CPU_ARM64_FEATURE2_SVEI8MM
CPU_ARM64_FEATURE2_SVEF32MM
CPU_ARM64_FEATURE2_SVEF64MM
CPU_ARM64_FEATURE2_SVEBF16
CPU_ARM64_FEATURE2_I8MM
CPU_ARM64_FEATURE2_BF16
CPU_ARM64_FEATURE2_DGH
CPU_ARM64_FEATURE2_RNG
CPU_ARM64_FEATURE2_BTI
CPU_ARM64_FEATURE2_MTE
CPU_ARM64_FEATURE2_ECV
CPU_ARM64_FEATURE2_AFP
CPU_ARM64_FEATURE2_RPRES
CPU_ARM64_FEATURE2_MTE3
CPU_ARM64_FEATURE2_SME
CPU_ARM64_FEATURE2_SME_I16I64
CPU_ARM64_FEATURE2_SME_F64F64
CPU_ARM64_FEATURE2_SME_I8I32
CPU_ARM64_FEATURE2_SME_F16F32
CPU_ARM64_FEATURE2_SME_B16F32
CPU_ARM64_FEATURE2_SME_F32F32
CPU_ARM64_FEATURE2_SME_FA64
CPU_ARM64_FEATURE2_WFXT
CPU_ARM64_FEATURE2_EBF16
CPU_ARM64_FEATURE2_SVE_EBF16
)
var flagNames_arm64 = map[uint64]string{
CPU_ARM64_FEATURE_FP: "FP",
CPU_ARM64_FEATURE_ASIMD: "ASIMD",
@ -98,9 +139,47 @@ var flagNames_arm64 = map[uint64]string{
CPU_ARM64_FEATURE_PACG: "PACG",
}
var flag2Names_arm64 = map[uint64]string{
CPU_ARM64_FEATURE2_DCPODP: "DCPODP",
CPU_ARM64_FEATURE2_SVE2: "SVE2",
CPU_ARM64_FEATURE2_SVEAES: "SVEAES",
CPU_ARM64_FEATURE2_SVEPMULL: "SVEPMULL",
CPU_ARM64_FEATURE2_SVEBITPERM: "SVEBITPERM",
CPU_ARM64_FEATURE2_SVESHA3: "SVESHA3",
CPU_ARM64_FEATURE2_SVESM4: "SVESM4",
CPU_ARM64_FEATURE2_FLAGM2: "FLAGM2",
CPU_ARM64_FEATURE2_FRINT: "FRINT",
CPU_ARM64_FEATURE2_SVEI8MM: "SVEI8MM",
CPU_ARM64_FEATURE2_SVEF32MM: "SVEF32MM",
CPU_ARM64_FEATURE2_SVEF64MM: "SVEF64MM",
CPU_ARM64_FEATURE2_SVEBF16: "SVEBF16",
CPU_ARM64_FEATURE2_I8MM: "I8MM",
CPU_ARM64_FEATURE2_BF16: "BF16",
CPU_ARM64_FEATURE2_DGH: "DGH",
CPU_ARM64_FEATURE2_RNG: "RNG",
CPU_ARM64_FEATURE2_BTI: "BTI",
CPU_ARM64_FEATURE2_MTE: "MTE",
CPU_ARM64_FEATURE2_ECV: "ECV",
CPU_ARM64_FEATURE2_AFP: "AFP",
CPU_ARM64_FEATURE2_RPRES: "RPRES",
CPU_ARM64_FEATURE2_MTE3: "MTE3",
CPU_ARM64_FEATURE2_SME: "SME",
CPU_ARM64_FEATURE2_SME_I16I64: "SMEI16I64",
CPU_ARM64_FEATURE2_SME_F64F64: "SMEF64F64",
CPU_ARM64_FEATURE2_SME_I8I32: "SMEI8I32",
CPU_ARM64_FEATURE2_SME_F16F32: "SMEF16F32",
CPU_ARM64_FEATURE2_SME_B16F32: "SMEB16F32",
CPU_ARM64_FEATURE2_SME_F32F32: "SMEF32F32",
CPU_ARM64_FEATURE2_SME_FA64: "SMEFA64",
CPU_ARM64_FEATURE2_WFXT: "WFXT",
CPU_ARM64_FEATURE2_EBF16: "EBF16",
CPU_ARM64_FEATURE2_SVE_EBF16: "SVEEBF16",
}
func getCpuidFlags() []string {
r := make([]string, 0, 20)
hwcap := uint64(C.gethwcap())
hwcap2 := uint64(C.gethwcap2())
for i := uint(0); i < 64; i++ {
key := uint64(1 << i)
val := flagNames_arm64[key]
@ -108,5 +187,12 @@ func getCpuidFlags() []string {
r = append(r, val)
}
}
for i := uint(0); i < 64; i++ {
key := uint64(1 << i)
val := flag2Names_arm64[key]
if hwcap2&key != 0 {
r = append(r, val)
}
}
return r
}