Re: [Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-17 Thread Erik Faye-Lund
On Sat, Nov 15, 2014 at 7:18 PM, Matt Turner matts...@gmail.com wrote:
 On Sat, Nov 15, 2014 at 10:13 AM, Ilia Mirkin imir...@alum.mit.edu wrote:
 On Sat, Nov 15, 2014 at 12:04 PM, Emil Velikov emil.l.veli...@gmail.com 
 wrote:
 So when checking/building sse code we have three possibilities:
  1 Old compiler, throws an error when using -msse*
  2 New compiler, user disables sse* (-mno-sse*)
  3 New compiler, user doesn't disable sse

 The original code, added code for #1 but not #2. Later on we patched
 around the lack of handling #2 by wrapping the code in __SSE4_1__.
 Yet it lead to a missing/undefined symbol in case of #1 or #2, which
 might cause an issue for #2 when using the i965 driver.

 A bit later we fixed the undefined symbol by using #1, rather than
 updating it to handle #2. With this commit we set things straight :)

 To top it all up, conventions state that in case of conflicting
 (-enable-foo -disable-foo) options, the latter one takes precedence.
 Thus we need to make sure to prepend -msse4.1 to CFLAGS in our test.

 Cc: Siavash Eliasi siavashser...@gmail.com
 Cc: Matt Turner matts...@gmail.com
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---

 Man this thing is _very_ messy.
 Matt from the last hunk it seems that pixman might need fixing. Should
 be bother with that, or let people have fun when they hit it :P

 -Emil

  configure.ac | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)

 diff --git a/configure.ac b/configure.ac
 index 91e111b..9d1835e 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -252,7 +252,19 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
  dnl
  dnl Optional flags, check for compiler support
  dnl
 -AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], [SSE41_SUPPORTED=0])
 +save_CFLAGS=$CFLAGS
 +CFLAGS=-msse4.1 $CFLAGS
 +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 +#include mmintrin.h
 +#include xmmintrin.h
 +#include emmintrin.h
 +#include smmintrin.h
 +int main () {
 +__m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
 +c = _mm_max_epu32(a, b);
 +return 0;

 This seems complicated.

 (a) Just #include immintrin.h
 (b) Is any of this even necessary? how about

 int main() { return !__SSE_4_1__; }

 Checking that you can actually using the intrinsics seens like a good
 plan. Pixman's configure.ac has been doing that for a long time. I'd
 rather copy that. It's not like we'd save much by not doing it.

...But then we cannot cross-compile with run-time SSE 4.1 support from
a machine without SSE 4.1 support, no?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-17 Thread Ilia Mirkin
On Mon, Nov 17, 2014 at 9:44 AM, Erik Faye-Lund kusmab...@gmail.com wrote:
 On Sat, Nov 15, 2014 at 7:18 PM, Matt Turner matts...@gmail.com wrote:
 On Sat, Nov 15, 2014 at 10:13 AM, Ilia Mirkin imir...@alum.mit.edu wrote:
 On Sat, Nov 15, 2014 at 12:04 PM, Emil Velikov emil.l.veli...@gmail.com 
 wrote:
 So when checking/building sse code we have three possibilities:
  1 Old compiler, throws an error when using -msse*
  2 New compiler, user disables sse* (-mno-sse*)
  3 New compiler, user doesn't disable sse

 The original code, added code for #1 but not #2. Later on we patched
 around the lack of handling #2 by wrapping the code in __SSE4_1__.
 Yet it lead to a missing/undefined symbol in case of #1 or #2, which
 might cause an issue for #2 when using the i965 driver.

 A bit later we fixed the undefined symbol by using #1, rather than
 updating it to handle #2. With this commit we set things straight :)

 To top it all up, conventions state that in case of conflicting
 (-enable-foo -disable-foo) options, the latter one takes precedence.
 Thus we need to make sure to prepend -msse4.1 to CFLAGS in our test.

 Cc: Siavash Eliasi siavashser...@gmail.com
 Cc: Matt Turner matts...@gmail.com
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---

 Man this thing is _very_ messy.
 Matt from the last hunk it seems that pixman might need fixing. Should
 be bother with that, or let people have fun when they hit it :P

 -Emil

  configure.ac | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)

 diff --git a/configure.ac b/configure.ac
 index 91e111b..9d1835e 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -252,7 +252,19 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
  dnl
  dnl Optional flags, check for compiler support
  dnl
 -AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], 
 [SSE41_SUPPORTED=0])
 +save_CFLAGS=$CFLAGS
 +CFLAGS=-msse4.1 $CFLAGS
 +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 +#include mmintrin.h
 +#include xmmintrin.h
 +#include emmintrin.h
 +#include smmintrin.h
 +int main () {
 +__m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
 +c = _mm_max_epu32(a, b);
 +return 0;

 This seems complicated.

 (a) Just #include immintrin.h
 (b) Is any of this even necessary? how about

 int main() { return !__SSE_4_1__; }

 Checking that you can actually using the intrinsics seens like a good
 plan. Pixman's configure.ac has been doing that for a long time. I'd
 rather copy that. It's not like we'd save much by not doing it.

 ...But then we cannot cross-compile with run-time SSE 4.1 support from
 a machine without SSE 4.1 support, no?

Why not? It's a compile-time test. Obviously if there's no compiler
support, then you're SOL...
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-17 Thread Erik Faye-Lund
On Mon, Nov 17, 2014 at 3:50 PM, Ilia Mirkin imir...@alum.mit.edu wrote:
 On Mon, Nov 17, 2014 at 9:44 AM, Erik Faye-Lund kusmab...@gmail.com wrote:
 On Sat, Nov 15, 2014 at 7:18 PM, Matt Turner matts...@gmail.com wrote:
 On Sat, Nov 15, 2014 at 10:13 AM, Ilia Mirkin imir...@alum.mit.edu wrote:
 On Sat, Nov 15, 2014 at 12:04 PM, Emil Velikov emil.l.veli...@gmail.com 
 wrote:
 So when checking/building sse code we have three possibilities:
  1 Old compiler, throws an error when using -msse*
  2 New compiler, user disables sse* (-mno-sse*)
  3 New compiler, user doesn't disable sse

 The original code, added code for #1 but not #2. Later on we patched
 around the lack of handling #2 by wrapping the code in __SSE4_1__.
 Yet it lead to a missing/undefined symbol in case of #1 or #2, which
 might cause an issue for #2 when using the i965 driver.

 A bit later we fixed the undefined symbol by using #1, rather than
 updating it to handle #2. With this commit we set things straight :)

 To top it all up, conventions state that in case of conflicting
 (-enable-foo -disable-foo) options, the latter one takes precedence.
 Thus we need to make sure to prepend -msse4.1 to CFLAGS in our test.

 Cc: Siavash Eliasi siavashser...@gmail.com
 Cc: Matt Turner matts...@gmail.com
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---

 Man this thing is _very_ messy.
 Matt from the last hunk it seems that pixman might need fixing. Should
 be bother with that, or let people have fun when they hit it :P

 -Emil

  configure.ac | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)

 diff --git a/configure.ac b/configure.ac
 index 91e111b..9d1835e 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -252,7 +252,19 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
  dnl
  dnl Optional flags, check for compiler support
  dnl
 -AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], 
 [SSE41_SUPPORTED=0])
 +save_CFLAGS=$CFLAGS
 +CFLAGS=-msse4.1 $CFLAGS
 +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 +#include mmintrin.h
 +#include xmmintrin.h
 +#include emmintrin.h
 +#include smmintrin.h
 +int main () {
 +__m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
 +c = _mm_max_epu32(a, b);
 +return 0;

 This seems complicated.

 (a) Just #include immintrin.h
 (b) Is any of this even necessary? how about

 int main() { return !__SSE_4_1__; }

 Checking that you can actually using the intrinsics seens like a good
 plan. Pixman's configure.ac has been doing that for a long time. I'd
 rather copy that. It's not like we'd save much by not doing it.

 ...But then we cannot cross-compile with run-time SSE 4.1 support from
 a machine without SSE 4.1 support, no?

 Why not? It's a compile-time test. Obviously if there's no compiler
 support, then you're SOL...

Right, my bad. Thanks for setting the record straight.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-17 Thread Emil Velikov
On 17/11/14 14:44, Erik Faye-Lund wrote:
 On Sat, Nov 15, 2014 at 7:18 PM, Matt Turner matts...@gmail.com wrote:
 On Sat, Nov 15, 2014 at 10:13 AM, Ilia Mirkin imir...@alum.mit.edu wrote:
 On Sat, Nov 15, 2014 at 12:04 PM, Emil Velikov emil.l.veli...@gmail.com 
 wrote:
 So when checking/building sse code we have three possibilities:
  1 Old compiler, throws an error when using -msse*
  2 New compiler, user disables sse* (-mno-sse*)
  3 New compiler, user doesn't disable sse

 The original code, added code for #1 but not #2. Later on we patched
 around the lack of handling #2 by wrapping the code in __SSE4_1__.
 Yet it lead to a missing/undefined symbol in case of #1 or #2, which
 might cause an issue for #2 when using the i965 driver.

 A bit later we fixed the undefined symbol by using #1, rather than
 updating it to handle #2. With this commit we set things straight :)

 To top it all up, conventions state that in case of conflicting
 (-enable-foo -disable-foo) options, the latter one takes precedence.
 Thus we need to make sure to prepend -msse4.1 to CFLAGS in our test.

 Cc: Siavash Eliasi siavashser...@gmail.com
 Cc: Matt Turner matts...@gmail.com
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---

 Man this thing is _very_ messy.
 Matt from the last hunk it seems that pixman might need fixing. Should
 be bother with that, or let people have fun when they hit it :P

 -Emil

  configure.ac | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)

 diff --git a/configure.ac b/configure.ac
 index 91e111b..9d1835e 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -252,7 +252,19 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
  dnl
  dnl Optional flags, check for compiler support
  dnl
 -AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], 
 [SSE41_SUPPORTED=0])
 +save_CFLAGS=$CFLAGS
 +CFLAGS=-msse4.1 $CFLAGS
 +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 +#include mmintrin.h
 +#include xmmintrin.h
 +#include emmintrin.h
 +#include smmintrin.h
 +int main () {
 +__m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
 +c = _mm_max_epu32(a, b);
 +return 0;

 This seems complicated.

 (a) Just #include immintrin.h
 (b) Is any of this even necessary? how about

 int main() { return !__SSE_4_1__; }

 Checking that you can actually using the intrinsics seens like a good
 plan. Pixman's configure.ac has been doing that for a long time. I'd
 rather copy that. It's not like we'd save much by not doing it.
 
 ...But then we cannot cross-compile with run-time SSE 4.1 support from
 a machine without SSE 4.1 support, no?
 
Autohell should be smart enough to use the correct (cross-compilation)
tool-chain while building that code. Must admit that I have not checked
if that is truly the case.

-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-15 Thread Emil Velikov
So when checking/building sse code we have three possibilities:
 1 Old compiler, throws an error when using -msse*
 2 New compiler, user disables sse* (-mno-sse*)
 3 New compiler, user doesn't disable sse

The original code, added code for #1 but not #2. Later on we patched 
around the lack of handling #2 by wrapping the code in __SSE4_1__.
Yet it lead to a missing/undefined symbol in case of #1 or #2, which 
might cause an issue for #2 when using the i965 driver.

A bit later we fixed the undefined symbol by using #1, rather than 
updating it to handle #2. With this commit we set things straight :)

To top it all up, conventions state that in case of conflicting
(-enable-foo -disable-foo) options, the latter one takes precedence.
Thus we need to make sure to prepend -msse4.1 to CFLAGS in our test.

Cc: Siavash Eliasi siavashser...@gmail.com
Cc: Matt Turner matts...@gmail.com
Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
---

Man this thing is _very_ messy.
Matt from the last hunk it seems that pixman might need fixing. Should 
be bother with that, or let people have fun when they hit it :P

-Emil

 configure.ac | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 91e111b..9d1835e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -252,7 +252,19 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
 dnl
 dnl Optional flags, check for compiler support
 dnl
-AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], [SSE41_SUPPORTED=0])
+save_CFLAGS=$CFLAGS
+CFLAGS=-msse4.1 $CFLAGS
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#include mmintrin.h
+#include xmmintrin.h
+#include emmintrin.h
+#include smmintrin.h
+int main () {
+__m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
+c = _mm_max_epu32(a, b);
+return 0;
+}]])], SSE41_SUPPORTED=1)
+CFLAGS=$save_CFLAGS
 if test x$SSE41_SUPPORTED = x1; then
 DEFINES=$DEFINES -DUSE_SSE41
 fi
