From 6a06d014a38fc8282f7dda7c11e5cacd9daf44ca Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 27 Feb 2018 21:45:14 +0000 Subject: lib: Provide an accelerated routine for readback from WC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reading from WC is awfully slow as each access is uncached and so performed synchronously, stalling for the memory load. x86 did introduce some new instructions in SSE 4.1 to provide a small internal buffer to accelerate reading back a cacheline at a time from uncached memory, for this purpose. v2: Don't be lazy and handle misalignment. v3: Switch out of sse41 before emitting the generic memcpy routine v4: Replace opencoded memcpy_from_wc v5: Always flush the internal buffer before use (Eric) v6: Assume bulk moves, so check for dst alignment. v7: Use _mm_fence for _buitlin_ia32_mfence for consistency, remove superfluous defines (Ville) Signed-off-by: Chris Wilson Cc: Eric Anholt Reviewed-by: Ville Syrjälä --- tests/gem_fence_thrash.c | 63 ++---------------------------------------------- 1 file changed, 2 insertions(+), 61 deletions(-) (limited to 'tests/gem_fence_thrash.c') diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c index c8ff961d..2d7fb2ff 100644 --- a/tests/gem_fence_thrash.c +++ b/tests/gem_fence_thrash.c @@ -107,75 +107,16 @@ bo_copy (void *_arg) return NULL; } -#if defined(__x86_64__) && !defined(__clang__) - -#pragma GCC push_options -#pragma GCC target("sse4.1") - -#include - -#define MOVNT 512 - -__attribute__((noinline)) -static void copy_wc_page(void *dst, void *src) -{ - if (igt_x86_features() & SSE4_1) { - __m128i *S = (__m128i *)src; - __m128i *D = (__m128i *)dst; - - for (int i = 0; i < PAGE_SIZE/CACHELINE; i++) { - __m128i tmp[4]; - - tmp[0] = _mm_stream_load_si128(S++); - tmp[1] = _mm_stream_load_si128(S++); - tmp[2] = _mm_stream_load_si128(S++); - tmp[3] = _mm_stream_load_si128(S++); - - _mm_store_si128(D++, tmp[0]); - _mm_store_si128(D++, tmp[1]); - _mm_store_si128(D++, tmp[2]); - _mm_store_si128(D++, tmp[3]); - } - } else - memcpy(dst, src, PAGE_SIZE); -} - -static void copy_wc_cacheline(void *dst, void *src) -{ - if (igt_x86_features() & SSE4_1) { - __m128i *S = (__m128i *)src; - __m128i *D = (__m128i *)dst; - __m128i tmp[4]; - - tmp[0] = _mm_stream_load_si128(S++); - tmp[1] = _mm_stream_load_si128(S++); - tmp[2] = _mm_stream_load_si128(S++); - tmp[3] = _mm_stream_load_si128(S++); - - _mm_store_si128(D++, tmp[0]); - _mm_store_si128(D++, tmp[1]); - _mm_store_si128(D++, tmp[2]); - _mm_store_si128(D++, tmp[3]); - } else - memcpy(dst, src, CACHELINE); -} - -#pragma GCC pop_options - -#else - static void copy_wc_page(void *dst, const void *src) { - memcpy(dst, src, PAGE_SIZE); + igt_memcpy_from_wc(dst, src, PAGE_SIZE); } static void copy_wc_cacheline(void *dst, const void *src) { - memcpy(dst, src, CACHELINE); + igt_memcpy_from_wc(dst, src, CACHELINE); } -#endif - static void _bo_write_verify(struct test *t) { -- cgit v1.2.3