printf SSE variables __m128i in Visual Studio

c, simd, visual-studio-2010

Solution

Use this function to print them:

void print128_num(__m128i var)
{
    uint16_t *val = (uint16_t*) &var;//can also use uint32_t instead of 16_t
    printf("Numerical: %i %i %i %i %i %i %i %i \n", 
           val[0], val[1], val[2], val[3], val[4], val[5], 
           val[6], val[7]);
}

You split 128bits into 16-bits(or 32-bits) before printing them.

This is a way of 64-bit splitting and printing if you have 64-bit support available:

void print128_num(__m128i var) 
{
    int64_t *v64val = (int64_t*) &var;
    printf("%.16llx %.16llx\n", v64val[1], v64val[0]);
}

Replace `llx` with `lld` if u want `int` output.

Problem

I have some code that uses SIMD optimization and various __m128i variables. Obviously, printf can't handle them. Is there an easy way for me to print their contents? I'm using Visual Studio 2010 with C/C++.

Original source

Related problems