Re: [Mesa-dev] [PATCH 1/2] configure/swr: configurable swr architectures

2017-07-19 Thread Emil Velikov
On 18 July 2017 at 22:59, Rowley, Timothy O  wrote:

>> You want to move the AVX flag detection here, right?
>
> No, since we need to have SWR_AVX_CXXFLAGS to build the driver proper.
>
Arg... that unusual thingy always gets me. Thanks for the correction.

-Emil
P.S. Sigh HTML emails and redoing the formatting :-(
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure/swr: configurable swr architectures

2017-07-18 Thread Rowley, Timothy O

On Jul 17, 2017, at 11:42 AM, Emil Velikov 
mailto:emil.l.veli...@gmail.com>> wrote:

On 17 July 2017 at 15:08, Tim Rowley 
mailto:timothy.o.row...@intel.com>> wrote:
Allow configuration of the SWR architecture depend libraries
we build for with --with-swr-archs.  Maintains current behavior
by defaulting to avx,avx2.

Scons changes made to make it still build and work, but
without the changes for configuring which architectures.
---
configure.ac   | 39 ++
src/gallium/drivers/swr/Makefile.am| 17 ++-
src/gallium/drivers/swr/SConscript |  1 +
src/gallium/drivers/swr/swr_loader.cpp | 22 +++
4 files changed, 70 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index 46fcd8f3fe..3a8fa4d7ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2349,6 +2349,15 @@ AC_ARG_WITH([d3d-libdir],
[D3D_DRIVER_INSTALL_DIR="${libdir}/d3d"])
AC_SUBST([D3D_DRIVER_INSTALL_DIR])

+dnl Architectures to build SWR library for
+
+AC_ARG_WITH([swr-archs],
+[AS_HELP_STRING([--with-swr-archs@<:@=DIRS...@:>@],
+[comma delimited swr architectures list, e.g.
+"avx,avx2" @<:@default="avx,avx2"@:>@])],
+[with_swr_archs="$withval"],
+[with_swr_archs="avx avx2"])
Add the missing comma - "avx,avx2”

Will do.


+
dnl
dnl r300 doesn't strictly require LLVM, but for performance reasons we
dnl highly recommend LLVM usage. So require it at least on x86 and x86_64
@@ -2496,10 +2505,24 @@ if test -n "$with_gallium_drivers"; then
SWR_AVX_CXXFLAGS
AC_SUBST([SWR_AVX_CXXFLAGS])

-swr_require_cxx_feature_flags "AVX2" "defined(__AVX2__)" \
-",-mavx2 -mfma -mbmi2 -mf16c,-march=core-avx2" \
-SWR_AVX2_CXXFLAGS
-AC_SUBST([SWR_AVX2_CXXFLAGS])
+swr_archs=`IFS=', '; echo $with_swr_archs`
+for arch in $swr_archs; do
+case "x$arch" in
+xavx)
You want to move the AVX flag detection here, right?

No, since we need to have SWR_AVX_CXXFLAGS to build the driver proper.


+HAVE_SWR_AVX=yes
+;;
+xavx2)
+swr_require_cxx_feature_flags "AVX2" "defined(__AVX2__)" \
+",-mavx2 -mfma -mbmi2 -mf16c,-march=core-avx2" \
+SWR_AVX2_CXXFLAGS
+AC_SUBST([SWR_AVX2_CXXFLAGS])
+HAVE_SWR_AVX2=yes
+;;
+*)
+AC_MSG_ERROR([unknown SWR build architecture '$arch'])
+;;
+esac
+done

And error out if building without any arch?

Added.

HAVE_GALLIUM_SWR=yes
;;
@@ -2538,6 +2561,9 @@ if test "x$enable_llvm" = "xyes" -a 
"$with_gallium_drivers"; then
llvm_add_default_components "gallium"
fi

+AM_CONDITIONAL(HAVE_SWR_AVX, test "x$HAVE_SWR_AVX" = xyes)
+AM_CONDITIONAL(HAVE_SWR_AVX2, test "x$HAVE_SWR_AVX2" = xyes)
+
dnl We need to validate some needed dependencies for renderonly drivers.

