From 76f7dbf79a801b030d215f60b5a2a6ffaf8d2fd7 Mon Sep 17 00:00:00 2001 From: d-netto Date: Wed, 24 Jan 2024 10:29:49 -0300 Subject: [PATCH] use proper cache-line size variable in work-stealing queue --- src/julia_atomics.h | 9 +++++++++ src/julia_internal.h | 5 ----- src/work-stealing-queue.h | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/julia_atomics.h b/src/julia_atomics.h index c4488f774c987..76be881067805 100644 --- a/src/julia_atomics.h +++ b/src/julia_atomics.h @@ -56,6 +56,15 @@ enum jl_memory_order { jl_memory_order_seq_cst }; +/** + * Cache line size +*/ +#if defined(_CPU_AARCH64_) && defined(_OS_DARWIN_) // Apple silicon has 128 cache lines +#define JL_CACHE_BYTE_ALIGNMENT 128 +#else +#define JL_CACHE_BYTE_ALIGNMENT 64 +#endif + /** * Thread synchronization primitives: * diff --git a/src/julia_internal.h b/src/julia_internal.h index d8e9a909f1761..b85ccdede884d 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -485,11 +485,6 @@ STATIC_INLINE uint8_t JL_CONST_FUNC jl_gc_szclass_align8(unsigned sz) JL_NOTSAFE } #define JL_SMALL_BYTE_ALIGNMENT 16 -#if defined(_CPU_AARCH64_) && defined(_OS_DARWIN_) // Apple silicon has 128 cache lines -#define JL_CACHE_BYTE_ALIGNMENT 128 -#else -#define JL_CACHE_BYTE_ALIGNMENT 64 -#endif // JL_HEAP_ALIGNMENT is the maximum alignment that the GC can provide #define JL_HEAP_ALIGNMENT JL_SMALL_BYTE_ALIGNMENT #define GC_MAX_SZCLASS (2032-sizeof(void*)) diff --git a/src/work-stealing-queue.h b/src/work-stealing-queue.h index 084e421fd58b3..5902c2ac6af9f 100644 --- a/src/work-stealing-queue.h +++ b/src/work-stealing-queue.h @@ -36,7 +36,7 @@ static inline ws_array_t *create_ws_array(size_t capacity, int32_t eltsz) JL_NOT typedef struct { _Atomic(int64_t) top; - char _padding[128 - sizeof(int64_t)]; + char _padding[JL_CACHE_BYTE_ALIGNMENT - sizeof(_Atomic(int64_t))]; _Atomic(int64_t) bottom; // put on a separate cache line. conservatively estimate cache line size as 128 bytes _Atomic(ws_array_t *) array; } ws_queue_t;