From 7bb0bf703bd313f37f48995aa1cb6788e592050d Mon Sep 17 00:00:00 2001 From: Hernan Martinez Date: Sat, 29 Jun 2024 05:37:15 -0600 Subject: [PATCH] cpu: add Int8 matrix multiplication instructions CPU feature flag for ARM64 References: https://github.com/torvalds/linux/blob/5bbd9b249880dba032bffa002dd9cd12cd5af09c/arch/arm64/include/uapi/asm/hwcap.h#L75C9-L75C31 https://developer.arm.com/documentation/ddi0601/2024-03/AArch64-Registers/ID-AA64ISAR1-EL1--AArch64-Instruction-Set-Attribute-Register-1 Change-Id: Ic4e1cf2c23097c7e8695453b6d0b335756d474bc Reviewed-on: https://go-review.googlesource.com/c/sys/+/595678 Reviewed-by: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Auto-Submit: Ian Lance Taylor Reviewed-by: Cherry Mui --- cpu/cpu.go | 1 + cpu/cpu_arm64.go | 6 ++++++ cpu/cpu_linux_arm64.go | 2 ++ 3 files changed, 9 insertions(+) diff --git a/cpu/cpu.go b/cpu/cpu.go index 11a0abc1d..ec07aab05 100644 --- a/cpu/cpu.go +++ b/cpu/cpu.go @@ -106,6 +106,7 @@ var ARM64 struct { HasSVE2 bool // Scalable Vector Extensions 2 HasASIMDFHM bool // Advanced SIMD multiplication FP16 to FP32 HasDIT bool // Data Independent Timing support + HasI8MM bool // Advanced SIMD Int8 matrix multiplication instructions _ CacheLinePad } diff --git a/cpu/cpu_arm64.go b/cpu/cpu_arm64.go index 8bde6f1b9..af2aa99f9 100644 --- a/cpu/cpu_arm64.go +++ b/cpu/cpu_arm64.go @@ -39,6 +39,7 @@ func initOptions() { {Name: "asimddp", Feature: &ARM64.HasASIMDDP}, {Name: "asimdfhm", Feature: &ARM64.HasASIMDFHM}, {Name: "dit", Feature: &ARM64.HasDIT}, + {Name: "i8mm", Feature: &ARM64.HasI8MM}, } } @@ -146,6 +147,11 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { ARM64.HasLRCPC = true } + switch extractBits(isar1, 52, 55) { + case 1: + ARM64.HasI8MM = true + } + // ID_AA64PFR0_EL1 switch extractBits(pfr0, 16, 19) { case 0: diff --git a/cpu/cpu_linux_arm64.go b/cpu/cpu_linux_arm64.go index bc61b1909..08f35ea17 100644 --- a/cpu/cpu_linux_arm64.go +++ b/cpu/cpu_linux_arm64.go @@ -38,6 +38,7 @@ const ( hwcap_DIT = 1 << 24 hwcap2_SVE2 = 1 << 1 + hwcap2_I8MM = 1 << 13 ) // linuxKernelCanEmulateCPUID reports whether we're running @@ -112,6 +113,7 @@ func doinit() { // HWCAP2 feature bits ARM64.HasSVE2 = isSet(hwCap2, hwcap2_SVE2) + ARM64.HasI8MM = isSet(hwCap2, hwcap2_I8MM) } func isSet(hwc uint, value uint) bool {