Is it safe to compile one source with SSE2 another with AVX architecture?

≡放荡痞女 提交于 2019-12-11 12:28:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!