Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using exclusive mode prefetch #627

Merged
merged 6 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/snmalloc/aal/aal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/snmalloc/aal/aal_arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/snmalloc/aal/aal_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down