if test "x$HAVE_GALLIUM_ETNAVIV" != xyes -a "x$HAVE_GALLIUM_IMX" = xyes  ; then
@@ -2977,6 +3003,11 @@ else
echo "HUD lmsensors:   yes"
fi

+echo ""
+if test "x$HAVE_GALLIUM_SWR" != x; then
+echo "SWR archs:   $swr_archs"
+fi
+
dnl Libraries
echo ""
echo "Shared libs: $enable_shared"
diff --git a/src/gallium/drivers/swr/Makefile.am 
b/src/gallium/drivers/swr/Makefile.am
index 74612280fe..f38ce7b1d9 100644
--- a/src/gallium/drivers/swr/Makefile.am
+++ b/src/gallium/drivers/swr/Makefile.am
@@ -55,6 +55,14 @@ libmesaswr_la_CXXFLAGS = \
   $(SWR_AVX_CXXFLAGS) \
   $(COMMON_CXXFLAGS)

+if HAVE_SWR_AVX
+libmesaswr_la_CXXFLAGS += -DHAVE_SWR_AVX
+endif
+
+if HAVE_SWR_AVX2
+libmesaswr_la_CXXFLAGS += -DHAVE_SWR_AVX2
+endif
+
COMMON_SOURCES = \
   $(ARCHRAST_CXX_SOURCES) \
   $(COMMON_CXX_SOURCES) \
@@ -224,7 +232,10 @@ COMMON_LDFLAGS = \
   $(GC_SECTIONS) \
   $(NO_UNDEFINED)

-lib_LTLIBRARIES = libswrAVX.la 
libswrAVX2.la
+lib_LTLIBRARIES =
+
+if HAVE_SWR_AVX
+lib_LTLIBRARIES += libswrAVX.la

libswrAVX_la_CXXFLAGS = \
   $(SWR_AVX_CXXFLAGS) \
@@ -236,7 +247,10 @@ libswrAVX_la_SOURCES = \

libswrAVX_la_LDFLAGS = \
   $(COMMON_LDFLAGS)
+endif

+if HAVE_SWR_AVX2
+lib_LTLIBRARIES += libswrAVX2.la
libswrAVX2_la_CXXFLAGS = \
   $(SWR_AVX2_CXXFLAGS) \
   -DKNOB_ARCH=KNOB_ARCH_AVX2 \
@@ -247,6 +261,7 @@ libswrAVX2_la_SOURCES = \

libswrAVX2_la_LDFLAGS = \
   $(COMMON_LDFLAGS)
+endif

include $(top_srcdir)/install-gallium-links.mk

diff --git a/src/gallium/drivers/swr/SConscript 
b/src/gallium/drivers/swr/SConscript
index cdfb91a5bb..a32807d36b 100644
--- a/src/gallium/drivers/swr/SConscript
+++ b/src/gallium/drivers/swr/SConscript
@@ -245,6 +245,7 @@ source += [

# main SWR lib
envSWR = envavx.Clone() # 

Re: [Mesa-dev] [PATCH 1/2] configure/swr: configurable swr architectures

2017-07-17 Thread Emil Velikov
On 17 July 2017 at 15:08, Tim Rowley  wrote:
> Allow configuration of the SWR architecture depend libraries
> we build for with --with-swr-archs.  Maintains current behavior
> by defaulting to avx,avx2.
>
> Scons changes made to make it still build and work, but
> without the changes for configuring which architectures.
> ---
>  configure.ac   | 39 
> ++
>  src/gallium/drivers/swr/Makefile.am| 17 ++-
>  src/gallium/drivers/swr/SConscript |  1 +
>  src/gallium/drivers/swr/swr_loader.cpp | 22 +++
>  4 files changed, 70 insertions(+), 9 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 46fcd8f3fe..3a8fa4d7ea 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -2349,6 +2349,15 @@ AC_ARG_WITH([d3d-libdir],
>  [D3D_DRIVER_INSTALL_DIR="${libdir}/d3d"])
>  AC_SUBST([D3D_DRIVER_INSTALL_DIR])
>
> +dnl Architectures to build SWR library for
> +
> +AC_ARG_WITH([swr-archs],
> +[AS_HELP_STRING([--with-swr-archs@<:@=DIRS...@:>@],
> +[comma delimited swr architectures list, e.g.
> +"avx,avx2" @<:@default="avx,avx2"@:>@])],
> +[with_swr_archs="$withval"],
> +[with_swr_archs="avx avx2"])
Add the missing comma - "avx,avx2"

> +
>  dnl
>  dnl r300 doesn't strictly require LLVM, but for performance reasons we
>  dnl highly recommend LLVM usage. So require it at least on x86 and x86_64
> @@ -2496,10 +2505,24 @@ if test -n "$with_gallium_drivers"; then
>  SWR_AVX_CXXFLAGS
>  AC_SUBST([SWR_AVX_CXXFLAGS])
>
> -swr_require_cxx_feature_flags "AVX2" "defined(__AVX2__)" \
> -",-mavx2 -mfma -mbmi2 -mf16c,-march=core-avx2" \
> -SWR_AVX2_CXXFLAGS
> -AC_SUBST([SWR_AVX2_CXXFLAGS])
> +swr_archs=`IFS=', '; echo $with_swr_archs`
> +for arch in $swr_archs; do
> +case "x$arch" in
> +xavx)
You want to move the AVX flag detection here, right?

