From 342c4eab2a0565de456f1f3efcc41b635544160e Mon Sep 17 00:00:00 2001 From: Matt Sarett Date: Thu, 18 Feb 2016 12:43:50 -0500 Subject: [PATCH] Move sse opts into contrib/intel --- Makefile.am | 5 -- configure.ac | 35 -------------- contrib/intel/Makefile.am.patch | 17 +++++++ contrib/intel/configure.ac.patch | 46 +++++++++++++++++++ .../intel}/filter_sse2_intrinsics.c | 0 {intel => contrib/intel}/intel_init.c | 0 pngpriv.h | 14 ++++-- 7 files changed, 73 insertions(+), 44 deletions(-) create mode 100644 contrib/intel/Makefile.am.patch create mode 100644 contrib/intel/configure.ac.patch rename {intel => contrib/intel}/filter_sse2_intrinsics.c (100%) rename {intel => contrib/intel}/intel_init.c (100%) diff --git a/Makefile.am b/Makefile.am index 646bb236a..73097dbcc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -83,11 +83,6 @@ 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 \ diff --git a/configure.ac b/configure.ac index c768e9ba9..10538fcc4 100644 --- a/configure.ac +++ b/configure.ac @@ -314,41 +314,6 @@ 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 - i?86|x86_64) :;; - *) test "$enable_intel_sse" != '';; - esac]) - AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]]) # Config files, substituting as above diff --git a/contrib/intel/Makefile.am.patch b/contrib/intel/Makefile.am.patch new file mode 100644 index 000000000..2f119cd6a --- /dev/null +++ b/contrib/intel/Makefile.am.patch @@ -0,0 +1,17 @@ + +# +# Copyright (c) 2016 Google, Inc. +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h +# + +# In order to compile Intel SSE optimizations for libpng, please add +# the following code to Makefile.am directly beneath the +# "if PNG_ARM_NEON ... endif" statement. + +if PNG_INTEL_SSE +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += intel/intel_init.c\ + intel/filter_sse2_intrinsics.c +endif diff --git a/contrib/intel/configure.ac.patch b/contrib/intel/configure.ac.patch new file mode 100644 index 000000000..fec654953 --- /dev/null +++ b/contrib/intel/configure.ac.patch @@ -0,0 +1,46 @@ +# +# Copyright (c) 2016 Google, Inc. +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h +# + +# In order to compile Intel SSE optimizations for libpng, please add +# the following code to configure.ac under HOST SPECIFIC OPTIONS +# directly beneath the section for ARM. + +# 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 + i?86|x86_64) :;; + *) test "$enable_intel_sse" != '';; + esac]) diff --git a/intel/filter_sse2_intrinsics.c b/contrib/intel/filter_sse2_intrinsics.c similarity index 100% rename from intel/filter_sse2_intrinsics.c rename to contrib/intel/filter_sse2_intrinsics.c diff --git a/intel/intel_init.c b/contrib/intel/intel_init.c similarity index 100% rename from intel/intel_init.c rename to contrib/intel/intel_init.c diff --git a/pngpriv.h b/pngpriv.h index a402704f8..0ac16fadd 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -183,10 +183,16 @@ #endif /* PNG_ARM_NEON_OPT > 0 */ #ifndef PNG_INTEL_SSE_OPT -# 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 +# ifdef PNG_INTEL_SSE + /* Only check for SSE if the build configuration has been modified to + * enable SSE optimizations. This means that these optimizations will + * be off by default. See contrib/intel for more details. + */ +# 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 #endif