Skip to content

Commit

Permalink
use proper cache-line size variable in work-stealing queue (JuliaLang…
Browse files Browse the repository at this point in the history
  • Loading branch information
d-netto authored Jan 24, 2024
1 parent f5816f4 commit 919c390
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/julia_atomics.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand Down
5 changes: 0 additions & 5 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*))
Expand Down
2 changes: 1 addition & 1 deletion src/work-stealing-queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 919c390

Please sign in to comment.