gdkrgb: no vector code for CPUs it is not for
Every set of vector instructions was compiled on every system, as an empty function where it could not be built: MMX on PowerPC, AltiVec on x86. And a build for a CPU that has SSE2 anyway (x86-64, or -msse2 and later in CFLAGS) carried the MMX code, which SSE2 replaces wherever it runs; one for ARM with NEON carried ARMv6 code the same way. configure now builds only the sets of the CPU family built for, and none that a set the build can take for granted does entirely: no MMX where SSE2 is there anyway, no ARMv6 where NEON is. AArch64, where the NEON file was simply compiled without flags, is looked at like the others. The empty stand-ins are gone, and so are the files from the MSVC makefile, where none of them could be built.
This commit is contained in:
parent
fb2da8786c
commit
c1872f2e96
11 changed files with 109 additions and 67 deletions
72
configure.ac
72
configure.ac
|
|
@ -505,15 +505,21 @@ AC_CHECK_FUNCS(localtime_r)
|
|||
#
|
||||
# Vector instructions for GdkRGB. Each instruction set has a file of its
|
||||
# own, compiled with the flags found here; CPUs without it are told apart
|
||||
# at run time (getauxval() or elf_aux_info() where cpuid doesn't).
|
||||
# at run time (getauxval() or elf_aux_info() where cpuid doesn't). Only
|
||||
# the sets of the CPU family built for are built, and not those a set
|
||||
# the build may take for granted does entirely: no MMX where SSE2 is
|
||||
# there anyway (x86-64, or -msse2 and later in CFLAGS), no ARMv6 where
|
||||
# NEON is (AArch64, or -mfpu=neon).
|
||||
#
|
||||
AC_CHECK_FUNCS(getauxval elf_aux_info)
|
||||
|
||||
dnl GTK_CHECK_SIMD_FLAGS(NAME, FLAGS|OTHER FLAGS, PROLOGUE, BODY):
|
||||
dnl sets NAME_CFLAGS to the first flags the test compiles with
|
||||
dnl sets NAME_CFLAGS to the first flags the test compiles with (which may
|
||||
dnl be none), and gtk_have_NAME to yes if there are such flags
|
||||
AC_DEFUN([GTK_CHECK_SIMD_FLAGS],
|
||||
[AC_MSG_CHECKING([for flags to compile $1 code])
|
||||
$1_CFLAGS=
|
||||
gtk_have_$1=no
|
||||
gtk_save_CFLAGS="$CFLAGS"
|
||||
gtk_simd_list='$2'
|
||||
gtk_save_IFS="$IFS"
|
||||
|
|
@ -523,11 +529,16 @@ for gtk_simd_flags in $gtk_simd_list; do
|
|||
CFLAGS="$gtk_save_CFLAGS $gtk_simd_flags"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$3]], [[$4]])],
|
||||
[$1_CFLAGS="$gtk_simd_flags"
|
||||
gtk_have_$1=yes
|
||||
break])
|
||||
done
|
||||
IFS="$gtk_save_IFS"
|
||||
CFLAGS="$gtk_save_CFLAGS"
|
||||
AC_MSG_RESULT([${$1_CFLAGS:-none}])
|
||||
if test "x$gtk_have_$1" = xyes; then
|
||||
AC_MSG_RESULT([${$1_CFLAGS:-none needed}])
|
||||
else
|
||||
AC_MSG_RESULT([not possible])
|
||||
fi
|
||||
AC_SUBST($1_CFLAGS)])
|
||||
|
||||
MMX_CFLAGS=
|
||||
|
|
@ -537,14 +548,25 @@ AVX2_CFLAGS=
|
|||
ALTIVEC_CFLAGS=
|
||||
ARMV6_CFLAGS=
|
||||
NEON_CFLAGS=
|
||||
for gtk_set in MMX SSE2 SSSE3 AVX2 ALTIVEC ARMV6 NEON; do
|
||||
eval gtk_have_$gtk_set=no
|
||||
done
|
||||
case "$host_cpu" in
|
||||
i?86|x86_64|amd64)
|
||||
AC_MSG_CHECKING([whether the build may take SSE2 for granted])
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if !defined(__SSE2__) && !defined(__x86_64__)
|
||||
#error not for granted
|
||||
#endif]], [])],
|
||||
[gtk_base_sse2=yes], [gtk_base_sse2=no])
|
||||
AC_MSG_RESULT([$gtk_base_sse2])
|
||||
if test "x$gtk_base_sse2" = xno; then
|
||||
GTK_CHECK_SIMD_FLAGS([MMX], [-mmmx],
|
||||
[#include <mmintrin.h>
|
||||
#ifndef __MMX__
|
||||
#error no MMX
|
||||
#endif],
|
||||
[__m64 v = _mm_setzero_si64 (); v = _mm_mullo_pi16 (v, v); _mm_empty ();])
|
||||
fi
|
||||
GTK_CHECK_SIMD_FLAGS([SSE2], [-msse2],
|
||||
[#include <emmintrin.h>
|
||||
#ifndef __SSE2__
|
||||
|
|
@ -580,22 +602,62 @@ case "$host_cpu" in
|
|||
[vector unsigned short v = vec_splats ((unsigned short) 1); v = vec_mladd (v, v, v); (void) v;])
|
||||
;;
|
||||
arm*)
|
||||
AC_MSG_CHECKING([whether the build may take NEON for granted])
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if !defined(__ARM_NEON) && !defined(__ARM_NEON__)
|
||||
#error not for granted
|
||||
#endif]], [])],
|
||||
[gtk_base_neon=yes], [gtk_base_neon=no])
|
||||
AC_MSG_RESULT([$gtk_base_neon])
|
||||
dnl the media instructions of ARMv6, for builds for older ARMs too
|
||||
if test "x$gtk_base_neon" = xno; then
|
||||
GTK_CHECK_SIMD_FLAGS([ARMV6], [|-march=armv6],
|
||||
[#if !defined(__ARM_ARCH_6__) && !(defined(__ARM_ARCH) && __ARM_ARCH >= 6)
|
||||
#error no ARMv6
|
||||
#endif
|
||||
#if defined(__ARMEB__) || (defined(__thumb__) && !defined(__thumb2__))
|
||||
#error no little endian ARM code
|
||||
#endif],
|
||||
[unsigned int r, x = 1; __asm__ ("uxtab16 %0, %1, %2, ror #8" : "=r" (r) : "r" (x), "r" (x)); (void) r;])
|
||||
fi
|
||||
dnl toolchains for the Raspberry Pi 1 default to ARMv6, which has no NEON
|
||||
GTK_CHECK_SIMD_FLAGS([NEON], [-mfpu=neon|-march=armv7-a -mfpu=neon],
|
||||
[#include <arm_neon.h>
|
||||
#if !defined(__ARM_NEON) && !defined(__ARM_NEON__)
|
||||
#error no NEON
|
||||
#if (!defined(__ARM_NEON) && !defined(__ARM_NEON__)) || defined(__ARM_BIG_ENDIAN)
|
||||
#error no little endian NEON
|
||||
#endif],
|
||||
[uint8x8x4_t v = vld4_u8 ((const unsigned char *) 0); (void) v;])
|
||||
;;
|
||||
aarch64*|arm64*)
|
||||
dnl always there
|
||||
GTK_CHECK_SIMD_FLAGS([NEON], [],
|
||||
[#include <arm_neon.h>
|
||||
#if !defined(__ARM_NEON) || defined(__ARM_BIG_ENDIAN)
|
||||
#error no little endian NEON
|
||||
#endif],
|
||||
[uint8x8x4_t v = vld4_u8 ((const unsigned char *) 0); (void) v;])
|
||||
;;
|
||||
esac
|
||||
|
||||
for gtk_set in MMX SSE2 SSSE3 AVX2 ALTIVEC ARMV6 NEON; do
|
||||
if eval test "x\$gtk_have_$gtk_set" = xyes; then
|
||||
AC_DEFINE_UNQUOTED([GDK_RGB_SIMD_$gtk_set], [1])
|
||||
fi
|
||||
done
|
||||
AH_TEMPLATE([GDK_RGB_SIMD_MMX], [Define to build the MMX code of GdkRGB])
|
||||
AH_TEMPLATE([GDK_RGB_SIMD_SSE2], [Define to build the SSE2 code of GdkRGB])
|
||||
AH_TEMPLATE([GDK_RGB_SIMD_SSSE3], [Define to build the SSSE3 code of GdkRGB])
|
||||
AH_TEMPLATE([GDK_RGB_SIMD_AVX2], [Define to build the AVX2 code of GdkRGB])
|
||||
AH_TEMPLATE([GDK_RGB_SIMD_ALTIVEC], [Define to build the AltiVec code of GdkRGB])
|
||||
AH_TEMPLATE([GDK_RGB_SIMD_ARMV6], [Define to build the ARMv6 code of GdkRGB])
|
||||
AH_TEMPLATE([GDK_RGB_SIMD_NEON], [Define to build the NEON code of GdkRGB])
|
||||
AM_CONDITIONAL(GDK_RGB_SIMD_MMX, test "x$gtk_have_MMX" = xyes)
|
||||
AM_CONDITIONAL(GDK_RGB_SIMD_SSE2, test "x$gtk_have_SSE2" = xyes)
|
||||
AM_CONDITIONAL(GDK_RGB_SIMD_SSSE3, test "x$gtk_have_SSSE3" = xyes)
|
||||
AM_CONDITIONAL(GDK_RGB_SIMD_AVX2, test "x$gtk_have_AVX2" = xyes)
|
||||
AM_CONDITIONAL(GDK_RGB_SIMD_ALTIVEC, test "x$gtk_have_ALTIVEC" = xyes)
|
||||
AM_CONDITIONAL(GDK_RGB_SIMD_ARMV6, test "x$gtk_have_ARMV6" = xyes)
|
||||
AM_CONDITIONAL(GDK_RGB_SIMD_NEON, test "x$gtk_have_NEON" = xyes)
|
||||
|
||||
# _NL_TIME_FIRST_WEEKDAY is an enum and not a define
|
||||
AC_MSG_CHECKING([for _NL_TIME_FIRST_WEEKDAY])
|
||||
AC_LINK_IFELSE(
|
||||
|
|
|
|||
|
|
@ -167,9 +167,32 @@ common_sources = \
|
|||
gdkmarshalers.h
|
||||
|
||||
# Vector versions of GdkRGB loops, each built with the flags of its
|
||||
# instruction set. configure leaves the flags empty where the compiler
|
||||
# can't do them, and the file then has nothing but an empty function.
|
||||
noinst_LTLIBRARIES = \
|
||||
# instruction set; only those configure found useful for the CPU family
|
||||
# built for.
|
||||
gdk_rgb_simd_libs =
|
||||
if GDK_RGB_SIMD_MMX
|
||||
gdk_rgb_simd_libs += libgdk-rgb-mmx.la
|
||||
endif
|
||||
if GDK_RGB_SIMD_SSE2
|
||||
gdk_rgb_simd_libs += libgdk-rgb-sse2.la
|
||||
endif
|
||||
if GDK_RGB_SIMD_SSSE3
|
||||
gdk_rgb_simd_libs += libgdk-rgb-ssse3.la
|
||||
endif
|
||||
if GDK_RGB_SIMD_AVX2
|
||||
gdk_rgb_simd_libs += libgdk-rgb-avx2.la
|
||||
endif
|
||||
if GDK_RGB_SIMD_ALTIVEC
|
||||
gdk_rgb_simd_libs += libgdk-rgb-altivec.la
|
||||
endif
|
||||
if GDK_RGB_SIMD_ARMV6
|
||||
gdk_rgb_simd_libs += libgdk-rgb-armv6.la
|
||||
endif
|
||||
if GDK_RGB_SIMD_NEON
|
||||
gdk_rgb_simd_libs += libgdk-rgb-neon.la
|
||||
endif
|
||||
noinst_LTLIBRARIES = $(gdk_rgb_simd_libs)
|
||||
EXTRA_LTLIBRARIES = \
|
||||
libgdk-rgb-mmx.la \
|
||||
libgdk-rgb-sse2.la \
|
||||
libgdk-rgb-ssse3.la \
|
||||
|
|
@ -193,8 +216,6 @@ libgdk_rgb_armv6_la_CFLAGS = $(ARMV6_CFLAGS)
|
|||
libgdk_rgb_neon_la_SOURCES = gdkrgb-neon.c
|
||||
libgdk_rgb_neon_la_CFLAGS = $(NEON_CFLAGS)
|
||||
|
||||
gdk_rgb_simd_libs = $(noinst_LTLIBRARIES)
|
||||
|
||||
# Checks and times the kernels on this machine against the C code:
|
||||
# make rgbsimdbench && ./rgbsimdbench
|
||||
EXTRA_PROGRAMS = rgbsimdbench
|
||||
|
|
|
|||
|
|
@ -423,11 +423,4 @@ _gdk_rgb_simd_init_altivec (GdkRgbSimd *simd)
|
|||
simd->rgba_to_argb = rgba_to_argb;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_altivec (GdkRgbSimd *simd)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -308,11 +308,4 @@ _gdk_rgb_simd_init_armv6 (GdkRgbSimd *simd)
|
|||
simd->rgba_to_argb = rgba_to_argb;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_armv6 (GdkRgbSimd *simd)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -126,11 +126,4 @@ _gdk_rgb_simd_init_avx2 (GdkRgbSimd *simd)
|
|||
simd->rgba_to_argb = rgba_to_argb;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_avx2 (GdkRgbSimd *simd)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -470,11 +470,4 @@ void _gdk_rgb_simd_init_3dnowext (GdkRgbSimd *simd) { }
|
|||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
void _gdk_rgb_simd_init_mmx (GdkRgbSimd *simd) { }
|
||||
void _gdk_rgb_simd_init_mmxext (GdkRgbSimd *simd) { }
|
||||
void _gdk_rgb_simd_init_3dnow (GdkRgbSimd *simd) { }
|
||||
void _gdk_rgb_simd_init_3dnowext (GdkRgbSimd *simd) { }
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -241,11 +241,4 @@ _gdk_rgb_simd_init_neon (GdkRgbSimd *simd)
|
|||
simd->rgba_to_argb = rgba_to_argb;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_neon (GdkRgbSimd *simd)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -290,11 +290,4 @@ _gdk_rgb_simd_init_sse2 (GdkRgbSimd *simd)
|
|||
simd->rgba_to_argb = rgba_to_argb;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_sse2 (GdkRgbSimd *simd)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -214,11 +214,4 @@ _gdk_rgb_simd_init_ssse3 (GdkRgbSimd *simd)
|
|||
simd->rgba_to_argb = rgba_to_argb;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void
|
||||
_gdk_rgb_simd_init_ssse3 (GdkRgbSimd *simd)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -31,16 +31,31 @@
|
|||
* kernel comes from the last set that has it and the CPU can run */
|
||||
static const GdkRgbSimdSet all_sets[] =
|
||||
{
|
||||
#ifdef GDK_RGB_SIMD_MMX
|
||||
{ "mmx", _gdk_rgb_simd_init_mmx },
|
||||
{ "mmxext", _gdk_rgb_simd_init_mmxext },
|
||||
{ "3dnow", _gdk_rgb_simd_init_3dnow },
|
||||
{ "3dnowext", _gdk_rgb_simd_init_3dnowext },
|
||||
#endif
|
||||
#ifdef GDK_RGB_SIMD_SSE2
|
||||
{ "sse2", _gdk_rgb_simd_init_sse2 },
|
||||
#endif
|
||||
#ifdef GDK_RGB_SIMD_SSSE3
|
||||
{ "ssse3", _gdk_rgb_simd_init_ssse3 },
|
||||
#endif
|
||||
#ifdef GDK_RGB_SIMD_AVX2
|
||||
{ "avx2", _gdk_rgb_simd_init_avx2 },
|
||||
#endif
|
||||
#ifdef GDK_RGB_SIMD_ALTIVEC
|
||||
{ "altivec", _gdk_rgb_simd_init_altivec },
|
||||
#endif
|
||||
#ifdef GDK_RGB_SIMD_ARMV6
|
||||
{ "armv6", _gdk_rgb_simd_init_armv6 },
|
||||
#endif
|
||||
#ifdef GDK_RGB_SIMD_NEON
|
||||
{ "neon", _gdk_rgb_simd_init_neon },
|
||||
#endif
|
||||
{ NULL, NULL } /* not every build has any */
|
||||
};
|
||||
|
||||
static const GdkRgbSimdOp all_ops[] =
|
||||
|
|
@ -195,7 +210,7 @@ _gdk_rgb_simd_sets (gint *n_sets)
|
|||
if (n < 0)
|
||||
{
|
||||
n = 0;
|
||||
for (i = 0; i < G_N_ELEMENTS (all_sets); i++)
|
||||
for (i = 0; all_sets[i].name; i++)
|
||||
if (cpu_has (all_sets[i].name))
|
||||
{
|
||||
GdkRgbSimd probe = { NULL, };
|
||||
|
|
|
|||
|
|
@ -93,13 +93,6 @@ gdk_OBJECTS = \
|
|||
gdkregion-generic.obj \
|
||||
gdkrgb.obj \
|
||||
gdkrgbsimd.obj \
|
||||
gdkrgb-mmx.obj \
|
||||
gdkrgb-sse2.obj \
|
||||
gdkrgb-ssse3.obj \
|
||||
gdkrgb-avx2.obj \
|
||||
gdkrgb-altivec.obj \
|
||||
gdkrgb-armv6.obj \
|
||||
gdkrgb-neon.obj \
|
||||
gdkscreen.obj \
|
||||
gdkselection.obj \
|
||||
gdkvisual.obj \
|
||||
|
|
|
|||
Loading…
Reference in a new issue