linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] selftests/powerpc: benchmarks/context_switch.c improve usage message
@ 2016-03-03 23:06 Cyril Bur
  2016-03-03 23:06 ` [PATCH 2/2] selftests/powerpc: benchmarks/context_switch.c use vector instructions/types Cyril Bur
  2016-07-05 14:10 ` [1/2] selftests/powerpc: benchmarks/context_switch.c improve usage message Michael Ellerman
  0 siblings, 2 replies; 5+ messages in thread
From: Cyril Bur @ 2016-03-03 23:06 UTC (permalink / raw)
  To: linuxppc-dev

Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
---
 tools/testing/selftests/powerpc/benchmarks/context_switch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/powerpc/benchmarks/context_switch.c b/tools/testing/selftests/powerpc/benchmarks/context_switch.c
index 7b78594..e6af382 100644
--- a/tools/testing/selftests/powerpc/benchmarks/context_switch.c
+++ b/tools/testing/selftests/powerpc/benchmarks/context_switch.c
@@ -369,11 +369,11 @@ static void usage(void)
 	fprintf(stderr, "\t\t--process\tUse processes (default threads)\n");
 	fprintf(stderr, "\t\t--timeout=X\tDuration in seconds to run (default 30)\n");
 	fprintf(stderr, "\t\t--vdso\t\ttouch VDSO\n");
-	fprintf(stderr, "\t\t--fp\t\ttouch FP\n");
+	fprintf(stderr, "\t\t--no-fp\t\tDon't touch FP\n");
 #ifdef __powerpc__
-	fprintf(stderr, "\t\t--altivec\ttouch altivec\n");
+	fprintf(stderr, "\t\t--no-altivec\tDon't touch altivec\n");
 #endif
-	fprintf(stderr, "\t\t--vector\ttouch vector\n");
+	fprintf(stderr, "\t\t--no-vector\tDon't touch vector\n");
 }
 
 int main(int argc, char *argv[])
-- 
2.7.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] selftests/powerpc: benchmarks/context_switch.c use vector instructions/types
  2016-03-03 23:06 [PATCH 1/2] selftests/powerpc: benchmarks/context_switch.c improve usage message Cyril Bur
@ 2016-03-03 23:06 ` Cyril Bur
  2016-07-05 14:10   ` [2/2] " Michael Ellerman
  2019-01-23  8:47   ` [PATCH 2/2] " Christophe Leroy
  2016-07-05 14:10 ` [1/2] selftests/powerpc: benchmarks/context_switch.c improve usage message Michael Ellerman
  1 sibling, 2 replies; 5+ messages in thread
From: Cyril Bur @ 2016-03-03 23:06 UTC (permalink / raw)
  To: linuxppc-dev

Currently it doesn't appear the resulting binary actually uses any Altivec
or VSX instructions the solution is to explicitly tell GCC to use vector
instructions and use vector types in the code.

Part of this this issue can be GCC version specific:

GCC 4.9.x is happy to use Altivec and VSX instructions if altivec.h is
includedi (and possibly if vector types are used), this also means that
4.9.x will use VSX instructions even if only -maltivec is passed. It is
also possible that Altivec instructions will be used even without -maltivec
or -mabi=altivec.

GCC 5.2.x complains about the lack of -maltivec parameter if altivec.h is
included and will not use VSX unless -mvsx is present on commandline.

