Compilation of a simple c++ program using SSE intrinsics

前端 未结 3 468
北荒
北荒 2020-12-16 05:17

I am new to the SSE instructions and I was trying to learn them from this site: http://www.codeproject.com/Articles/4522/Introduction-to-SSE-Programming

I am using t

3条回答
  •  失恋的感觉
    2020-12-16 05:49

    Short answer: use _mm_malloc and _mm_free from xmmintrin.h instead of _aligned_malloc and _aligned_free.

    Discussion

    You should not use _aligned_malloc, _aligned_free, posix_memalign, memalign, or whatever else when you are writing SSE/AVX code. These are all compiler/platform-specific functions (either MSVC or GCC or POSIX).

    Intel introduced functions _mm_malloc and _mm_free in Intel compiler specifically for SIMD computations (see this). The other compilers with x86 target architecture added them too (just as they add Intel intrinsics regularly). In this sense they are the only cross-platform solution: they should be available in every compiler supporting SSE.

    These functions are declared in xmmintrin.h header. Any header for later SSE/AVX version automatically includes previous ones, so it would be enough to include only smmintrin.h or emmintrin.h for example.

提交回复
热议问题