-- 
2.1.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-15 Thread Ilia Mirkin
On Sat, Nov 15, 2014 at 12:04 PM, Emil Velikov emil.l.veli...@gmail.com wrote:
 So when checking/building sse code we have three possibilities:
  1 Old compiler, throws an error when using -msse*
  2 New compiler, user disables sse* (-mno-sse*)
  3 New compiler, user doesn't disable sse

 The original code, added code for #1 but not #2. Later on we patched
 around the lack of handling #2 by wrapping the code in __SSE4_1__.
 Yet it lead to a missing/undefined symbol in case of #1 or #2, which
 might cause an issue for #2 when using the i965 driver.

 A bit later we fixed the undefined symbol by using #1, rather than
 updating it to handle #2. With this commit we set things straight :)

 To top it all up, conventions state that in case of conflicting
 (-enable-foo -disable-foo) options, the latter one takes precedence.
 Thus we need to make sure to prepend -msse4.1 to CFLAGS in our test.

 Cc: Siavash Eliasi siavashser...@gmail.com
 Cc: Matt Turner matts...@gmail.com
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---

 Man this thing is _very_ messy.
 Matt from the last hunk it seems that pixman might need fixing. Should
 be bother with that, or let people have fun when they hit it :P

 -Emil

  configure.ac | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)

 diff --git a/configure.ac b/configure.ac
 index 91e111b..9d1835e 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -252,7 +252,19 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
  dnl
  dnl Optional flags, check for compiler support
  dnl
 -AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], [SSE41_SUPPORTED=0])
 +save_CFLAGS=$CFLAGS
 +CFLAGS=-msse4.1 $CFLAGS
 +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 +#include mmintrin.h
 +#include xmmintrin.h
 +#include emmintrin.h
 +#include smmintrin.h
 +int main () {
 +__m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
 +c = _mm_max_epu32(a, b);
 +return 0;

This seems complicated.

(a) Just #include immintrin.h
(b) Is any of this even necessary? how about

int main() { return !__SSE_4_1__; }

 +}]])], SSE41_SUPPORTED=1)
 +CFLAGS=$save_CFLAGS
  if test x$SSE41_SUPPORTED = x1; then
  DEFINES=$DEFINES -DUSE_SSE41
  fi
 --
 2.1.3

 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-15 Thread Ilia Mirkin
