Skip to content

Commit

Permalink
Add prefetch to mpscq.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjp41 committed Jul 2, 2019
1 parent daebe3f commit fdcbcf7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ds/bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ namespace snmalloc
#endif
}

inline void prefetch(void* ptr)
{
#if defined(PLATFORM_IS_X86)
_mm_prefetch(reinterpret_cast<const char *>(ptr), _MM_HINT_T0);
#else
# warning "Missing pause intrinsic"
#endif
}

inline uint64_t tick()
{
#if defined(PLATFORM_IS_X86)
Expand Down
1 change: 1 addition & 0 deletions src/ds/mpscq.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ namespace snmalloc
if (next != nullptr)
{
front = next;
bits::prefetch(&(next->next));
assert(front);
std::atomic_thread_fence(std::memory_order_acquire);
invariant();
Expand Down

0 comments on commit fdcbcf7

Please sign in to comment.