p12tic / libsimdpp

Portable header-only C++ low level SIMD library
Boost Software License 1.0
1.24k stars 129 forks source link

How can we combine with Intel® SSE2 (Streaming SIMD Extensions 2)? #156

Open ardianumam opened 3 years ago

ardianumam commented 3 years ago

Hi,

I have existing code in Intel SIMD SSE2, how can I use API of libsimdpp if the variable I have is in SSE2, for example _mm_set_epi32? Is there any way so that, for example, I can use script such as: int32<4> = add(A, B); where A and B are SSE data type of _mm_set_epi32? Many thanks.

jehoshuapratama commented 3 years ago

Facing the same issue, any recommendation on this @p12tic @mtklein? Thanks

mtklein commented 3 years ago

I find that there's very little like this that memcpy() and static_assert(sizeof(A) == sizeof(B), "") cannot fix.

ardianumam commented 3 years ago

Thanks for the reply @mtklein . In the documentation here, it's stated that: uint16<N>( const native_type& n ); where n is native SIMD type to construct from. What does it mean by that? Can we use SIMD of SSE2 as n? Many thanks.

mtklein commented 3 years ago

Yep, the native_type for uint16<8> on x86 is __m128i. That's all the type stores, just native_type d_;.

https://github.com/p12tic/libsimdpp/blob/9dac213d6965bf57c7accf9dda6d16c3bed0e3ac/simdpp/types/int16x8.h#L111