GCC 5.3.0 has a regression that means __attribute__((__target__("no-vsx"))
fails to build. A fix is targeted for 5.4.

Furthermore LTO (Link Time Optimisation) doesn't play well with
__attribute__((__target__("no-vsx")), LTO can cause GCC to forget about the
attribute and compile with VSX instructions regardless. Be weary when
enabling -flfo for this test.

Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
---
 tools/testing/selftests/powerpc/benchmarks/Makefile         |  1 +
 tools/testing/selftests/powerpc/benchmarks/context_switch.c | 11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
index 912445f..6816fc2 100644
--- a/tools/testing/selftests/powerpc/benchmarks/Makefile
+++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
@@ -7,6 +7,7 @@ all: $(TEST_PROGS)
 $(TEST_PROGS): ../harness.c
 
 context_switch: ../utils.c
+context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec
 context_switch: LDLIBS += -lpthread
 
 include ../../lib.mk
diff --git a/tools/testing/selftests/powerpc/benchmarks/context_switch.c b/tools/testing/selftests/powerpc/benchmarks/context_switch.c
index e6af382..a36883a 100644
--- a/tools/testing/selftests/powerpc/benchmarks/context_switch.c
+++ b/tools/testing/selftests/powerpc/benchmarks/context_switch.c
@@ -25,7 +25,9 @@
 #include <sys/types.h>
 #include <sys/shm.h>
 #include <linux/futex.h>
-
+#ifdef __powerpc__
+#include <altivec.h>
+#endif
 #include "../utils.h"
 
 static unsigned int timeout = 30;
@@ -37,12 +39,15 @@ static int touch_fp = 1;
 double fp;
 
 static int touch_vector = 1;
-typedef int v4si __attribute__ ((vector_size (16)));
-v4si a, b, c;
+vector int a, b, c;
 
 #ifdef __powerpc__
 static int touch_altivec = 1;
 
+/*
+ * Note: LTO (Link Time Optimisation) doesn't play well with this function
+ * attribute. Be very careful enabling LTO for this test.
+ */
 static void __attribute__((__target__("no-vsx"))) altivec_touch_fn(void)
 {
 	c = a + b;
-- 
2.7.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [1/2] selftests/powerpc: benchmarks/context_switch.c improve usage message
  2016-03-03 23:06 [PATCH 1/2] selftests/powerpc: benchmarks/context_switch.c improve usage message Cyril Bur
  2016-03-03 23:06 ` [PATCH 2/2] selftests/powerpc: benchmarks/context_switch.c use vector instructions/types Cyril Bur
@ 2016-07-05 14:10 ` Michael Ellerman
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2016-07-05 14:10 UTC (permalink / raw)
  To: Cyril Bur, linuxppc-dev

On Thu, 2016-03-03 at 23:06:39 UTC, Cyril Bur wrote:
> Signed-off-by: Cyril Bur <cyrilbur@gmail.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/94fa56a96a39914551694673fd

cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [2/2] selftests/powerpc: benchmarks/context_switch.c use vector instructions/types
  2016-03-03 23:06 ` [PATCH 2/2] selftests/powerpc: benchmarks/context_switch.c use vector instructions/types Cyril Bur
@ 2016-07-05 14:10   ` Michael Ellerman
  2019-01-23  8:47   ` [PATCH 2/2] " Christophe Leroy
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2016-07-05 14:10 UTC (permalink / raw)
  To: Cyril Bur, linuxppc-dev

On Thu, 2016-03-03 at 23:06:40 UTC, Cyril Bur wrote:
> Currently it doesn't appear the resulting binary actually uses any Altivec
> or VSX instructions the solution is to explicitly tell GCC to use vector
> instructions and use vector types in the code.
> 
> Part of this this issue can be GCC version specific:
> 
> GCC 4.9.x is happy to use Altivec and VSX instructions if altivec.h is
> includedi (and possibly if vector types are used), this also means that
> 4.9.x will use VSX instructions even if only -maltivec is passed. It is
> also possible that Altivec instructions will be used even without -maltivec
> or -mabi=altivec.
> 
> GCC 5.2.x complains about the lack of -maltivec parameter if altivec.h is
> included and will not use VSX unless -mvsx is present on commandline.
> 
> GCC 5.3.0 has a regression that means __attribute__((__target__("no-vsx"))
> fails to build. A fix is targeted for 5.4.
> 
> Furthermore LTO (Link Time Optimisation) doesn't play well with
> __attribute__((__target__("no-vsx")), LTO can cause GCC to forget about the
> attribute and compile with VSX instructions regardless. Be weary when
> enabling -flfo for this test.
> 
> Signed-off-by: Cyril Bur <cyrilbur@gmail.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/f2418ae8a81760b4dec8d5e3e7

cheers

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] selftests/powerpc: benchmarks/context_switch.c use vector instructions/types
  2016-03-03 23:06 ` [PATCH 2/2] selftests/powerpc: benchmarks/context_switch.c use vector instructions/types Cyril Bur
  2016-07-05 14:10   ` [2/2] " Michael Ellerman
@ 2019-01-23  8:47   ` Christophe Leroy
  1 sibling, 0 replies; 5+ messages in thread
From: Christophe Leroy @ 2019-01-23  8:47 UTC (permalink / raw)
  To: Cyril Bur; +Cc: linuxppc-dev

Hi Cyril,

On 03/03/2016 11:06 PM, Cyril Bur wrote:
> Currently it doesn't appear the resulting binary actually uses any Altivec
> or VSX instructions the solution is to explicitly tell GCC to use vector
> instructions and use vector types in the code.
> 
> Part of this this issue can be GCC version specific:
> 
> GCC 4.9.x is happy to use Altivec and VSX instructions if altivec.h is
> includedi (and possibly if vector types are used), this also means that
> 4.9.x will use VSX instructions even if only -maltivec is passed. It is
> also possible that Altivec instructions will be used even without -maltivec
> or -mabi=altivec.
> 
> GCC 5.2.x complains about the lack of -maltivec parameter if altivec.h is
> included and will not use VSX unless -mvsx is present on commandline.
> 
> GCC 5.3.0 has a regression that means __attribute__((__target__("no-vsx"))
> fails to build. A fix is targeted for 5.4.
> 
> Furthermore LTO (Link Time Optimisation) doesn't play well with
> __attribute__((__target__("no-vsx")), LTO can cause GCC to forget about the
> attribute and compile with VSX instructions regardless. Be weary when
> enabling -flfo for this test.
> 
> Signed-off-by: Cyril Bur <cyrilbur@gmail.com>

This patch breaks the build on my setup:

ppc-linux-gcc -std=gnu99 -O2 -Wall -Werror 
-DGIT_VERSION='"v5.0-rc3-560-ge0ce62731d77"' 
-I/root/linux-powerpc/tools/testing/selftests/powerpc/include  -O2 
-maltivec -mvsx -mabi=altivec    context_switch.c ../harness.c 
../utils.c -lpthread -o 
/root/linux-powerpc/tools/testing/selftests/powerpc/benchmarks/context_switch
context_switch.c:1:0: error: -mvsx requires hardware floating point 
[-Werror]
  /*
  ^
cc1: all warnings being treated as errors
../harness.c:1:0: error: -mvsx requires hardware floating point [-Werror]
  /*
  ^
cc1: all warnings being treated as errors
../utils.c:1:0: error: -mvsx requires hardware floating point [-Werror]
  /*
  ^
cc1: all warnings being treated as errors
make[1]: *** 
[/root/linux-powerpc/tools/testing/selftests/powerpc/benchmarks/context_switch] 
Error 1


By removing the -mvsx option, it compiles just fine.

Is that option really required ? According to gcc doc, it is 
automatically selected when compiling for cpus that support it.

I'm using:

[root@po16846vm linux-powerpc]# ppc-linux-gcc -v
Using built-in specs.
COLLECT_GCC=ppc-linux-gcc
COLLECT_LTO_WRAPPER=/opt/cldk-1.4.0/libexec/gcc/ppc-linux/5.4.0/lto-wrapper
Target: ppc-linux
Configured with: /root/cldk/gcc-5.4.0/configure --target=ppc-linux 
--with-headers=yes --with-cpu=860 --prefix=/opt/cldk-1.4.0 
--bindir=/opt/cldk-1.4.0/bin --sbindir=/opt/cldk-1.4.0/sbin 
--libexecdir=/opt/cldk-1.4.0/libexec --datadir=/opt/cldk-1.4.0/share 
--sysconfdir=/opt/cldk-1.4.0/etc --libdir=/opt/cldk-1.4.0/lib 
--includedir=/opt/cldk-1.4.0/usr/include 
--oldincludedir=/opt/cldk-1.4.0/usr/include 
--infodir=/opt/cldk-1.4.0/share/info --mandir=/opt/cldk-1.4.0/share/man 
--with-glibc-version=2.18 --enable-languages=c,c++
Thread model: posix
gcc version 5.4.0 (GCC)


Christophe

> ---
>   tools/testing/selftests/powerpc/benchmarks/Makefile         |  1 +
>   tools/testing/selftests/powerpc/benchmarks/context_switch.c | 11 ++++++++---
>   2 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
> index 912445f..6816fc2 100644
> --- a/tools/testing/selftests/powerpc/benchmarks/Makefile
> +++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
> @@ -7,6 +7,7 @@ all: $(TEST_PROGS)
>   $(TEST_PROGS): ../harness.c
>   
>   context_switch: ../utils.c
> +context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec
>   context_switch: LDLIBS += -lpthread
>   
>   include ../../lib.mk
> diff --git a/tools/testing/selftests/powerpc/benchmarks/context_switch.c b/tools/testing/selftests/powerpc/benchmarks/context_switch.c
> index e6af382..a36883a 100644
> --- a/tools/testing/selftests/powerpc/benchmarks/context_switch.c
> +++ b/tools/testing/selftests/powerpc/benchmarks/context_switch.c
> @@ -25,7 +25,9 @@
>   #include <sys/types.h>
>   #include <sys/shm.h>
>   #include <linux/futex.h>
> -
> +#ifdef __powerpc__
> +#include <altivec.h>
> +#endif
>   #include "../utils.h"
>   
>   static unsigned int timeout = 30;
> @@ -37,12 +39,15 @@ static int touch_fp = 1;
>   double fp;
>   
>   static int touch_vector = 1;
> -typedef int v4si __attribute__ ((vector_size (16)));
> -v4si a, b, c;
> +vector int a, b, c;
>   
>   #ifdef __powerpc__
>   static int touch_altivec = 1;
>   
> +/*
> + * Note: LTO (Link Time Optimisation) doesn't play well with this function
> + * attribute. Be very careful enabling LTO for this test.
> + */
>   static void __attribute__((__target__("no-vsx"))) altivec_touch_fn(void)
>   {
>   	c = a + b;
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-01-23  8:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-03 23:06 [PATCH 1/2] selftests/powerpc: benchmarks/context_switch.c improve usage message Cyril Bur
2016-03-03 23:06 ` [PATCH 2/2] selftests/powerpc: benchmarks/context_switch.c use vector instructions/types Cyril Bur
2016-07-05 14:10   ` [2/2] " Michael Ellerman
2019-01-23  8:47   ` [PATCH 2/2] " Christophe Leroy
2016-07-05 14:10 ` [1/2] selftests/powerpc: benchmarks/context_switch.c improve usage message Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).