> +HAVE_SWR_AVX=yes
> +;;
> +xavx2)
> +swr_require_cxx_feature_flags "AVX2" "defined(__AVX2__)" 
> \
> +",-mavx2 -mfma -mbmi2 -mf16c,-march=core-avx2" \
> +SWR_AVX2_CXXFLAGS
> +AC_SUBST([SWR_AVX2_CXXFLAGS])
> +HAVE_SWR_AVX2=yes
> +;;
> +*)
> +AC_MSG_ERROR([unknown SWR build architecture '$arch'])
> +;;
> +esac
> +done
>
And error out if building without any arch?

>  HAVE_GALLIUM_SWR=yes
>  ;;
> @@ -2538,6 +2561,9 @@ if test "x$enable_llvm" = "xyes" -a 
> "$with_gallium_drivers"; then
>  llvm_add_default_components "gallium"
>  fi
>
> +AM_CONDITIONAL(HAVE_SWR_AVX, test "x$HAVE_SWR_AVX" = xyes)
> +AM_CONDITIONAL(HAVE_SWR_AVX2, test "x$HAVE_SWR_AVX2" = xyes)
> +
>  dnl We need to validate some needed dependencies for renderonly drivers.
>
>  if test "x$HAVE_GALLIUM_ETNAVIV" != xyes -a "x$HAVE_GALLIUM_IMX" = xyes  ; 
> then
> @@ -2977,6 +3003,11 @@ else
>  echo "HUD lmsensors:   yes"
>  fi
>
> +echo ""
> +if test "x$HAVE_GALLIUM_SWR" != x; then
> +echo "SWR archs:   $swr_archs"
> +fi
> +
>  dnl Libraries
>  echo ""
>  echo "Shared libs: $enable_shared"
> diff --git a/src/gallium/drivers/swr/Makefile.am 
> b/src/gallium/drivers/swr/Makefile.am
> index 74612280fe..f38ce7b1d9 100644
> --- a/src/gallium/drivers/swr/Makefile.am
> +++ b/src/gallium/drivers/swr/Makefile.am
> @@ -55,6 +55,14 @@ libmesaswr_la_CXXFLAGS = \
> $(SWR_AVX_CXXFLAGS) \
> $(COMMON_CXXFLAGS)
>
> +if HAVE_SWR_AVX
> +libmesaswr_la_CXXFLAGS += -DHAVE_SWR_AVX
> +endif
> +
> +if HAVE_SWR_AVX2
> +libmesaswr_la_CXXFLAGS += -DHAVE_SWR_AVX2
> +endif
> +
>  COMMON_SOURCES = \
> $(ARCHRAST_CXX_SOURCES) \
> $(COMMON_CXX_SOURCES) \
> @@ -224,7 +232,10 @@ COMMON_LDFLAGS = \
> $(GC_SECTIONS) \
> $(NO_UNDEFINED)
>
> -lib_LTLIBRARIES = libswrAVX.la libswrAVX2.la
> +lib_LTLIBRARIES =
> +
> +if HAVE_SWR_AVX
> +lib_LTLIBRARIES += libswrAVX.la
>
>  libswrAVX_la_CXXFLAGS = \
> $(SWR_AVX_CXXFLAGS) \
> @@ -236,7 +247,10 @@ libswrAVX_la_SOURCES = \
>
>  libswrAVX_la_LDFLAGS = \
> $(COMMON_LDFLAGS)
> +endif
>
> +if HAVE_SWR_AVX2
> +lib_LTLIBRARIES += libswrAVX2.la
>  libswrAVX2_la_CXXFLAGS = \
> $(SWR_AVX2_CXXFLAGS) \
> -DKNOB_ARCH=KNOB_ARCH_AVX2 \
> @@ -247,6 +261,7 @@ libswrAVX2_la_SOURCES = \
>
>  libswrAVX2_la_LDFLAGS = \
> $(COMMON_LDFLAGS)
> +endif
>
>  include $(top_srcdir)/install-gallium-links.mk
>
> diff --git a/src/gallium/drivers/swr/SConscript 
> b/src/gallium/drivers/swr/SConscript
> index cdfb91a5bb..a32807d36b 100644
> --- a/src/gallium/drivers/swr/SConscript
> +++ b/src/gallium/drivers/swr/SConscript
> @@ -245,6 +245,7 @@ source += [
>
>  # main SWR lib
>  envS

[Mesa-dev] [PATCH 1/2] configure/swr: configurable swr architectures

2017-07-17 Thread Tim Rowley
Allow configuration of the SWR architecture depend libraries
we build for with --with-swr-archs.  Maintains current behavior
by defaulting to avx,avx2.

Scons changes made to make it still build and work, but
without the changes for configuring which architectures.
---
 configure.ac   | 39 ++
 src/gallium/drivers/swr/Makefile.am| 17 ++-
 src/gallium/drivers/swr/SConscript |  1 +
 src/gallium/drivers/swr/swr_loader.cpp | 22 +++
 4 files changed, 70 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index 46fcd8f3fe..3a8fa4d7ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2349,6 +2349,15 @@ AC_ARG_WITH([d3d-libdir],
 [D3D_DRIVER_INSTALL_DIR="${libdir}/d3d"])
 AC_SUBST([D3D_DRIVER_INSTALL_DIR])
 
+dnl Architectures to build SWR library for
+
+AC_ARG_WITH([swr-archs],
+[AS_HELP_STRING([--with-swr-archs@<:@=DIRS...@:>@],
+[comma delimited swr architectures list, e.g.
+"avx,avx2" @<:@default="avx,avx2"@:>@])],
+[with_swr_archs="$withval"],
+[with_swr_archs="avx avx2"])
+
 dnl
 dnl r300 doesn't strictly require LLVM, but for performance reasons we
 dnl highly recommend LLVM usage. So require it at least on x86 and x86_64
@@ -2496,10 +2505,24 @@ if test -n "$with_gallium_drivers"; then
 SWR_AVX_CXXFLAGS
 AC_SUBST([SWR_AVX_CXXFLAGS])
 
-swr_require_cxx_feature_flags "AVX2" "defined(__AVX2__)" \
-",-mavx2 -mfma -mbmi2 -mf16c,-march=core-avx2" \
-SWR_AVX2_CXXFLAGS
-AC_SUBST([SWR_AVX2_CXXFLAGS])
+swr_archs=`IFS=', '; echo $with_swr_archs`
+for arch in $swr_archs; do
+case "x$arch" in
+xavx)
+HAVE_SWR_AVX=yes
+;;
+xavx2)
+swr_require_cxx_feature_flags "AVX2" "defined(__AVX2__)" \
+",-mavx2 -mfma -mbmi2 -mf16c,-march=core-avx2" \
+SWR_AVX2_CXXFLAGS
+AC_SUBST([SWR_AVX2_CXXFLAGS])
+HAVE_SWR_AVX2=yes
+;;
+*)
+AC_MSG_ERROR([unknown SWR build architecture '$arch'])
+;;
+esac
+done
 
 HAVE_GALLIUM_SWR=yes
 ;;
