Brian Cameron wrote:
>
> The attached change to liboil causes it to be built with GCC when
> building on x86 platforms, so that hardware acceleration support is
> enabled. The new patch uses the getisax(2) kernel function so that
> hardware acceleration support is determined using the correct Solaris
> kernel interface.
I can see why you want to do this. But I find this strange that GCC is
actually use in building some part of vermillion. Is this normal practise or
is this the first exception? Does this create any potential run-time problem
down the line?
No a linker/compiler expert, but like to ask some generic questions
here :)
-Ghee
>
> I have verified that liboil functions are 4-6 times faster using
> GCC so that the GCC-style assembly code for hardware acceleration
> gets compiled, and we don't just use the default C-implementations.
>
> Brian
>
>
> ------------------------------------------------------------------------
>
> Index: ChangeLog
> ===================================================================
> --- ChangeLog (revision 10499)
> +++ ChangeLog (working copy)
> @@ -1,5 +1,10 @@
> 2007-02-09 Brian Cameron <brian.cameron at sun.com>
>
> + * liboil.spec: Add patch to support Solaris hardware acelleration
> + support.
> +
> +2007-02-09 Brian Cameron <brian.cameron at sun.com>
> +
> * libtheora.spec: Bump to 1.0alpha7. Remove upstream patch,
> 01-noversionscript. Add --disable-asm to configure which
> corrects the problem that caused Damien to have compile
> Index: patches/liboil-01-detection.diff
> ===================================================================
> --- patches/liboil-01-detection.diff (revision 0)
> +++ patches/liboil-01-detection.diff (revision 0)
> @@ -0,0 +1,78 @@
> +--- liboil-0.3.10/liboil/cpu-orig.c 2007-02-09 12:52:11.759309000 +0800
> ++++ liboil-0.3.10/liboil/liboilcpu.c 2007-02-09 12:53:32.499187000 +0800
> +@@ -47,6 +47,10 @@
> + #include <sys/sysctl.h>
> + #endif
> +
> ++#ifdef __sun
> ++#include <sys/auxv.h>
> ++#endif
> ++
> + /**
> + * SECTION:liboilcpu
> + * @title: CPU
> +@@ -469,6 +473,41 @@ oil_cpu_detect_cpuid (void)
> + return;
> + }
> +
> ++#ifdef __sun
> ++ {
> ++ uint_t ui;
> ++
> ++ getisax (&ui, 1);
> ++
> ++ if (ui & AV_386_CMOV) {
> ++ oil_cpu_flags |= OIL_IMPL_FLAG_CMOV;
> ++ }
> ++ if (ui & AV_386_MMX) {
> ++ oil_cpu_flags |= OIL_IMPL_FLAG_MMX;
> ++ }
> ++ if (ui & AV_386_SSE) {
> ++ oil_cpu_flags |= OIL_IMPL_FLAG_SSE;
> ++ }
> ++ if (ui & AV_386_SSE2) {
> ++ oil_cpu_flags |= OIL_IMPL_FLAG_SSE2;
> ++ oil_cpu_flags |= OIL_IMPL_FLAG_MMXEXT;
> ++ }
> ++ if (ui & AV_386_SSE3) {
> ++ oil_cpu_flags |= OIL_IMPL_FLAG_SSE3;
> ++ }
> ++ if (ui & AV_386_AMD_3DNow) {
> ++ oil_cpu_flags |= OIL_IMPL_FLAG_3DNOW;
> ++ }
> ++ if (ui & AV_386_AMD_3DNowx) {
> ++ oil_cpu_flags |= OIL_IMPL_FLAG_3DNOWEXT;
> ++ }
> ++ if (ui & AV_386_AMD_MMX) {
> ++ oil_cpu_flags |= OIL_IMPL_FLAG_MMXEXT;
> ++ }
> ++ return;
> ++ }
> ++#endif
> ++
> + get_cpuid (0x00000001, &eax, &ebx, &ecx, &edx);
> +
> + if (edx & (1<<4)) {
> +@@ -542,7 +581,21 @@ oil_cpu_detect_kernel_support (void)
> + OIL_IMPL_FLAG_MMXEXT | OIL_IMPL_FLAG_SSE3);
> + }
> + #endif
> +-#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
> ++#ifdef __sun
> ++ {
> ++ uint_t ui;
> ++
> ++ getisax (&ui, 1);
> ++
> ++ if (ui & !AV_386_FXSR) {
> ++ oil_cpu_flags &= ~(OIL_IMPL_FLAG_SSE | OIL_IMPL_FLAG_SSE2 |
> ++ OIL_IMPL_FLAG_MMXEXT | OIL_IMPL_FLAG_SSE3);
> ++ oil_cpu_flags |= OIL_IMPL_FLAG_CMOV;
> ++ }
> ++ }
> ++#endif
> ++
> ++#if !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__) &&
> !defined(__sun)
> + /* If we don't know that the operating system supports SSE, don't trust
> that
> + * it will properly support it.
> + */
> Index: Solaris/ChangeLog
> ===================================================================
> --- Solaris/ChangeLog (revision 10497)
> +++ Solaris/ChangeLog (working copy)
> @@ -1,3 +1,8 @@
> +2007-02-09 Brian Cameron <brian.cameron at sun.com>
> +
> + * SUNWliboil.spec: Now build with gcc so that hardware acceleration
> + is supported when building on x86.
> +
> 2007-02-08 Damien Carbery <damien.carbery at sun.com>
>
> * SUNWgnome-desklets.spec, SUNWgnome-desklets-extra.spec: Update
> Index: Solaris/SUNWliboil.spec
> ===================================================================
> --- Solaris/SUNWliboil.spec (revision 10497)
> +++ Solaris/SUNWliboil.spec (working copy)
> @@ -24,6 +24,9 @@
> Requires: SUNWlibms
> BuildRequires: SUNWgnome-base-libs
> BuildRequires: SUNWgnome-base-libs-devel
> +#ifarch amd64 i386
> +BuildRequires: SUNWgcc
> +#endif
>
> %package devel
> Summary: %{summary} - development files
> @@ -35,14 +38,21 @@
> mkdir %name-%version
> %liboil.prep -d %name-%version
>
> +# Note, on x86 build with gcc since liboil contains GCC-style assembly
> +# code which won't compile with Sun Studio. For better performance,
> +# we use GCC here.
> +#
> %build
> export PKG_CONFIG_PATH=%{_pkg_config_path}
> export MSGFMT="/usr/bin/msgfmt"
> export ACLOCAL_FLAGS="-I %{_datadir}/aclocal"
> export PERL5LIB=%{_prefix}/perl5/site_perl/5.6.1/sun4-solaris-64int
> -export CFLAGS="%optflags -I%{_includedir}"
> +export CFLAGS="$CFLAGS -I%{_includedir}"
> export RPM_OPT_FLAGS="$CFLAGS"
> export LDFLAGS="%_ldflags"
> +#ifarch amd64 i386
> +export CC=gcc
> +#endif
>
> %liboil.build -d %name-%version
>
> @@ -72,6 +82,8 @@
> %{_libdir}/pkgconfig/*
>
> %changelog
> +* Wed Jan 31 2006 - brian.cameron at sun.com
> +- Build with gcc so that on x86 we compile hardware acceleration GCC asm
> code.
> * Wed Jun 14 2006 - brian.cameron at sun.com
> - Add new bindir files included in 0.3.9.
> * Sun Jun 11 2006 - laca at sun.com
> Index: liboil.spec
> ===================================================================
> --- liboil.spec (revision 10497)
> +++ liboil.spec (working copy)
> @@ -6,6 +6,7 @@
> # package are under the same license as the package itself.
> #
> # Owner: yippi
> +# bugdb: bugzilla.freedesktop.org
> #
> #####################################
> ## Package Information Section ##
> @@ -20,6 +21,8 @@
> Vendor: Sun Microsystems, Inc.
> Summary: The GNOME Structured File Library
> Source:
> http://liboil.freedesktop.org/download/%{name}-%version.tar.gz
> +# date:2007-02-09 owner:yippi type:bug bugster:9925
> +Patch1: liboil-01-detection.diff
> URL: http://liboil.freedesktop.org/wiki/
> BuildRoot: %{_tmppath}/%{name}-%{version}-build
> Docdir: %{_defaultdocdir}/doc
> @@ -79,6 +82,7 @@
>
> %prep
> %setup -q
> +%patch1 -p1
>
> #####################################
> ## Package Build Section ##
> @@ -144,6 +148,9 @@
> %{_datadir}/gtk-doc/*
>
> %changelog
> +* Fri Feb 09 2007 - brian.cameron at sun.com
> +- Add patch to support hardware acelleration detection on x86 when
> + building with GCC. Also add bugdb info.
> * Thu Nov 30 2006 - damien.carbery at sun.com
> - Bump to 0.3.10.
> * Fri Nov 3 2006 - laca at sun.com
>