On Sat, Nov 15, 2014 at 1:13 PM, Ilia Mirkin imir...@alum.mit.edu wrote:
 On Sat, Nov 15, 2014 at 12:04 PM, Emil Velikov emil.l.veli...@gmail.com 
 wrote:
 So when checking/building sse code we have three possibilities:
  1 Old compiler, throws an error when using -msse*
  2 New compiler, user disables sse* (-mno-sse*)
  3 New compiler, user doesn't disable sse

 The original code, added code for #1 but not #2. Later on we patched
 around the lack of handling #2 by wrapping the code in __SSE4_1__.
 Yet it lead to a missing/undefined symbol in case of #1 or #2, which
 might cause an issue for #2 when using the i965 driver.

 A bit later we fixed the undefined symbol by using #1, rather than
 updating it to handle #2. With this commit we set things straight :)

 To top it all up, conventions state that in case of conflicting
 (-enable-foo -disable-foo) options, the latter one takes precedence.
 Thus we need to make sure to prepend -msse4.1 to CFLAGS in our test.

 Cc: Siavash Eliasi siavashser...@gmail.com
 Cc: Matt Turner matts...@gmail.com
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---

 Man this thing is _very_ messy.
 Matt from the last hunk it seems that pixman might need fixing. Should
 be bother with that, or let people have fun when they hit it :P

 -Emil

  configure.ac | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)

 diff --git a/configure.ac b/configure.ac
 index 91e111b..9d1835e 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -252,7 +252,19 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
  dnl
  dnl Optional flags, check for compiler support
  dnl
 -AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], [SSE41_SUPPORTED=0])
 +save_CFLAGS=$CFLAGS
 +CFLAGS=-msse4.1 $CFLAGS
 +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 +#include mmintrin.h
 +#include xmmintrin.h
 +#include emmintrin.h
 +#include smmintrin.h
 +int main () {
 +__m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
 +c = _mm_max_epu32(a, b);
 +return 0;

 This seems complicated.

 (a) Just #include immintrin.h
 (b) Is any of this even necessary? how about

 int main() { return !__SSE_4_1__; }

Er, I guess this is a compile check, so more like

#ifndef __SSE_4_1__
#error no sse4.1 support
#endif

int main() { return 0; }


 +}]])], SSE41_SUPPORTED=1)
 +CFLAGS=$save_CFLAGS
  if test x$SSE41_SUPPORTED = x1; then
  DEFINES=$DEFINES -DUSE_SSE41
  fi
 --
 2.1.3

 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-15 Thread Matt Turner
