问题
I'm using AVX intrinsics, but since for everything other than _mm256 based intrinsics MSVC generates non-vex instructions, I need to compiler the whole source code with /arch:AVX. The rest of the project is compiled with /arch:SSE2, so that it works on older CPUs and I'm manually checking if AVX is available.
The source containing AVX code (compiled for AVX) includes a huge library of templates and other stuff, just to have the definitions. Is there a possibility that the compiler/linker decides to instantiate some template with AVX instructions, just because it has been included in this source as well? In that case it would make it crash on non-AVX processors
回答1:
Is there a possibility that the compiler/linker decides to instantiate some template with AVX instructions, just because it has been included in this source as well?
Yes, it may happen, as seen in my linked question. Check out the (other) good answers given there.
My preferred workaround was to modify the template to include a discriminative parameter, but it may be too much of a hassle if it's really a "huge library", just like using global definitions as you mentioned in your own answer.
来源:https://stackoverflow.com/questions/29358105/is-it-safe-to-compile-one-source-with-sse2-another-with-avx-architecture