Skip to content

Commit

Permalink
yet more atomics & cache-line fixes on work-stealing queue
Browse files Browse the repository at this point in the history
  • Loading branch information
d-netto committed Feb 22, 2024
1 parent 8425b0e commit cfa3be2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/work-stealing-queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#ifndef WORK_STEALING_QUEUE_H
#define WORK_STEALING_QUEUE_H

#include <stdalign.h>

#include "julia_atomics.h"
#include "assert.h"

Expand Down Expand Up @@ -35,10 +37,10 @@ static inline ws_array_t *create_ws_array(size_t capacity, int32_t eltsz) JL_NOT
}

typedef struct {
_Atomic(int64_t) top;
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;
// align to JL_CACHE_BYTE_ALIGNMENT
alignas(JL_CACHE_BYTE_ALIGNMENT) _Atomic(int64_t) top;
alignas(JL_CACHE_BYTE_ALIGNMENT) _Atomic(int64_t) bottom;
alignas(JL_CACHE_BYTE_ALIGNMENT) _Atomic(ws_array_t *) array;
} ws_queue_t;

static inline ws_array_t *ws_queue_push(ws_queue_t *q, void *elt, int32_t eltsz) JL_NOTSAFEPOINT
Expand Down

0 comments on commit cfa3be2

Please sign in to comment.