I use processor scheduling based on processor functions to switch the implementation of a complex numerical algorithm. I want to include two versions (sse2 and sse3 for arguments) I am compiling in the same dynamic library.
The approach taken so far is to wrap all architecture-specific code in a namespace, for example. namespace sse2 and namespace sse3 and thus avoiding duplicate symbol names when linking to the destination dynamic library.
However, what happens if I use some code outside my control (for example, a std::vector<int> ) in both versions of sse2 and ss3. As far as I can see, the std::vector implementation will be present both in the sse2 and sse3 object files, but theoretically it may contain different instructions depending on the optimizations performed by the compiler. When I link these object files in a dynamic library, one of them will be used, and I risk potentially trying to run the sse3 instruction on the processor, supporting only sse2.
Besides compiling into two separate dynamic libraries, what can be done to get around this problem? I need a solution that works with both Visual Studio and windows, mac os x and linux.
source share