I'm trying to do an algorithm which uses SSE2+SSE3 functions. How do I go about to actually compile REF + SSE + SSE2 + SSE3 variants of the algorithm?
My hunch is that I somehow via includes direct the compiler which set of instructions to use, like (pseudo code):
// Compile for REF #include <SSEplus_REF.h> #define myalgorithm myalgorithm_REF #include <myalgorithm.cpp> #undef myalgorithm
// Compile for SSE #include <sseplus_unmap_all.h> #include <SSEplus_SSE.h> #define myalgorithm myalgorithm_SSE #include <myalgorithm.cpp> #undef myalgorithm
etc.
then use cpuid to map a function pointer at run-time to the correct version.
Thing is that I don't know. An example project would be nice to have.
Log in to post a comment.
I'm trying to do an algorithm which uses SSE2+SSE3 functions. How do I go about to actually compile REF + SSE + SSE2 + SSE3 variants of the algorithm?
My hunch is that I somehow via includes direct the compiler which set of instructions to use, like (pseudo code):
// Compile for REF
#include <SSEplus_REF.h>
#define myalgorithm myalgorithm_REF
#include <myalgorithm.cpp>
#undef myalgorithm
// Compile for SSE
#include <sseplus_unmap_all.h>
#include <SSEplus_SSE.h>
#define myalgorithm myalgorithm_SSE
#include <myalgorithm.cpp>
#undef myalgorithm
etc.
then use cpuid to map a function pointer at run-time to the correct version.
Thing is that I don't know. An example project would be nice to have.