Add intel opts to Makefile and configure.ac

This commit is contained in:
Matt Sarett 2016-02-17 11:43:34 -05:00
parent 5bc58a0ebc
commit 9a308a3344
5 changed files with 67 additions and 15 deletions

View File

@ -83,6 +83,11 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\
arm/filter_neon.S arm/filter_neon_intrinsics.c
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
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \

View File

@ -314,6 +314,41 @@ AM_CONDITIONAL([PNG_ARM_NEON],
*) test "$enable_arm_neon" != '';;
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]])
# Config files, substituting as above

View File

@ -12,7 +12,7 @@
#ifdef PNG_READ_SUPPORTED
#if PNG_INTEL_SSE_OPT > 0
#if PNG_INTEL_SSE_IMPLEMENTATION > 0
#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.
static __m128i abs_i16(__m128i x) {
#if PNG_INTEL_SSE_OPT >= 2
#if PNG_INTEL_SSE_IMPLEMENTATION >= 2
return _mm_abs_epi16(x);
#else
// Read this all as, return x<0 ? -x : x.
@ -162,7 +162,7 @@ static __m128i abs_i16(__m128i x) {
// Bytewise c ? t : 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);
#else
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 */

View File

@ -11,7 +11,7 @@
#include "../pngpriv.h"
#ifdef PNG_READ_SUPPORTED
#if PNG_INTEL_SSE_OPT > 0
#if PNG_INTEL_SSE_IMPLEMENTATION > 0
void
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.
}
#endif /* PNG_INTEL_SSE_OPT > 0 */
#endif /* PNG_INTEL_SSE_IMPLEMENTATION > 0 */
#endif /* PNG_READ_SUPPORTED */

View File

@ -183,21 +183,33 @@
#endif /* PNG_ARM_NEON_OPT > 0 */
#ifndef PNG_INTEL_SSE_OPT
# 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_OPT 3
# elif defined(__SSSE3__)
# define PNG_INTEL_SSE_OPT 2
# elif defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \
# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \
defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \
(defined(_M_IX86_FP) && _M_IX86_FP >= 2)
# define PNG_INTEL_SSE_OPT 1
# endif
#endif
#if PNG_INTEL_SSE_OPT > 0
# 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
/* Is this a build of a DLL where compilation of the object modules requires