From 7e72dfb78e4c6694c357760a21c52acad637840e Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Mon, 19 Sep 2016 22:39:58 +0100 Subject: [PATCH] Temporarily disable SIMD on aarch64 until upstream #97 is fixed, Add NEON fix for ARMv7 --- libjpeg-turbo-arm-neon.patch | 111 +++++++++++++++++++++++++++++++++++ libjpeg-turbo.spec | 17 +++++- 2 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 libjpeg-turbo-arm-neon.patch diff --git a/libjpeg-turbo-arm-neon.patch b/libjpeg-turbo-arm-neon.patch new file mode 100644 index 0000000..7338def --- /dev/null +++ b/libjpeg-turbo-arm-neon.patch @@ -0,0 +1,111 @@ +From 9055fb408dcb585ce9392d395e16630d51002152 Mon Sep 17 00:00:00 2001 +From: DRC +Date: Thu, 7 Jul 2016 13:10:30 -0500 +Subject: [PATCH] ARM/MIPS: Change the behavior of JSIMD_FORCE* + +The JSIMD_FORCE* environment variables previously meant "force the use +of this instruction set if it is available but others are available as +well", but that did nothing on ARM platforms, since there is only ever +one instruction set available. Since the ARM and MIPS CPU feature +detection code is less than bulletproof, and since there is only one +SIMD instruction set (currently) supported on those platforms, it makes +sense for the JSIMD_FORCE* environment variables on those platforms to +actually force the use of the SIMD instruction set, thus bypassing the +CPU feature detection code. + +This addresses a concern raised in #88 whereby parsing /proc/cpuinfo +didn't work within a QEMU environment. This at least provides a +workaround, allowing users to force-enable or force-disable SIMD +instructions for ARM and MIPS builds of libjpeg-turbo. +--- + ChangeLog.md | 23 +++++++++++++++++++++++ + simd/jsimd_arm.c | 2 +- + simd/jsimd_arm64.c | 2 +- + simd/jsimd_mips.c | 10 +++++++++- + 4 files changed, 34 insertions(+), 3 deletions(-) + +diff --git a/ChangeLog.md b/ChangeLog.md +index 0691ccc..9653471 100644 +--- a/ChangeLog.md ++++ b/ChangeLog.md +@@ -1,3 +1,26 @@ ++1.5.1 ++===== ++ ++### Significant changes relative to 1.5.0: ++ ++1. Previously, the undocumented `JSIMD_FORCE*` environment variables could be ++used to force-enable a particular SIMD instruction set if multiple instruction ++sets were available on a particular platform. On x86 platforms, where CPU ++feature detection is bulletproof and multiple SIMD instruction sets are ++available, it makes sense for those environment variables to allow forcing the ++use of an instruction set only if that instruction set is available. However, ++since the ARM implementations of libjpeg-turbo can only use one SIMD ++instruction set, and since their feature detection code is less bulletproof ++(parsing /proc/cpuinfo), it makes sense for the `JSIMD_FORCENEON` environment ++variable to bypass the feature detection code and really force the use of NEON ++instructions. A new environment variable (`JSIMD_FORCEDSPR2`) was introduced ++in the MIPS implementation for the same reasons, and the existing ++`JSIMD_FORCENONE` environment variable was extended to that implementation. ++These environment variables provide a workaround for those attempting to test ++ARM and MIPS builds of libjpeg-turbo in QEMU, which passes through ++/proc/cpuinfo from the host system. ++ ++ + 1.5.0 + ===== + +diff --git a/simd/jsimd_arm.c b/simd/jsimd_arm.c +index 754806d..61cd073 100644 +--- a/simd/jsimd_arm.c ++++ b/simd/jsimd_arm.c +@@ -125,7 +125,7 @@ init_simd (void) + /* Force different settings through environment variables */ + env = getenv("JSIMD_FORCENEON"); + if ((env != NULL) && (strcmp(env, "1") == 0)) +- simd_support &= JSIMD_ARM_NEON; ++ simd_support = JSIMD_ARM_NEON; + env = getenv("JSIMD_FORCENONE"); + if ((env != NULL) && (strcmp(env, "1") == 0)) + simd_support = 0; +diff --git a/simd/jsimd_arm64.c b/simd/jsimd_arm64.c +index 7def8f9..09449bb 100644 +--- a/simd/jsimd_arm64.c ++++ b/simd/jsimd_arm64.c +@@ -142,7 +142,7 @@ init_simd (void) + /* Force different settings through environment variables */ + env = getenv("JSIMD_FORCENEON"); + if ((env != NULL) && (strcmp(env, "1") == 0)) +- simd_support &= JSIMD_ARM_NEON; ++ simd_support = JSIMD_ARM_NEON; + env = getenv("JSIMD_FORCENONE"); + if ((env != NULL) && (strcmp(env, "1") == 0)) + simd_support = 0; +diff --git a/simd/jsimd_mips.c b/simd/jsimd_mips.c +index 358bbb8..63b8115 100644 +--- a/simd/jsimd_mips.c ++++ b/simd/jsimd_mips.c +@@ -2,7 +2,7 @@ + * jsimd_mips.c + * + * Copyright 2009 Pierre Ossman for Cendio AB +- * Copyright (C) 2009-2011, 2014, D. R. Commander. ++ * Copyright (C) 2009-2011, 2014, 2016, D. R. Commander. + * Copyright (C) 2013-2014, MIPS Technologies, Inc., California. + * Copyright (C) 2015, Matthieu Darbois. + * +@@ -77,6 +77,14 @@ init_simd (void) + if (!parse_proc_cpuinfo("MIPS 74K")) + return; + #endif ++ ++ /* Force different settings through environment variables */ ++ env = getenv("JSIMD_FORCEDSPR2"); ++ if ((env != NULL) && (strcmp(env, "1") == 0)) ++ simd_support = JSIMD_MIPS_DSPR2; ++ env = getenv("JSIMD_FORCENONE"); ++ if ((env != NULL) && (strcmp(env, "1") == 0)) ++ simd_support = 0; + } + + static const int mips_idct_ifast_coefs[4] = { diff --git a/libjpeg-turbo.spec b/libjpeg-turbo.spec index 2d9705e..b6b5a48 100644 --- a/libjpeg-turbo.spec +++ b/libjpeg-turbo.spec @@ -1,6 +1,6 @@ Name: libjpeg-turbo Version: 1.5.0 -Release: 2%{?dist} +Release: 3%{?dist} Summary: A MMX/SSE2/SIMD accelerated library for manipulating JPEG image files License: IJG URL: http://sourceforge.net/projects/libjpeg-turbo @@ -9,6 +9,7 @@ Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar. Patch0: libjpeg-turbo14-noinst.patch Patch1: libjpeg-turbo-header-files.patch Patch2: libjpeg-turbo-aarch64.patch +Patch3: libjpeg-turbo-arm-neon.patch BuildRequires: autoconf BuildRequires: automake @@ -73,11 +74,17 @@ manipulate JPEG files using the TurboJPEG library. %patch0 -p1 -b .noinst %patch1 -p1 -b .header-files %patch2 -p1 -b .aarch64 +%patch3 -p1 -b .neon %build autoreconf -vif -%configure --disable-static -make %{?_smp_mflags} +%configure \ +%ifarch aarch64 +--without-simd \ +%endif +--disable-static + +make %{?_smp_mflags} V=1 %install make install DESTDIR=%{buildroot} @@ -169,6 +176,10 @@ make test %{?_smp_mflags} %{_libdir}/pkgconfig/libturbojpeg.pc %changelog +* Mon Sep 19 2016 Peter Robinson 1.5.0-3 +- Temporarily disable SIMD on aarch64 until upstream #97 is fixed +- Add NEON fix for ARMv7 + * Tue Sep 13 2016 Peter Robinson 1.5.0-2 - Add upstream fix to fix SIMD crash on aarch64 (rhbz #1368569)