Skip to content

SIMD Compile-time vs. run-time

  • Compile-time
    • Use intrinsics and/or autovectorization by telling the compiler which extensions are supported on the target host. The executable can not be used on hosts that do not support the included instructions.
      • Autovectorization will try to use the extensions you tell the compiler you support.
      • For intrinsics if you want multiple SIMD extensions / host machines support, then you can rely on the __AVX512F__ macro definition set by the compiler to manually ensure you only include the correct implementation. E.g., see how Kuffo’s PDX.
        • In Kuffo’s PDX, C++‘s preprocessor is used to include/exclude architecture specific headers. Thus, if you say -march=native and I have AVX512, then the compiler will set the __AVX512F__ definition, which then in the source code with an #ifdef will ensure that the desired implementation header is included (which in turn defines an implementation of some function).
          • In this case the neon_computers.hpp header directly uses the NEON intrinsics.
          • #ifdef
          • `__ARM_NEON #include “pdxearch/distance_computers/neon_computers.hpp”
          • #endif
  • Run-time