On Sat, Nov 15, 2014 at 10:13 AM, Ilia Mirkin imir...@alum.mit.edu wrote:
 On Sat, Nov 15, 2014 at 12:04 PM, Emil Velikov emil.l.veli...@gmail.com 
 wrote:
 So when checking/building sse code we have three possibilities:
  1 Old compiler, throws an error when using -msse*
  2 New compiler, user disables sse* (-mno-sse*)
  3 New compiler, user doesn't disable sse

 The original code, added code for #1 but not #2. Later on we patched
 around the lack of handling #2 by wrapping the code in __SSE4_1__.
 Yet it lead to a missing/undefined symbol in case of #1 or #2, which
 might cause an issue for #2 when using the i965 driver.

 A bit later we fixed the undefined symbol by using #1, rather than
 updating it to handle #2. With this commit we set things straight :)

 To top it all up, conventions state that in case of conflicting
 (-enable-foo -disable-foo) options, the latter one takes precedence.
 Thus we need to make sure to prepend -msse4.1 to CFLAGS in our test.

 Cc: Siavash Eliasi siavashser...@gmail.com
 Cc: Matt Turner matts...@gmail.com
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---

 Man this thing is _very_ messy.
 Matt from the last hunk it seems that pixman might need fixing. Should
 be bother with that, or let people have fun when they hit it :P

 -Emil

  configure.ac | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)

 diff --git a/configure.ac b/configure.ac
 index 91e111b..9d1835e 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -252,7 +252,19 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
  dnl
  dnl Optional flags, check for compiler support
  dnl
 -AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], [SSE41_SUPPORTED=0])
 +save_CFLAGS=$CFLAGS
 +CFLAGS=-msse4.1 $CFLAGS
 +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 +#include mmintrin.h
 +#include xmmintrin.h
 +#include emmintrin.h
 +#include smmintrin.h
 +int main () {
 +__m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
 +c = _mm_max_epu32(a, b);
 +return 0;

 This seems complicated.

 (a) Just #include immintrin.h
 (b) Is any of this even necessary? how about

 int main() { return !__SSE_4_1__; }

Checking that you can actually using the intrinsics seens like a good
plan. Pixman's configure.ac has been doing that for a long time. I'd
rather copy that. It's not like we'd save much by not doing it.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-15 Thread Matt Turner
On Sat, Nov 15, 2014 at 9:04 AM, Emil Velikov emil.l.veli...@gmail.com wrote:
 So when checking/building sse code we have three possibilities:
  1 Old compiler, throws an error when using -msse*
  2 New compiler, user disables sse* (-mno-sse*)
  3 New compiler, user doesn't disable sse

 The original code, added code for #1 but not #2. Later on we patched
 around the lack of handling #2 by wrapping the code in __SSE4_1__.
 Yet it lead to a missing/undefined symbol in case of #1 or #2, which
 might cause an issue for #2 when using the i965 driver.

 A bit later we fixed the undefined symbol by using #1, rather than
 updating it to handle #2. With this commit we set things straight :)

 To top it all up, conventions state that in case of conflicting
 (-enable-foo -disable-foo) options, the latter one takes precedence.
 Thus we need to make sure to prepend -msse4.1 to CFLAGS in our test.

 Cc: Siavash Eliasi siavashser...@gmail.com
 Cc: Matt Turner matts...@gmail.com
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---

 Man this thing is _very_ messy.
 Matt from the last hunk it seems that pixman might need fixing. Should
 be bother with that, or let people have fun when they hit it :P

I don't know what you mean, specifically.

 -Emil

  configure.ac | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)

 diff --git a/configure.ac b/configure.ac
 index 91e111b..9d1835e 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -252,7 +252,19 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
  dnl
  dnl Optional flags, check for compiler support
  dnl
 -AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], [SSE41_SUPPORTED=0])
 +save_CFLAGS=$CFLAGS
 +CFLAGS=-msse4.1 $CFLAGS
 +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 +#include mmintrin.h
 +#include xmmintrin.h
 +#include emmintrin.h
 +#include smmintrin.h

