Using exclusive mode prefetch (#627)

* Using exclusive mode prefetch

The prefetching is always used to move the cache line to the current
core for writing.  This change makes it use exclusive mode prefetch
and enables it as a feature flag for x64.

* Debug platform for BSDs

* CI fixes

* More CI

* Update ARM prefetch

* Update x64 prefetch default
This commit is contained in:
Matthew Parkinson
2023-08-09 07:15:37 +01:00
committed by GitHub
parent 6cbc50fe2c
commit c2e4a12e21
4 changed files with 12 additions and 3 deletions

View File

@@ -386,6 +386,11 @@ if(NOT SNMALLOC_HEADER_ONLY_LIBRARY)
target_compile_definitions(${name} PRIVATE "SNMALLOC_EXPORT=__attribute__((visibility(\"default\")))")
target_compile_options(${name} PRIVATE
-fomit-frame-pointer -ffunction-sections)
check_cxx_compiler_flag("-Werror -Wextra -Wall -mprfchw" SUPPORT_PREFETCH_WRITE)
if (SUPPORT_PREFETCH_WRITE)
target_compile_options(${name} PRIVATE -mprfchw)
endif()
# Static TLS model is unsupported on Haiku.
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Haiku")
target_compile_options(${name} PRIVATE -ftls-model=initial-exec)

View File

@@ -147,7 +147,7 @@ namespace snmalloc
static inline void prefetch(void* ptr) noexcept
{
#if __has_builtin(__builtin_prefetch) && !defined(SNMALLOC_NO_AAL_BUILTINS)
__builtin_prefetch(ptr);
__builtin_prefetch(ptr, 1, 3);
#else
Arch::prefetch(ptr);
#endif

View File

@@ -54,7 +54,7 @@ namespace snmalloc
#elif __has_builtin(__builtin_prefetch) && !defined(SNMALLOC_NO_AAL_BUILTINS)
__builtin_prefetch(ptr);
#elif defined(SNMALLOC_VA_BITS_64)
__asm__ volatile("prfm pldl1keep, [%0]" : "=r"(ptr));
__asm__ volatile("prfm pstl1keep, [%0]" : "=r"(ptr));
#else
__asm__ volatile("pld\t[%0]" : "=r"(ptr));
#endif

View File

@@ -78,7 +78,11 @@ namespace snmalloc
*/
static inline void prefetch(void* ptr)
{
_mm_prefetch(reinterpret_cast<const char*>(ptr), _MM_HINT_T0);
#if defined(_MSC_VER)
_m_prefetchw(ptr);
#else
_mm_prefetch(reinterpret_cast<const char*>(ptr), _MM_HINT_ET0);
#endif
}
/**