问题描述
_control87
注意:
SSE和SSE2 MXCSR控制寄存器相同,但是,文档中未提及SSE单元。 _control87
会影响SSE单元的MXCSR控制寄存器还是仅对SSE2有用?
It seems that the SSE and SSE2 MXCSR control registers are identical, however, there is no mention of the SSE unit in the documentation. Does _control87
affect an SSE unit's MXCSR control register or is this only true for SSE2?
推荐答案
我挖出一个旧的Pentium III,并用以下代码检查:
I dug out an old Pentium III and checked with the following code:
#include <Windows.h>
#include <float.h>
#include <xmmintrin.h>
#include <iostream>
#include <iomanip>
int _tmain( int argc, _TCHAR* argv[] ) {
using namespace std;
// Unmask all SSE/SSE2 exceptions
_MM_SET_EXCEPTION_MASK( 0 );
// Get SSE/SSE2 exception mask
DWORD dwExceptionMask = _MM_GET_EXCEPTION_MASK();
cout << "Exception Mask: 0x" << hex << setw( 8 )
<< setfill( '0' ) << dwExceptionMask << endl;
// Mask all FPU exceptions
_control87( 0xFFFF, _MCW_EM );
// Get SSE/SSE2 exception mask
dwExceptionMask = _MM_GET_EXCEPTION_MASK();
cout << "Exception Mask: 0x" << hex << setw( 8 )
<< setfill( '0' ) << dwExceptionMask << endl;
return 0;
}
奔腾III(SSE)的结果:
Result on Pentium III (SSE):
Exception Mask: 0x00000000
Exception Mask: 0x00000000
至强(SSE,SSE2,SSE3,SSSE3)的结果:
Result on Xeon (SSE, SSE2, SSE3, SSSE3):
Exception Mask: 0x00000000
Exception Mask: 0x00001e80
结果令人惊讶,但与文档一致。 _control87
仅在至少有一个SSE2单元可用时才对MXCSR控制寄存器产生影响。
The results are surprising, but in line with the documentation. _control87
only has an effect on the MXCSR control register if at least an SSE2 unit is available.
这篇关于_control87()是否还会设置SSE MXCSR控制寄存器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!