I think all you need to include is smmintrin.h.

 +int main () {
 +__m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
 +c = _mm_max_epu32(a, b);
 +return 0;
 +}]])], SSE41_SUPPORTED=1)
 +CFLAGS=$save_CFLAGS
  if test x$SSE41_SUPPORTED = x1; then
  DEFINES=$DEFINES -DUSE_SSE41
  fi
 --
 2.1.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-15 Thread Emil Velikov
On 15/11/14 18:18, Matt Turner wrote:
 On Sat, Nov 15, 2014 at 10:13 AM, Ilia Mirkin imir...@alum.mit.edu wrote:
 On Sat, Nov 15, 2014 at 12:04 PM, Emil Velikov emil.l.veli...@gmail.com 
 wrote:
 So when checking/building sse code we have three possibilities:
  1 Old compiler, throws an error when using -msse*
  2 New compiler, user disables sse* (-mno-sse*)
  3 New compiler, user doesn't disable sse

 The original code, added code for #1 but not #2. Later on we patched
 around the lack of handling #2 by wrapping the code in __SSE4_1__.
 Yet it lead to a missing/undefined symbol in case of #1 or #2, which
 might cause an issue for #2 when using the i965 driver.

 A bit later we fixed the undefined symbol by using #1, rather than
 updating it to handle #2. With this commit we set things straight :)

 To top it all up, conventions state that in case of conflicting
 (-enable-foo -disable-foo) options, the latter one takes precedence.
 Thus we need to make sure to prepend -msse4.1 to CFLAGS in our test.

 Cc: Siavash Eliasi siavashser...@gmail.com
 Cc: Matt Turner matts...@gmail.com
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---

 Man this thing is _very_ messy.
 Matt from the last hunk it seems that pixman might need fixing. Should
 be bother with that, or let people have fun when they hit it :P

 -Emil

  configure.ac | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)

 diff --git a/configure.ac b/configure.ac
 index 91e111b..9d1835e 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -252,7 +252,19 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
  dnl
  dnl Optional flags, check for compiler support
  dnl
 -AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], [SSE41_SUPPORTED=0])
 +save_CFLAGS=$CFLAGS
 +CFLAGS=-msse4.1 $CFLAGS
 +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 +#include mmintrin.h
 +#include xmmintrin.h
 +#include emmintrin.h
 +#include smmintrin.h
 +int main () {
 +__m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
 +c = _mm_max_epu32(a, b);
 +return 0;

 This seems complicated.

Ilia, did you really mean complicated or you're having a thing for me :)
Excessive ? Perhaps, but as Matt mentioned, actually checking one of the
functions you're going to use does not hurt.

 (a) Just #include immintrin.h
 (b) Is any of this even necessary? how about

 int main() { return !__SSE_4_1__; }
 
 Checking that you can actually using the intrinsics seens like a good
 plan. Pixman's configure.ac has been doing that for a long time. I'd
 rather copy that. It's not like we'd save much by not doing it.
 
That's where I drew the inspiration.

-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-15 Thread Siavash Eliasi
Tested on Core2 Q9550, using -march=native with and without 
-mno-sse4.1flag. It works perfect :)


