3 ms·
That isn't exactly how it works. The proper way to do it: if( CPUIDbits & SSE1_CAPABLE ) {enable SSE1} if( CPUIDbits & SSE2_CAPABLE ) {enable SSE2}
by DarkShikari 17y ago
That isn't exactly how it works.
The proper way to do it:
if( CPUIDbits & SSE1_CAPABLE ) {enable SSE1}
if( CPUIDbits & SSE2_CAPABLE ) {enable SSE2}
[etc]
The even better way to do it:
if( CPUIDbits & SSE1_CAPABLE ) {enable SSE1}
if( CPUIDbits & SSE2_CAPABLE ) {enable SSE2}
if( CPU is Athlon 64 ) {disable some SSE2 functions}
if( CPU is Pentium-M ) {disable all SSE2 functions}
[etc]
Intel's way of doing it:
if( CPU is Pentium 3 ) {enable SSE1}
if( CPU is Pentium 4 ) {enable SSE1/SSE2}
if( CPU is Core 2 ) {enable SSE1/SSE2/SSE3/SSSE3}
[etc]
Practically all sane applications do things the first way; a couple do things the second way. Anyone doing things the third way is just asking for trouble both in terms of future compatibility and resilience to unexpected situations. For example, some VMs disable certain instruction sets, which would result in SIGILLs when using the last method.
- kelnos 17y agoIf you read the article, it looks like Intel's CPU-type dispatcher actually does it the second way (sorta; it appears to only check Intel CPU family IDs), but at the bottom of that list there's a big "if(CPU string is not "GenuineIntel") { disable everything and use crappy fallback code path }".