1

I'm writing a performance critical application in C that exploits the use of SIMD available on most processors out there. I have made my code to be compilable on multiple platforms, whether it be ARM or x86, but what are the commonly used processors/chips out there, that lack SIMD and on which my application would be inefficient?

I can't find a list of processors online that lacks SIMD, but a handful of commonly used ones, would be sufficient to convince me, that I should make a SIMD-less version of my project...

So, are there ways to detect if SIMD is available at runtime?

If I am on x86 and using GNU GCC, then I can use __builtin_cpu_supports("...") to check if a particular feature like avx , sse is available.

But I cant get an equivalent builtin to check for ARM's neon on my CLANG compiler.

I don't know if such a builtin is available.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Vivekanand V
  • 340
  • 2
  • 12
  • 1
    You'll have to define "common" and "SIMD" because you can implement some sort of SIMD even using general purpose instructions. In x86 space there is Intel Quark that lacks any dedicated SIMD instruction set extensions. In ARM, I think, ARMv7 and earlier CPUs are not required to have SIMD extensions. Such CPUs may still be relevant in embedded area. – Andrey Semashev Jul 07 '20 at 21:20
  • @AndreySemashev Thankyou, Are there runtime checks to see if its available? – Vivekanand V Jul 07 '20 at 21:23
  • 1
    On x86 you would use `cpuid` instruction or one of the many wrappers, including the gcc builtins. For ARM I don't know if there is a user mode instruction, so you may have to query the OS (e.g. parse `/proc/cpuinfo`). – Andrey Semashev Jul 07 '20 at 21:27
  • @AndreySemashev Thankyou! But, `/proc/cpuinfo` works only on Linux like OS ? – Vivekanand V Jul 07 '20 at 21:30
  • 1
    Yes, `/proc/cpuinfo` is a UNIX-like interface. Also, see this question: https://stackoverflow.com/questions/26701262/how-to-check-the-existence-of-neon-on-arm – Andrey Semashev Jul 07 '20 at 21:34
  • 1
    Also, this article: https://community.arm.com/developer/tools-software/oss-platforms/b/android-blog/posts/runtime-detection-of-cpu-features-on-an-armv8-a-cpu – Andrey Semashev Jul 07 '20 at 21:39
  • The arm cpuid registers indicate SIMD feature support or not. – old_timer Jul 08 '20 at 03:52

0 Answers0