Also David Heidelberg kindly tested the patch which permanently enables 
optimized code paths if supported by target machine and it was okay.

http://patchwork.freedesktop.org/patch/36488/

And a small improvement to your patch, I think including smmintrin.h 
or the all-in-one alternative immintrin.h should be enough.


Best regards,
Siavash Eliasi.

On 11/15/2014 08:34 PM, Emil Velikov wrote:

So when checking/building sse code we have three possibilities:
  1 Old compiler, throws an error when using -msse*
  2 New compiler, user disables sse* (-mno-sse*)
  3 New compiler, user doesn't disable sse

The original code, added code for #1 but not #2. Later on we patched
around the lack of handling #2 by wrapping the code in __SSE4_1__.
Yet it lead to a missing/undefined symbol in case of #1 or #2, which
might cause an issue for #2 when using the i965 driver.

A bit later we fixed the undefined symbol by using #1, rather than
updating it to handle #2. With this commit we set things straight :)

To top it all up, conventions state that in case of conflicting
(-enable-foo -disable-foo) options, the latter one takes precedence.
Thus we need to make sure to prepend -msse4.1 to CFLAGS in our test.

Cc: Siavash Eliasi siavashser...@gmail.com
Cc: Matt Turner matts...@gmail.com
Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
---

Man this thing is _very_ messy.
Matt from the last hunk it seems that pixman might need fixing. Should
be bother with that, or let people have fun when they hit it :P

