I am looking at parallel processing algorithm for processing speed improvement. I want to test Agner Fog's vector class library, VCL.
I am wondering how to select different vector classes for example Vec16c (SSE2 instruction set) and Vec32c (AVX instruction set).
I am using Intel® Atom™ x5-Z8350 Processor and according to the specs, it supports SSE4.2 instruction sets.
How can I effectively choose vector class with regards to the hardware support? Say for my processor, can I use Vec32c recommended for AVX instruction set?
You can use compiler defined macros to detect what instruction-sets are enabled for the target you're compiling for, such as:
This doesn't do run-time detection, so only enable AVX2 if you want to make a binary that only runs on CPUs with AVX2.
If you want your code to work on non-x86 platforms, or x86 without SSE2 where VCL isn't supported at all, you need to protect the
#include <vectori128.h>with#ifas well.