MinGW64无法使用32字节堆栈对齐方式(在Windows x64上需要AVX),易于使用或交换编译器? [英] MinGW64 Is Incapable of 32 Byte Stack Alignment (Required for AVX on Windows x64), Easy Work Around or Switch Compilers?

查看:303
本文介绍了MinGW64无法使用32字节堆栈对齐方式(在Windows x64上需要AVX),易于使用或交换编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用AVX指令和Windows 64位。我对g ++编译器感到满意,所以我一直在使用它,但是,有一个大的错误描述了报告这里和非常粗略的解决方案呈现 here。



基本上,m256变量不能在堆栈上对齐,以便与avx指令正常工作,它需要32字节对齐。

在链接的其他堆栈问题中提出的解决方案非常糟糕,特别是如果您有性能考虑。一个python程序,你每次想要调试时都必须运行,用它们的次优未对齐指令代替指令,或者过度分配代码并在代码中执行一堆代价高昂的hacky指针数学运算,以便正确对齐。如果你做指针数学解决方案,我认为甚至有可能出现seg故障,因为你无法控制分配或r值/临时值。



我正在寻找一种更简单,更便宜的解决方案。我不介意转换编译器,不愿意,但如果这是我的最佳解决方案。然而,我对这个错误的理解很差,它是windows 64位的固有特性,所以切换编译器会有帮助还是其他编译器也有同样的问题?

解决方案

您可以通过切换到Microsoft的64位C / C ++编译器来解决此问题。这个问题不是固有的64位Windows。尽管Kai Tietz在你关联的bug报告中说过,微软的x64 ABI确实允许一个编译器为堆栈上的变量提供大于16字节的对齐。

另外Cygwin's GCC 4.9.2的64位版本可以为堆栈上的变量提供32字节对齐方式。

I'm trying to work with AVX instructions and windows 64bit. I'm comfortable with g++ compiler so I've been using that, however, there is a big bug described reported here and very rough solutions were presented here.

Basically, m256 variable can't be aligned on the stack to work properly with avx instructions, it needs 32 byte alignment.

The solutions presented at the other stack question I linked are really terrible, especially if you have performance in mind. A python program that you would have to run every time you want to debug that replaces instructions with their sub-optimal unaligned instructions, or over-allocating and doing a bunch of costly hacky pointer math in code to get proper alignment. If you do the pointer math solution, I think there is still even a chance for a seg fault because you can't control the allocation or r-values / temporaries.

I'm looking for an easier and cheaper solution. I don't mind switching compilers, would prefer not to, but if it's the best solution I will. However, my very poor understanding of the bug is that it is intrinsic to windows 64 bit, so would switching compilers help or do other compilers also have the same issue?

解决方案

You can solve this problem by switching to Microsoft's 64-bit C/C++ compiler. The problem is not intrinsic to 64-bit Windows. Despite what Kai Tietz said in the bug report you linked, Microsoft's x64 ABI does allow a compiler to give variables a greater than 16-byte alignment on the stack.

Also Cygwin's 64-bit version of GCC 4.9.2 can give variables 32-byte alignment on the stack.

这篇关于MinGW64无法使用32字节堆栈对齐方式(在Windows x64上需要AVX),易于使用或交换编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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