added conditional prefetch

depending on amount of work to do.
This commit is contained in:
Yann Collet
2018-09-12 10:29:47 -07:00
parent 63a519dbf6
commit 4de344d505
2 changed files with 35 additions and 30 deletions
+9 -7
View File
@@ -95,19 +95,21 @@
#else
# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */
# include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
# define PREFETCH(ptr) _mm_prefetch((const char*)ptr, _MM_HINT_T0)
# define PREFETCH(ptr) _mm_prefetch((const char*)ptr, _MM_HINT_T1)
# elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) )
# define PREFETCH(ptr) __builtin_prefetch(ptr, 0 /* rw==read */, 0 /* locality */)
# define PREFETCH(ptr) __builtin_prefetch(ptr, 0 /* rw==read */, 2 /* locality */)
# else
# define PREFETCH(ptr) /* disabled */
# endif
#endif /* NO_PREFETCH */
#define PREFETCH_AREA(ptr, size) { \
size_t pos; \
for (pos=0; pos<size; pos++) { \
PREFETCH( (const char*)(const void*)ptr + pos); \
} \
#define CACHELINE_SIZE 64
#define PREFETCH_AREA(ptr, size) { \
size_t pos; \
for (pos=0; pos<size; pos+=CACHELINE_SIZE) { \
PREFETCH( (const char*)ptr + pos); \
} \
}
/* disable warnings */