-Emil

  configure.ac | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 91e111b..9d1835e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -252,7 +252,19 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
  dnl
  dnl Optional flags, check for compiler support
  dnl
-AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], [SSE41_SUPPORTED=0])
+save_CFLAGS=$CFLAGS
+CFLAGS=-msse4.1 $CFLAGS
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#include mmintrin.h
+#include xmmintrin.h
+#include emmintrin.h
+#include smmintrin.h
+int main () {
+__m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
+c = _mm_max_epu32(a, b);
+return 0;
+}]])], SSE41_SUPPORTED=1)
+CFLAGS=$save_CFLAGS
  if test x$SSE41_SUPPORTED = x1; then
  DEFINES=$DEFINES -DUSE_SSE41
  fi


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-15 Thread Emil Velikov
On 15/11/14 18:21, Matt Turner wrote:
 On Sat, Nov 15, 2014 at 9:04 AM, Emil Velikov emil.l.veli...@gmail.com 
 wrote:
 So when checking/building sse code we have three possibilities:
  1 Old compiler, throws an error when using -msse*
  2 New compiler, user disables sse* (-mno-sse*)
  3 New compiler, user doesn't disable sse

 The original code, added code for #1 but not #2. Later on we patched
 around the lack of handling #2 by wrapping the code in __SSE4_1__.
 Yet it lead to a missing/undefined symbol in case of #1 or #2, which
 might cause an issue for #2 when using the i965 driver.

 A bit later we fixed the undefined symbol by using #1, rather than
 updating it to handle #2. With this commit we set things straight :)

 To top it all up, conventions state that in case of conflicting
 (-enable-foo -disable-foo) options, the latter one takes precedence.
 Thus we need to make sure to prepend -msse4.1 to CFLAGS in our test.

 Cc: Siavash Eliasi siavashser...@gmail.com
 Cc: Matt Turner matts...@gmail.com
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---

 Man this thing is _very_ messy.
 Matt from the last hunk it seems that pixman might need fixing. Should
 be bother with that, or let people have fun when they hit it :P
 
 I don't know what you mean, specifically.
 
configure.ac (in pixman) does:

CFLAGS=$CFLAGS -msse4.1
AC_COMPILE_IFELSE(...)

Which overwrites the cflags set by the user. I.e. it will not honour
-mno-sse4.1. At build time things will blow up, as CFLAGS, are placed
after AM_CFLAGS. I.e. in the makefiles the user knows best while in
configure it's the opposite.

 -Emil

  configure.ac | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)

 diff --git a/configure.ac b/configure.ac
 index 91e111b..9d1835e 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -252,7 +252,19 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
  dnl
  dnl Optional flags, check for compiler support
  dnl
 -AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], [SSE41_SUPPORTED=0])
 +save_CFLAGS=$CFLAGS
 +CFLAGS=-msse4.1 $CFLAGS
 +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 +#include mmintrin.h
 +#include xmmintrin.h
 +#include emmintrin.h
 +#include smmintrin.h
 
 I think all you need to include is smmintrin.h.
 
True, blame pixman for the rest :P

-Emil
 +int main () {
 +__m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
 +c = _mm_max_epu32(a, b);
 +return 0;
 +}]])], SSE41_SUPPORTED=1)
 +CFLAGS=$save_CFLAGS
  if test x$SSE41_SUPPORTED = x1; then
  DEFINES=$DEFINES -DUSE_SSE41
  fi
 --
 2.1.3


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-15 Thread Matt Turner
On Sat, Nov 15, 2014 at 10:30 AM, Emil Velikov emil.l.veli...@gmail.com wrote:
 On 15/11/14 18:21, Matt Turner wrote:
 On Sat, Nov 15, 2014 at 9:04 AM, Emil Velikov emil.l.veli...@gmail.com 
 wrote:
 Man this thing is _very_ messy.
 Matt from the last hunk it seems that pixman might need fixing. Should
 be bother with that, or let people have fun when they hit it :P

 I don't know what you mean, specifically.

 configure.ac (in pixman) does:

 CFLAGS=$CFLAGS -msse4.1
 AC_COMPILE_IFELSE(...)

Where? I see

MMX_CFLAGS=-mmmx -Winline
...
CFLAGS=$MMX_CFLAGS $CFLAGS

SSE2_CFLAGS=-msse2 -Winline
...
CFLAGS=$SSE2_CFLAGS $CFLAGS

and

