简体   繁体   English

如何找出是什么引入了 AVX 标志

[英]How to find out what introduces AVX flag

I have a quite large x64 c++ program that is compiled with Visual Studio.我有一个相当大的 x64 c++ 程序,它是用 Visual Studio 编译的。 There are two ways how do we compile it - one is with sln solution file (from IDE or through msbuild), another is through Makefile in VS command prompt (which then internally uses Visual Studio's cl.exe and link.exe).我们如何编译它有两种方法 - 一种是使用 sln 解决方案文件(来自 IDE 或通过 msbuild),另一种是通过 VS 命令提示符中的 Makefile(然后在内部使用 Visual Studio 的 cl.exe 和 link.exe)。

Somehow I got into situation that binary build through Makefile produces executable with /AVX instructions enabled, and I don't want that , so I want to find out how to get rid of it.不知何故,我遇到了通过Makefile 生成二进制文件并启用了 /AVX 指令的可执行文件的情况,我不想要那样,所以我想找出如何摆脱它。

I try to compile and link it without any parameters (especially without /arch:AVX).我尝试在没有任何参数的情况下编译和链接它(尤其是没有 /arch:AVX)。 I hope that I compile and link the same sources and libs in both sln and Makefile.我希望我在 sln 和 Makefile 中编译和链接相同的源代码和库。

What is the easy way how to find out where the AVX comes from?如何找出 AVX 来自哪里的简单方法是什么? Project includes dozens of h/cpp files, around 40 own libs, 10 windows libs.项目包括数十个 h/cpp 文件,大约 40 个自己的库,10 个 Windows 库。 How would you proceed?你将如何进行?

The simple way, find an old PC without AVX, run your app in debugger, it'll crash with invalid instruction runtime error and will trap to debugger.简单的方法,找到一台没有 AVX 的旧电脑,在调试器中运行你的应用程序,它会因无效指令运行时错误而崩溃,并会陷入调试器。 This way you'll immediately find out what code compiled into that instruction.通过这种方式,您将立即找出编译为该指令的代码。

Another, harder way, write a C# console app that disassembles the compiled DLL or EXE, and searches for AVX instruction.另一种更难的方法是编写一个 C# 控制台应用程序,反汇编已编译的 DLL 或 EXE,并搜索 AVX 指令。 You'll need Gee.External.Capstone nuget package for disassembling, PeNet package for parsing into sections.你需要Gee.External.Capstone nuget 包来反汇编, PeNet包来解析成部分。 Also this code to disassemble .还有这段代码要反汇编 The disassembleStreamEx method will return you the stream of the instructions. disassembleStreamEx方法将返回指令流。 Search for X86InstructionGroup.AVX or X86InstructionGroup.AVX2 instructions, print addresses, then use eg WinDBG + PDB file to translate addresses into source code location.搜索 X86InstructionGroup.AVX 或 X86InstructionGroup.AVX2 指令,打印地址,然后使用例如 WinDBG + PDB 文件将地址转换为源代码位置。

Update: before doing that, search your codebase for files containing _mm256_ , and *.asm files.更新:在此之前,请在代码库中搜索包含_mm256_*.asm文件的文件。 If you're lucky you won't have to do anything else.如果你很幸运,你将不必做任何其他事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM