使用SSE2编译具有AVX架构的另一个源是否安全? [英] Is it safe to compile one source with SSE2 another with AVX architecture?

查看:87
本文介绍了使用SSE2编译具有AVX架构的另一个源是否安全?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是AVX内部函数,但是由于基于_mm256的内部函数以外的所有内容,MSVC都会生成非vex指令,因此我需要使用/arch:AVX编译整个源代码.该项目的其余部分使用/arch:SSE2进行编译,因此它可以在较旧的CPU上运行,并且我正在手动检查AVX是否可用.

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.

包含AVX代码的源(为AVX编译)包括一个庞大的模板库和其他内容,仅包含定义.编译器/链接器是否有可能决定使用AVX指令实例化某些模板,只是因为该模板也已包含在此源代码中?在这种情况下,它将使其在非AVX处理器上崩溃

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

推荐答案

编译器/链接器是否有可能决定实例化 一些带有AVX指令的模板,只是因为它已包含在内 在这个资源中也是如此?

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.

这篇关于使用SSE2编译具有AVX架构的另一个源是否安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