Skip to content

Commit b28e927

Browse files
skandhurkatSkand Hurkat
andauthored
Read AA64ISAR0_EL1 to check dot product support (#16082)
### Description Use an assembly instruction to read the `AA64ISAR0_EL1` register for dot product support. ### Motivation and Context The only reliable way to check for supported instruction extensions in ARM is to query the instruction set attribute registers. [Dot product instructions can be checked using bits 47:44 in the AA64ISAR0_EL1 register](https://developer.arm.com/documentation/ddi0601/2021-12/AArch64-Registers/ID-AA64ISAR0-EL1--AArch64-Instruction-Set-Attribute-Register-0?lang=en#fieldset_0-47_44). On `qemu-aarch64` with the `a64fx` cpu which does not support the dot product instructions, running a quantized BERT-Large (from MLPerf) results in `SIGILL`. With the change, the program continues without using the dot product instructions. Also verified that `S8S8_SDOT` kernels are invoked when running on hardware that supports dot product instructions. --------- Co-authored-by: Skand Hurkat <[email protected]>
1 parent 0d1a8cc commit b28e927

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

onnxruntime/core/mlas/lib/platform.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ MLASCPUIDInfo::MLASCPUIDInfo()
5555
#if defined(BUILD_MLAS_NO_ONNXRUNTIME)
5656
MLASCPUIDInfo::MLASCPUIDInfo()
5757
{
58-
has_arm_neon_dot_ = ((getauxval(AT_HWCAP) & HWCAP_ASIMDDP) != 0);
58+
has_arm_neon_dot_ = ((getauxval(AT_HWCAP) & HWCAP_ASIMDDP) != 0);
5959

6060
// raw hack! Need CPUIDInfo implementation for more precise detection
6161
has_fp16_ = has_arm_neon_dot_;
@@ -447,10 +447,10 @@ Return Value:
447447

448448
#if defined(_WIN32)
449449
HasDotProductInstructions = (IsProcessorFeaturePresent(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE) != 0);
450-
#elif defined(__linux__)
451-
HasDotProductInstructions = MLAS_CPUIDINFO::GetCPUIDInfo().HasArmNeonDot();
452450
#else
453-
HasDotProductInstructions = false;
451+
uint64_t isar0_el1;
452+
asm("mrs %[reg], ID_AA64ISAR0_EL1\n" : [reg] "=r"(isar0_el1) : :);
453+
HasDotProductInstructions = ((isar0_el1 >> 44) & 0xfu) == 0x1u;
454454
#endif
455455

456456
if (HasDotProductInstructions) {

0 commit comments

Comments
 (0)