1

I'm working on a cross-platform parallel math library and I've made great progress implementing SSE, AVX, AVX2 and AVX-512 for x86/amd64 including runtime detection of ISA availability.

However, I've run into a major problem. There is no documentation for detecting NEON or Helium support at runtime on MSVC. It appears that there is no cpuid instruction on ARM or ARM64. It isn't clear whether there is a cross-platform way to accomplish this for Linux either.

Do you even need to detect it manually or can you just use preprocessor definitions (such as _M_ARM64) to check for runtime support? It is my understanding that preprocessor macros are ONLY evaluated at compile-time.

Are we just supposed to assume that every ARM CPU has NEON? What about Helium?

I'm hoping that someone here knows how to do it. Thank You in advance.

phuclv
  • 37,963
  • 15
  • 156
  • 475
dave_thenerd
  • 448
  • 3
  • 10
  • https://stackoverflow.com/questions/26701262/how-to-check-the-existence-of-neon-on-arm – Yakk - Adam Nevraumont Jul 30 '21 at 01:49
  • Yeah, I've seen that page. I still don't understand how to implement this in C/ C++ or how to accomplish this on Windows. Thanks anyway. – dave_thenerd Jul 30 '21 at 01:58
  • 1
    Probably you should tag this Windows. – Nate Eldredge Jul 30 '21 at 02:37
  • please read the tag description before tagging. [tag:helium] is for the automation test tool – phuclv Jul 30 '21 at 03:07
  • There is a deleted answer in that link. It looks like written carefully and I wonder that it was deleted. As I cannot justify if it tells something good or bad, I copy at least a link concerning Windows: [Understanding ARM Assembly Part](https://learn.microsoft.com/de-de/archive/blogs/ntdebugging/understanding-arm-assembly-part-1): _The processor also has to have the Optional ISA extensions of VFP (Hardware Floating Point) and NEON (128-bit SIMD Architecture)._ – Scheff's Cat Jul 30 '21 at 06:14
  • @phuclv The tag has always been " arm-helium " See: https://stackoverflow.com/questions/tagged/arm-helium and https://en.wikipedia.org/wiki/ARM_architecture#ARM_Helium_technology – dave_thenerd Jul 31 '21 at 03:48
  • @dave_thenerd no, that tag was created by me. You use [tag:helium] before I edited it. Did you see the edit history? Your question is currently the only one with that tag – phuclv Jul 31 '21 at 04:04

2 Answers2

2

If building with MSVC, targeting modern Windows on ARM or ARM64 (i.e. not Windows CE), then the baseline feature set does support NEON (on both 32 and 64 bit), so you don't need to check for them at all, you can use them unconditionally. (If the code base is portable you might want to avoid compiling that code for other architectures of course, using e.g. regular preprocessor defines.) So for this case, checking the _M_ARM or _M_ARM64 defines is enough.

Helium is only for the M profile of ARM processors, i.e. for microcontrollers and such, not relevant for the the A profile (for "application use").

mstorsjo
  • 12,983
  • 2
  • 39
  • 62
0

NEON as well as VFP is mandatory on armv8-a.

Hence there is no need to check the availability at runtime on aarch64.

And I'd ditch aarch32 support altogether.

Jake 'Alquimista' LEE
  • 6,197
  • 2
  • 17
  • 25
  • Thank You very much that's great news for me. I wasn't planning on supporting any 32-bit platforms anyway. Should I be verifying that the processor is an armv8-a or newer somehow or would somebody have had to hack a 64-bit OS to run on the older chips and I shouldn't waste my time? – dave_thenerd Jul 31 '21 at 03:53
  • 1
    No 64-bit before Armv8, so running a 64-bit OS on anything older is not possible. – solidpixel Aug 04 '21 at 17:27