google / gemmlowp

Low-precision matrix multiplication

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

run dotprod instruction failed on apple A12 and qualcomm 845

xyoungli opened this issue · comments

hi, i tested the udot gemm kernel on "kernel_neon.h" on qualcomm 845 big core and iphone A12, but get errors like following:
android, qualcomm 845: "Illegal instruction "
iphone xr, A12: "Thread 1: EXC_BAD_INSTRUCTION (code=1, subcode=0x6f80e048)"
i would like to ask how to enable or run sdot on these devices

i tested this instruction "MRS %[id], ID_AA64ISAR0_EL1", and got "Illegal instruction"?

It is expected that dot-product instructions (UDOT, SDOT) generate 'illegal instruction' on both the Apple A12 and Qualcomm 845 CPUs. Neither of these CPUs support this new instruction. An example of a CPU that does support this new instruction is the qualcomm 855.
https://www.qualcomm.com/products/snapdragon-855-mobile-platform

Regarding your other question, the instruction
MRS %[id], ID_AA64ISAR0_EL1
generates 'illegal instruction' for a different reason: it is only legal in kernel code (that is the meaning of the _EL1 suffix). it is the operating system's task to expose this information to user-space. Here is how you would perform such userspace detection on Linux, but this requires a recent Linux version -- at least 4.15 I believe.

#include <sys/auxv.h>

...

inline bool DetectDotprodByLinuxAuxvMethod() {
  // This is the value of HWCAP_ASIMDDP in sufficiently recent Linux headers,
  // however we need to support building against older headers for the time
  // being.
  const int kAsimddpBit = 1 << 20;
  return getauxval(AT_HWCAP) & kAsimddpBit;
}