Skip to content

Commit 919c390

Browse files
authored
use proper cache-line size variable in work-stealing queue (JuliaLang#53035)
1 parent f5816f4 commit 919c390

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/julia_atomics.h

+9
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ enum jl_memory_order {
5656
jl_memory_order_seq_cst
5757
};
5858

59+
/**
60+
* Cache line size
61+
*/
62+
#if defined(_CPU_AARCH64_) && defined(_OS_DARWIN_) // Apple silicon has 128 cache lines
63+
#define JL_CACHE_BYTE_ALIGNMENT 128
64+
#else
65+
#define JL_CACHE_BYTE_ALIGNMENT 64
66+
#endif
67+
5968
/**
6069
* Thread synchronization primitives:
6170
*

src/julia_internal.h

-5
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,6 @@ STATIC_INLINE uint8_t JL_CONST_FUNC jl_gc_szclass_align8(unsigned sz) JL_NOTSAFE
485485
}
486486

487487
#define JL_SMALL_BYTE_ALIGNMENT 16
488-
#if defined(_CPU_AARCH64_) && defined(_OS_DARWIN_) // Apple silicon has 128 cache lines
489-
#define JL_CACHE_BYTE_ALIGNMENT 128
490-
#else
491-
#define JL_CACHE_BYTE_ALIGNMENT 64
492-
#endif
493488
// JL_HEAP_ALIGNMENT is the maximum alignment that the GC can provide
494489
#define JL_HEAP_ALIGNMENT JL_SMALL_BYTE_ALIGNMENT
495490
#define GC_MAX_SZCLASS (2032-sizeof(void*))

src/work-stealing-queue.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static inline ws_array_t *create_ws_array(size_t capacity, int32_t eltsz) JL_NOT
3636

3737
typedef struct {
3838
_Atomic(int64_t) top;
39-
char _padding[128 - sizeof(int64_t)];
39+
char _padding[JL_CACHE_BYTE_ALIGNMENT - sizeof(_Atomic(int64_t))];
4040
_Atomic(int64_t) bottom; // put on a separate cache line. conservatively estimate cache line size as 128 bytes
4141
_Atomic(ws_array_t *) array;
4242
} ws_queue_t;

0 commit comments

Comments
 (0)