Files
730057c146 gcasm: arm64 "fhm" override feature level (FEAT_FHM, FMLAL/FMLSL) (#69)
Assembly overrides can now declare an arm64 body for FEAT_FHM, the
f16-product / f32-accumulate multiply-adds (FMLAL, FMLAL2 and their
by-element forms). The base package detects it (hw.optional.arm.FEAT_FHM
on darwin, HWCAP_ASIMDFHM on linux) as CPUFHM, and the dispatch ladder
checks it first: the arm64 levels are independent features rather
than a ladder, so the order only decides which of several present
bodies runs.

Co-authored-by: Claude Fable 5.1 <[email protected]>
2026-09-05 14:30:10 +09:00

36 lines
918 B
Go

//go:build arm64 && darwin
package helpers
import "syscall"
// CPUDotProd reports FEAT_DotProd (the SDOT/UDOT instructions).
// Feature-gated splice bodies dispatch on it at runtime; the
// portable twin body runs when it is false.
var CPUDotProd = detectDotProd()
// CPUI8MM reports FEAT_I8MM (SMMLA/UMMLA); see the linux twin for
// why it is detected apart from CPUDotProd.
var CPUI8MM = detectI8MM()
// CPUFHM reports FEAT_FHM (FMLAL/FMLSL: f16 products accumulated in
// f32). Bodies that keep f16 operands unwidened dispatch on it.
var CPUFHM = detectFHM()
func detectDotProd() bool {
return sysctlFeature("hw.optional.arm.FEAT_DotProd")
}
func detectI8MM() bool {
return sysctlFeature("hw.optional.arm.FEAT_I8MM")
}
func detectFHM() bool {
return sysctlFeature("hw.optional.arm.FEAT_FHM")
}
func sysctlFeature(name string) bool {
v, err := syscall.SysctlUint32(name)
return err == nil && v != 0
}