Skip to content

Commit

Permalink
SIMD. resolve imports
Browse files Browse the repository at this point in the history
  • Loading branch information
homm committed Dec 20, 2021
1 parent 5faccdd commit be0fc48
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
15 changes: 2 additions & 13 deletions src/libImaging/ImPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@

#include "Python.h"

/* 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 __SSE4_2__
#endif
#if defined(__SSE4_2__)
#include <emmintrin.h>
#include <mmintrin.h>
#include <smmintrin.h>
#endif
#if defined(__AVX2__)
#include <immintrin.h>
#endif

/* Workaround issue #2479 */
#if PY_VERSION_HEX < 0x03070000 && defined(PySlice_GetIndicesEx) && \
Expand Down Expand Up @@ -97,3 +84,5 @@ typedef signed __int64 int64_t;
#ifdef __GNUC__
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif

#include "ImagingSIMD.h"
27 changes: 27 additions & 0 deletions src/libImaging/ImagingSIMD.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* 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 __SSE4_2__
#endif
#if defined(__SSE4_2__)
#include <emmintrin.h>
#include <mmintrin.h>
#include <smmintrin.h>
#endif
#if defined(__AVX2__)
#include <immintrin.h>
#endif

#if defined(__SSE4_2__)
static __m128i inline
mm_cvtepu8_epi32(void *ptr) {
return _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*(INT32 *) ptr));
}
#endif

#if defined(__AVX2__)
static __m256i inline
mm256_cvtepu8_epi32(void *ptr) {
return _mm256_cvtepu8_epi32(_mm_loadl_epi64((__m128i *) ptr));
}
#endif
15 changes: 0 additions & 15 deletions src/libImaging/ImagingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,3 @@ static float __attribute__((always_inline)) inline _i2f(int v) {
#else
static float inline _i2f(int v) { return (float)v; }
#endif


#if defined(__SSE4_2__)
static __m128i inline
mm_cvtepu8_epi32(void *ptr) {
return _mm_cvtepu8_epi32(_mm_cvtsi32_si128(*(INT32 *) ptr));
}
#endif

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

0 comments on commit be0fc48

Please sign in to comment.