I am writing some C++ code to target various platforms. This includes x86, x64, and ARM. I currently use Intel IPP and MKL (for SSE) on x64 and expect to add a NEON library for ARM. Is there a standard way to branch around specific libraries and with minimal dependencies and fuss? I am currently using Visual Studio 2008 or 2012.
My initial thought is to just #ifdef around specific calls and test for X86, X64, ARM, etc. Like:
void addVectors(int * a, int * b, int n)
{
#ifdef INTELIPP
ippsAdd_32s_I(...);
#elif ARMNEON
neonAdd_32s_I(...);
#else
for(int k = 0; k < n; k++)
a[k] += b[k];
#endif
}
but this could get really messy. I was wondering what the standard approach is. For example, I expect it to be cleaner to a separate project for the IPP and NEON code and only build the main project against one of them?
The IDE is not terribly important except for support---and I suspect we will change over to something like Eclipse for the ARM work.