Skip to content

Commit

Permalink
Add SIMD headers
Browse files Browse the repository at this point in the history
  • Loading branch information
homm committed Jul 6, 2024
1 parent 9b4fae7 commit 8b9af1d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/libImaging/ImPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@ typedef signed __int64 int64_t;
#ifdef __GNUC__
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif

#include "ImagingSIMD.h"
41 changes: 41 additions & 0 deletions src/libImaging/ImagingSIMD.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* Microsoft compiler doesn't limit intrinsics for an architecture.
This macro is set only on x86 and means SSE2 and above including AVX2. */
#if defined(_M_X64) || _M_IX86_FP == 2
#define __SSE2__
#endif

#ifdef __SSE4_2__
#define __SSE4__
#endif

#ifdef __SSE2__
#include <mmintrin.h> // MMX
#include <xmmintrin.h> // SSE
#include <emmintrin.h> // SSE2
#endif
#ifdef __SSE4__
#include <pmmintrin.h> // SSE3
#include <tmmintrin.h> // SSSE3
#include <smmintrin.h> // SSE4.1
#include <nmmintrin.h> // SSE4.2
#endif
#ifdef __AVX2__
#include <immintrin.h> // AVX, AVX2
#endif
#ifdef __aarch64__
#include <arm_neon.h> // ARM NEON
#endif

#ifdef __SSE4__
static __m128i inline
mm_cvtepu8_epi32(void *ptr) {
return _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*(INT32 *) ptr));
}
#endif

#ifdef __AVX2__
static __m256i inline
mm256_cvtepu8_epi32(void *ptr) {
return _mm256_cvtepu8_epi32(_mm_loadl_epi64((__m128i *) ptr));
}
#endif

0 comments on commit 8b9af1d

Please sign in to comment.