SSSE3_CFLAGS=-mssse3 -Winline
...
CFLAGS=$SSSE3_CFLAGS $CFLAGS

which looks like it's doing the right thing. I tried building it with
-mno-ssse3 and it correctly disabled the SSSE3 code.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-15 Thread Ilia Mirkin
On Sat, Nov 15, 2014 at 1:25 PM, Emil Velikov emil.l.veli...@gmail.com wrote:
 On 15/11/14 18:18, Matt Turner wrote:
 On Sat, Nov 15, 2014 at 10:13 AM, Ilia Mirkin imir...@alum.mit.edu wrote:
 On Sat, Nov 15, 2014 at 12:04 PM, Emil Velikov emil.l.veli...@gmail.com 
 wrote:
 So when checking/building sse code we have three possibilities:
  1 Old compiler, throws an error when using -msse*
  2 New compiler, user disables sse* (-mno-sse*)
  3 New compiler, user doesn't disable sse

 The original code, added code for #1 but not #2. Later on we patched
 around the lack of handling #2 by wrapping the code in __SSE4_1__.
 Yet it lead to a missing/undefined symbol in case of #1 or #2, which
 might cause an issue for #2 when using the i965 driver.

 A bit later we fixed the undefined symbol by using #1, rather than
 updating it to handle #2. With this commit we set things straight :)

 To top it all up, conventions state that in case of conflicting
 (-enable-foo -disable-foo) options, the latter one takes precedence.
 Thus we need to make sure to prepend -msse4.1 to CFLAGS in our test.

 Cc: Siavash Eliasi siavashser...@gmail.com
 Cc: Matt Turner matts...@gmail.com
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---

 Man this thing is _very_ messy.
 Matt from the last hunk it seems that pixman might need fixing. Should
 be bother with that, or let people have fun when they hit it :P

 -Emil

  configure.ac | 14 +-
  1 file changed, 13 insertions(+), 1 deletion(-)

 diff --git a/configure.ac b/configure.ac
 index 91e111b..9d1835e 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -252,7 +252,19 @@ AC_SUBST([VISIBILITY_CXXFLAGS])
  dnl
  dnl Optional flags, check for compiler support
  dnl
 -AX_CHECK_COMPILE_FLAG([-msse4.1], [SSE41_SUPPORTED=1], 
 [SSE41_SUPPORTED=0])
 +save_CFLAGS=$CFLAGS
 +CFLAGS=-msse4.1 $CFLAGS
 +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 +#include mmintrin.h
 +#include xmmintrin.h
 +#include emmintrin.h
 +#include smmintrin.h
 +int main () {
 +__m128i a = _mm_set1_epi32 (0), b = _mm_set1_epi32 (0), c;
 +c = _mm_max_epu32(a, b);
 +return 0;

 This seems complicated.

 Ilia, did you really mean complicated or you're having a thing for me :)

I like simplicity.

 Excessive ? Perhaps, but as Matt mentioned, actually checking one of the
 functions you're going to use does not hurt.

Indeed. Checking the functions seems like a not-unreasonable thing to
do. Perhaps I'm naive and like to think that if __SSE_4_1__ is
defined, then all's well :)


 (a) Just #include immintrin.h
 (b) Is any of this even necessary? how about

 int main() { return !__SSE_4_1__; }

 Checking that you can actually using the intrinsics seens like a good
 plan. Pixman's configure.ac has been doing that for a long time. I'd
 rather copy that. It's not like we'd save much by not doing it.

 That's where I drew the inspiration.

 -Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] configure.ac: roll up a program for the sse4.1 check

2014-11-15 Thread Emil Velikov
On 15/11/14 18:38, Matt Turner wrote:
 On Sat, Nov 15, 2014 at 10:30 AM, Emil Velikov emil.l.veli...@gmail.com 
 wrote:
 On 15/11/14 18:21, Matt Turner wrote:
 On Sat, Nov 15, 2014 at 9:04 AM, Emil Velikov emil.l.veli...@gmail.com 
 wrote:
 Man this thing is _very_ messy.
 Matt from the last hunk it seems that pixman might need fixing. Should
 be bother with that, or let people have fun when they hit it :P

 I don't know what you mean, specifically.

 configure.ac (in pixman) does:

 CFLAGS=$CFLAGS -msse4.1
 AC_COMPILE_IFELSE(...)
 
 Where? I see
 ...
Pardon for the noise it seems to be a PEBKAC on my end :)

-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev