Add intel opts to Makefile and configure.ac
This commit is contained in:
parent
5bc58a0ebc
commit
9a308a3344
@ -83,6 +83,11 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\
|
|||||||
arm/filter_neon.S arm/filter_neon_intrinsics.c
|
arm/filter_neon.S arm/filter_neon_intrinsics.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if PNG_INTEL_SSE
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += intel/intel_init.c\
|
||||||
|
intel/filter_sse2_intrinsics.c
|
||||||
|
endif
|
||||||
|
|
||||||
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
||||||
|
|
||||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \
|
||||||
|
35
configure.ac
35
configure.ac
@ -314,6 +314,41 @@ AM_CONDITIONAL([PNG_ARM_NEON],
|
|||||||
*) test "$enable_arm_neon" != '';;
|
*) test "$enable_arm_neon" != '';;
|
||||||
esac])
|
esac])
|
||||||
|
|
||||||
|
# INTEL
|
||||||
|
# ===
|
||||||
|
#
|
||||||
|
# INTEL SSE (SIMD) support.
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([intel-sse],
|
||||||
|
AS_HELP_STRING([[[--enable-intel-sse]]],
|
||||||
|
[Enable Intel SSE optimizations: =no/off, yes/on:]
|
||||||
|
[no/off: disable the optimizations;]
|
||||||
|
[yes/on: enable the optimizations.]
|
||||||
|
[If not specified: determined by the compiler.]),
|
||||||
|
[case "$enableval" in
|
||||||
|
no|off)
|
||||||
|
# disable the default enabling:
|
||||||
|
AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
|
||||||
|
[Disable Intel SSE optimizations])
|
||||||
|
# Prevent inclusion of the assembler files below:
|
||||||
|
enable_intel_sse=no;;
|
||||||
|
yes|on)
|
||||||
|
AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
|
||||||
|
[Enable Intel SSE optimizations]);;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value])
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# Add Intel specific files to all builds where the host_cpu is Intel ('x86*')
|
||||||
|
# or where Intel optimizations were explicitly requested (this allows a
|
||||||
|
# fallback if a future host CPU does not match 'x86*')
|
||||||
|
AM_CONDITIONAL([PNG_INTEL_SSE],
|
||||||
|
[test "$enable_intel_sse" != 'no' &&
|
||||||
|
case "$host_cpu" in
|
||||||
|
x86*) :;;
|
||||||
|
*) test "$enable_intel_sse" != '';;
|
||||||
|
esac])
|
||||||
|
|
||||||
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
|
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
|
||||||
|
|
||||||
# Config files, substituting as above
|
# Config files, substituting as above
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#ifdef PNG_READ_SUPPORTED
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
|
||||||
#if PNG_INTEL_SSE_OPT > 0
|
#if PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||||
|
|
||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ void png_read_filter_row_avg4_sse2(png_row_infop row_info, png_bytep row,
|
|||||||
|
|
||||||
// Returns |x| for 16-bit lanes.
|
// Returns |x| for 16-bit lanes.
|
||||||
static __m128i abs_i16(__m128i x) {
|
static __m128i abs_i16(__m128i x) {
|
||||||
#if PNG_INTEL_SSE_OPT >= 2
|
#if PNG_INTEL_SSE_IMPLEMENTATION >= 2
|
||||||
return _mm_abs_epi16(x);
|
return _mm_abs_epi16(x);
|
||||||
#else
|
#else
|
||||||
// Read this all as, return x<0 ? -x : x.
|
// Read this all as, return x<0 ? -x : x.
|
||||||
@ -162,7 +162,7 @@ static __m128i abs_i16(__m128i x) {
|
|||||||
|
|
||||||
// Bytewise c ? t : e.
|
// Bytewise c ? t : e.
|
||||||
static __m128i if_then_else(__m128i c, __m128i t, __m128i e) {
|
static __m128i if_then_else(__m128i c, __m128i t, __m128i e) {
|
||||||
#if PNG_INTEL_SSE_OPT >= 3
|
#if PNG_INTEL_SSE_IMPLEMENTATION >= 3
|
||||||
return _mm_blendv_epi8(e,t,c);
|
return _mm_blendv_epi8(e,t,c);
|
||||||
#else
|
#else
|
||||||
return _mm_or_si128(_mm_and_si128(c, t), _mm_andnot_si128(c, e));
|
return _mm_or_si128(_mm_and_si128(c, t), _mm_andnot_si128(c, e));
|
||||||
@ -281,5 +281,5 @@ void png_read_filter_row_paeth4_sse2(png_row_infop row_info, png_bytep row,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* PNG_INTEL_SSE_OPT > 0 */
|
#endif /* PNG_INTEL_SSE_IMPLEMENTATION > 0 */
|
||||||
#endif /* READ */
|
#endif /* READ */
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "../pngpriv.h"
|
#include "../pngpriv.h"
|
||||||
|
|
||||||
#ifdef PNG_READ_SUPPORTED
|
#ifdef PNG_READ_SUPPORTED
|
||||||
#if PNG_INTEL_SSE_OPT > 0
|
#if PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||||
|
|
||||||
void
|
void
|
||||||
png_init_filter_functions_sse2(png_structp pp, unsigned int bpp)
|
png_init_filter_functions_sse2(png_structp pp, unsigned int bpp)
|
||||||
@ -41,5 +41,5 @@ png_init_filter_functions_sse2(png_structp pp, unsigned int bpp)
|
|||||||
// No need optimize PNG_FILTER_VALUE_UP. The compiler should autovectorize.
|
// No need optimize PNG_FILTER_VALUE_UP. The compiler should autovectorize.
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* PNG_INTEL_SSE_OPT > 0 */
|
#endif /* PNG_INTEL_SSE_IMPLEMENTATION > 0 */
|
||||||
#endif /* PNG_READ_SUPPORTED */
|
#endif /* PNG_READ_SUPPORTED */
|
||||||
|
30
pngpriv.h
30
pngpriv.h
@ -183,21 +183,33 @@
|
|||||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||||
|
|
||||||
#ifndef PNG_INTEL_SSE_OPT
|
#ifndef PNG_INTEL_SSE_OPT
|
||||||
# if defined(__SSE4_1__) || defined(__AVX__)
|
# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \
|
||||||
/* We are not actually using AVX, but checking for AVX is the best
|
defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \
|
||||||
way we can detect SSE4.1 and SSSE3 on MSVC.
|
|
||||||
*/
|
|
||||||
# define PNG_INTEL_SSE_OPT 3
|
|
||||||
# elif defined(__SSSE3__)
|
|
||||||
# define PNG_INTEL_SSE_OPT 2
|
|
||||||
# elif defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \
|
|
||||||
(defined(_M_IX86_FP) && _M_IX86_FP >= 2)
|
(defined(_M_IX86_FP) && _M_IX86_FP >= 2)
|
||||||
# define PNG_INTEL_SSE_OPT 1
|
# define PNG_INTEL_SSE_OPT 1
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PNG_INTEL_SSE_OPT > 0
|
#if PNG_INTEL_SSE_OPT > 0
|
||||||
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_sse2
|
# ifndef PNG_INTEL_SSE_IMPLEMENTATION
|
||||||
|
# if defined(__SSE4_1__) || defined(__AVX__)
|
||||||
|
/* We are not actually using AVX, but checking for AVX is the best
|
||||||
|
way we can detect SSE4.1 and SSSE3 on MSVC.
|
||||||
|
*/
|
||||||
|
# define PNG_INTEL_SSE_IMPLEMENTATION 3
|
||||||
|
# elif defined(__SSSE3__)
|
||||||
|
# define PNG_INTEL_SSE_IMPLEMENTATION 2
|
||||||
|
# elif defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \
|
||||||
|
(defined(_M_IX86_FP) && _M_IX86_FP >= 2)
|
||||||
|
# define PNG_INTEL_SSE_IMPLEMENTATION 1
|
||||||
|
# else
|
||||||
|
# define PNG_INTEL_SSE_IMPLEMENTATION 0
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||||
|
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_sse2
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Is this a build of a DLL where compilation of the object modules requires
|
/* Is this a build of a DLL where compilation of the object modules requires
|
||||||
|
Loading…
Reference in New Issue
Block a user