@@ -2538,6 +2561,9 @@ if test "x$enable_llvm" = "xyes" -a 
"$with_gallium_drivers"; then
 llvm_add_default_components "gallium"
 fi
 
+AM_CONDITIONAL(HAVE_SWR_AVX, test "x$HAVE_SWR_AVX" = xyes)
+AM_CONDITIONAL(HAVE_SWR_AVX2, test "x$HAVE_SWR_AVX2" = xyes)
+
 dnl We need to validate some needed dependencies for renderonly drivers.
 
 if test "x$HAVE_GALLIUM_ETNAVIV" != xyes -a "x$HAVE_GALLIUM_IMX" = xyes  ; then
@@ -2977,6 +3003,11 @@ else
 echo "HUD lmsensors:   yes"
 fi
 
+echo ""
+if test "x$HAVE_GALLIUM_SWR" != x; then
+echo "SWR archs:   $swr_archs"
+fi
+
 dnl Libraries
 echo ""
 echo "Shared libs: $enable_shared"
diff --git a/src/gallium/drivers/swr/Makefile.am 
b/src/gallium/drivers/swr/Makefile.am
index 74612280fe..f38ce7b1d9 100644
--- a/src/gallium/drivers/swr/Makefile.am
+++ b/src/gallium/drivers/swr/Makefile.am
@@ -55,6 +55,14 @@ libmesaswr_la_CXXFLAGS = \
$(SWR_AVX_CXXFLAGS) \
$(COMMON_CXXFLAGS)
 
