diff mbox

[i-g-t] tests: Fix compilation when some gcc configurations

Message ID 1468517497-7859-1-git-send-email-damien.lespiau@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lespiau, Damien July 14, 2016, 5:31 p.m. UTC
Depending how the gcc was compiled it may be necessary to enable SSE4
instructions explicitly. Otherwise:

  CC       gem_gtt_speed.o
In file included from gem_gtt_speed.c:54:0:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/smmintrin.h:31:3: error: #error "SSE4.1 instruction set not enabled"
 # error "SSE4.1 instruction set not enabled"
   ^
gem_gtt_speed.c: In function ‘streaming_load’:
gem_gtt_speed.c:59:2: error: unknown type name ‘__m128i’
  __m128i tmp, *s = src;
  ^
gem_gtt_speed.c:65:3: error: implicit declaration of function ‘_mm_stream_load_si128’ [-Werror=implicit-function-declaration]
   tmp += _mm_stream_load_si128(s++);
   ^
gem_gtt_speed.c:65:3: warning: nested extern declaration of ‘_mm_stream_load_si128’ [-Wnested-externs]
gem_gtt_speed.c:70:2: error: unknown type name ‘__m128i’
  *(volatile __m128i *)src = tmp;
  ^

CC: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 tests/Makefile.am | 2 ++
 1 file changed, 2 insertions(+)

Comments

Chris Wilson July 14, 2016, 5:44 p.m. UTC | #1
On Thu, Jul 14, 2016 at 06:31:37PM +0100, Damien Lespiau wrote:
> Depending how the gcc was compiled it may be necessary to enable SSE4
> instructions explicitly. Otherwise:
> 
>   CC       gem_gtt_speed.o
> In file included from gem_gtt_speed.c:54:0:
> /usr/lib/gcc/x86_64-linux-gnu/4.8/include/smmintrin.h:31:3: error: #error "SSE4.1 instruction set not enabled"
>  # error "SSE4.1 instruction set not enabled"

So the challenge is getting the function attribute applied to the
include.

Ah, can you try
#pragma GCC target ("sse4.1")
in those blocks instead?

> @@ -76,6 +76,7 @@ gem_ctx_basic_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
>  gem_ctx_basic_LDADD = $(LDADD) -lpthread
>  gem_ctx_thrash_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
>  gem_ctx_thrash_LDADD = $(LDADD) -lpthread
> +gem_exec_flush_CFLAGS = $(AM_CFLAGS) -msse4

Note, it should be -msse4.1
-Chris
Chris Wilson July 14, 2016, 5:48 p.m. UTC | #2
On Thu, Jul 14, 2016 at 06:44:59PM +0100, Chris Wilson wrote:
> On Thu, Jul 14, 2016 at 06:31:37PM +0100, Damien Lespiau wrote:
> > Depending how the gcc was compiled it may be necessary to enable SSE4
> > instructions explicitly. Otherwise:
> > 
> >   CC       gem_gtt_speed.o
> > In file included from gem_gtt_speed.c:54:0:
> > /usr/lib/gcc/x86_64-linux-gnu/4.8/include/smmintrin.h:31:3: error: #error "SSE4.1 instruction set not enabled"
> >  # error "SSE4.1 instruction set not enabled"
> 
> So the challenge is getting the function attribute applied to the
> include.
> 
> Ah, can you try
> #pragma GCC target ("sse4.1")
> in those blocks instead?

Oh, and we probably need an #if GCC > 4.y to be fully backwards
compatible.
-Chris
Lespiau, Damien July 15, 2016, 11:09 a.m. UTC | #3
On Thu, Jul 14, 2016 at 06:48:26PM +0100, Chris Wilson wrote:
> On Thu, Jul 14, 2016 at 06:44:59PM +0100, Chris Wilson wrote:
> > On Thu, Jul 14, 2016 at 06:31:37PM +0100, Damien Lespiau wrote:
> > > Depending how the gcc was compiled it may be necessary to enable SSE4
> > > instructions explicitly. Otherwise:
> > > 
> > >   CC       gem_gtt_speed.o
> > > In file included from gem_gtt_speed.c:54:0:
> > > /usr/lib/gcc/x86_64-linux-gnu/4.8/include/smmintrin.h:31:3: error: #error "SSE4.1 instruction set not enabled"
> > >  # error "SSE4.1 instruction set not enabled"
> > 
> > So the challenge is getting the function attribute applied to the
> > include.
> > 
> > Ah, can you try
> > #pragma GCC target ("sse4.1")
> > in those blocks instead?

Yup, that also seems to enable sse4.1 for the rest of the compilation
unit.

> Oh, and we probably need an #if GCC > 4.y to be fully backwards
> compatible.

Couldn't find in less than 5 mins this information, gave up. Someone
exhibiting the problem will have to fix it :)
diff mbox

Patch

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 102b8a6..8c6b0a3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -76,6 +76,7 @@  gem_ctx_basic_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_ctx_basic_LDADD = $(LDADD) -lpthread
 gem_ctx_thrash_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_ctx_thrash_LDADD = $(LDADD) -lpthread
+gem_exec_flush_CFLAGS = $(AM_CFLAGS) -msse4
 gem_exec_parallel_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_exec_parallel_LDADD = $(LDADD) -lpthread
 gem_fence_thrash_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
@@ -84,6 +85,7 @@  gem_fence_upload_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_fence_upload_LDADD = $(LDADD) -lpthread
 gem_flink_race_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_flink_race_LDADD = $(LDADD) -lpthread
+gem_gtt_speed_CFLAGS = $(AM_CFLAGS) -msse4
 gem_mmap_gtt_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
 gem_mmap_gtt_LDADD = $(LDADD) -lpthread
 gem_mmap_wc_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)