Determining maximum vector length supported by the CPU?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm currently writing an FFT library which tries to make use of SIMD
instructions and uses a lot of variables with
 __attribute__ ((vector_size (xyz))

The resulting source is nicely portable and architecture-independent -
except for the one place where I need to determine the maximum
hardware-supported vector length on the target CPU.

This currently looks like

#if defined(__AVX__)
constexpr veclen=32;
#elif defined(__SSE2__)
constexpr veclen=16;
[...]

This approach requires me to add an #ifdef for many architectures, most
of which I cannot really test on ... and new architectures will be
unsupported by default.

Hence my question: is there a way in gcc to determine the hardware
vector length for the architecture the compiler is currently targeting?
Some predefined macro like

HARDWARE_VECTOR_LENGTH_IN_BYTES

which is 32 for AVX, 16 for SSE2, and has proper values for Neon, VPX
etc. etc.

If this is not provided at the moment, would it bo possible to add this
in the future? This could massively simplify writing and maintaining
SIMD code.

Thanks,
  Martin




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux