112 lines
4.4 KiB
Diff
112 lines
4.4 KiB
Diff
From 9055fb408dcb585ce9392d395e16630d51002152 Mon Sep 17 00:00:00 2001
|
|
From: DRC <information@libjpeg-turbo.org>
|
|
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 <ossman@cendio.se> 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] = {
|