Skip to content
Search

Streaming SIMD Extensions

lastmod 2019-11-25created 2016-10-068 edits

Streaming SIMD Extensions (SSE) is a SIMD (single instruction, multiple data) instruction set extension to the x86 architecture, introduced by Intel in 1999 with the Pentium III series of processors. It was a response to AMD's 3DNow! technology, which appeared in 1998. SSE consists of 70 new instructions and additional registers, and most of the instructions operate on floating-point numbers.

While the Pentium III was known by the code name Katmai, SSE was called KNI (Katmai New Instructions). The name was later set to ISSE (Internet Streaming SIMD Extensions) and then changed to SSE. AMD added support for SSE instructions starting with the Athlon XP and Duron processors.

SSE copy

Copying with Streaming SIMD Extension

void temporal_copy( char* outbuff, char* inbuff, unsigned int size )
{
    const unsigned int step = 64; // cache line size

    while ( size > step )
    {
        _mm_prefetch( inbuff + 640, _MM_HINT_NTA ); // non-temporal prefetch
        __m128i A = _mm_load_si128( (__m128i*)(inbuff +  0) );
        __m128i B = _mm_load_si128( (__m128i*)(inbuff + 16) );
        __m128i C = _mm_load_si128( (__m128i*)(inbuff + 32) );
        __m128i D = _mm_load_si128( (__m128i*)(inbuff + 48) );

        // destination address must be 16-byte aligned!
        _mm_store_si128( (__m128i*)(outbuff +  0), A );
        _mm_store_si128( (__m128i*)(outbuff + 16), B );
        _mm_store_si128( (__m128i*)(outbuff + 32), C );
        _mm_store_si128( (__m128i*)(outbuff + 48), D );

        inbuff  += step;
        outbuff += step;
        size -= step;
    }

    memcpy( inbuff, outbuff, size );  // 나머지부분은 간단하게 memcpy 로 복사

    //_mm_mfence(); // 멀티스레드 환경에서 사용
}

See also

Favorite site

author Zer0 sitemap