]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Optimize by prefetching on aarch64 2040/head
authorcaoyzh <caoyazhen_ok@163.com>
Sat, 14 Mar 2020 07:25:09 +0000 (15:25 +0800)
committercaoyzh <caoyazhen_ok@163.com>
Sat, 14 Mar 2020 07:25:59 +0000 (15:25 +0800)
lib/common/compiler.h
lib/compress/zstd_double_fast.c
lib/compress/zstd_fast.c

index 4213dfcf3615672a098627bec7b4297e4203a83c..5fd92f0402d5892a8478042e3fb937dc182591fc 100644 (file)
 #    include <mmintrin.h>   /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
 #    define PREFETCH_L1(ptr)  _mm_prefetch((const char*)(ptr), _MM_HINT_T0)
 #    define PREFETCH_L2(ptr)  _mm_prefetch((const char*)(ptr), _MM_HINT_T1)
+#    elif defined(__aarch64__)
+#     define PREFETCH_L1(ptr)  __asm__ __volatile__("prfm pldl1keep, %0" ::"Q"(*(ptr)))
+#     define PREFETCH_L2(ptr)  __asm__ __volatile__("prfm pldl2keep, %0" ::"Q"(*(ptr)))
 #  elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) )
 #    define PREFETCH_L1(ptr)  __builtin_prefetch((ptr), 0 /* rw==read */, 3 /* locality */)
 #    define PREFETCH_L2(ptr)  __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */)
index 2e657f7c4265f5e5656c3f05b9b1fc169d4e9cc7..ef09a6968beb4c5009422c88b20a872ad4484d2e 100644 (file)
@@ -198,6 +198,9 @@ size_t ZSTD_compressBlock_doubleFast_generic(
         }   }
 
         ip += ((ip-anchor) >> kSearchStrength) + 1;
+#if defined(__aarch64__)
+        PREFETCH_L1(ip+256);
+#endif
         continue;
 
 _search_next_long:
index 09e220b3abc0358c34dfa87f7df829fb9ee2e2b3..556dc5a9a9898908be33b8397d7ed37b253bce78 100644 (file)
@@ -102,6 +102,11 @@ ZSTD_compressBlock_fast_generic(
         const BYTE* match0 = base + matchIndex0;
         const BYTE* match1 = base + matchIndex1;
         U32 offcode;
+
+#if defined(__aarch64__)
+        PREFETCH_L1(ip0+256);
+#endif
+
         hashTable[h0] = current0;   /* update hash table */
         hashTable[h1] = current1;   /* update hash table */