Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I need to do determine processor support for SSE2 prior installing a software. From what I understand, I came up with this:

bool TestSSE2(char * szErrorMsg)
{
    __try 
    {
        __asm 
        {
              xorpd xmm0, xmm0        // executing SSE2 instruction
        }
    }
        #pragma warning (suppress: 6320)
        __except (EXCEPTION_EXECUTE_HANDLER) 
        {
            if (_exception_code() == STATUS_ILLEGAL_INSTRUCTION) 
            {
                _tcscpy_s(szErrorMsg,MSGSIZE, _T("Streaming SIMD Extensions 2(SSE2) is not supported by the CPU.
 Unable to launch APP"));
                return false;

            }
        _tcscpy_s(szErrorMsg,MSGSIZE, _T("Streaming SIMD Extensions 2(SSE2) is not supported by the CPU.
 Unable to launch APP"));
        return false;
        }   
    return true;
}

Would this work? I'm not really sure how to test, since my CPU supports it, so I don't get false from the function call.

How do I determine processor support for SSE2?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
390 views
Welcome To Ask or Share your Answers For Others

1 Answer

I found this one by accident in the MSDN:

BOOL sse2supported = ::IsProcessorFeaturePresent( PF_XMMI64_INSTRUCTIONS_AVAILABLE );

Windows-only, but if you are not interested in anything cross-platform, very simple.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...