Skip to content

Commit

Permalink
version check jl_fence
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed Jan 24, 2023
1 parent d0907be commit 0f11cac
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/julia_atomics.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ enum jl_memory_order {
* are). We also need to access these atomic variables from the LLVM JIT code
* which is very hard unless the layout of the object is fully specified.
*/
#if defined(_CPU_X86_64_)

/**
* On modern Intel and AMD platforms `lock orq` on the SP is faster than
* `mfence`. GCC 11 did switch to this representation. See #48123
*/
#if defined(_CPU_X86_64_) && \
((defined(__GNUC__) && __GNUC__ < 11) || \
(defined(__clang__)))
#define jl_fence() __asm__ volatile("lock orq $0 , (%rsp)")
#else
#define jl_fence() atomic_thread_fence(memory_order_seq_cst)
Expand Down

0 comments on commit 0f11cac

Please sign in to comment.