+if HAVE_SWR_AVX
+libmesaswr_la_CXXFLAGS += -DHAVE_SWR_AVX
+endif
+
+if HAVE_SWR_AVX2
+libmesaswr_la_CXXFLAGS += -DHAVE_SWR_AVX2
+endif
+
 COMMON_SOURCES = \
$(ARCHRAST_CXX_SOURCES) \
$(COMMON_CXX_SOURCES) \
@@ -224,7 +232,10 @@ COMMON_LDFLAGS = \
$(GC_SECTIONS) \
$(NO_UNDEFINED)
 
-lib_LTLIBRARIES = libswrAVX.la libswrAVX2.la
+lib_LTLIBRARIES =
+
+if HAVE_SWR_AVX
+lib_LTLIBRARIES += libswrAVX.la
 
 libswrAVX_la_CXXFLAGS = \
$(SWR_AVX_CXXFLAGS) \
@@ -236,7 +247,10 @@ libswrAVX_la_SOURCES = \
 
 libswrAVX_la_LDFLAGS = \
$(COMMON_LDFLAGS)
+endif
 
+if HAVE_SWR_AVX2
+lib_LTLIBRARIES += libswrAVX2.la
 libswrAVX2_la_CXXFLAGS = \
$(SWR_AVX2_CXXFLAGS) \
-DKNOB_ARCH=KNOB_ARCH_AVX2 \
@@ -247,6 +261,7 @@ libswrAVX2_la_SOURCES = \
 
 libswrAVX2_la_LDFLAGS = \
$(COMMON_LDFLAGS)
+endif
 
 include $(top_srcdir)/install-gallium-links.mk
 
diff --git a/src/gallium/drivers/swr/SConscript 
b/src/gallium/drivers/swr/SConscript
index cdfb91a5bb..a32807d36b 100644
--- a/src/gallium/drivers/swr/SConscript
+++ b/src/gallium/drivers/swr/SConscript
@@ -245,6 +245,7 @@ source += [
 
 # main SWR lib
 envSWR = envavx.Clone() # pick up the arch flag for intrinsic usage
+envSWR.Append(CPPDEFINES = ['HAVE_SWR_AVX', 'HAVE_SWR_AVX2'])
 swr = envSWR.ConvenienceLibrary(
 target = 'swr',
 source = source,
diff --git a/src/gallium/drivers/swr/swr_loader.cpp 
b/src/gallium/drivers/swr/swr_loader.cpp
index d56fb0e59f..57ab4e4f66 100644
--- a/src/gallium/drivers/swr/swr_loader.cpp
+++ b/src/gallium/drivers/swr/swr_loader.cpp
@@ -31,22 +31,36 @@
 st