Skip to content

Commit 1b42c71

Browse files
committed
include/ofi_atomic_queue: fix create function
create function needs to align the allocation with the cache line size Signed-off-by: Alexia Ingerson <[email protected]>
1 parent debabb9 commit 1b42c71

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

include/ofi_atomic_queue.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,19 @@ static inline void name ## _init(struct name *aq, size_t size) \
128128
aq->size_mask = aq->size - 1; \
129129
ofi_atomic_initialize64(&aq->write_pos, 0); \
130130
ofi_atomic_initialize64(&aq->read_pos, 0); \
131-
for (i = 0; i < size; i++) \
131+
for (i = 0; i < size; i++) { \
132132
ofi_atomic_initialize64(&aq->entry[i].seq, i); \
133+
aq->entry[i].noop = false; \
134+
} \
133135
} \
134136
\
135137
static inline struct name * name ## _create(size_t size) \
136138
{ \
137139
struct name *aq; \
138-
aq = (struct name*) calloc(1, sizeof(*aq) + \
139-
sizeof(struct name ## _entry) * \
140-
(roundup_power_of_two(size))); \
140+
aq = (struct name *) aligned_alloc( \
141+
OFI_CACHE_LINE_SIZE, sizeof(*aq) + \
142+
sizeof(struct name ## _entry) * \
143+
(roundup_power_of_two(size))); \
141144
if (aq) \
142145
name ##_init(aq, roundup_power_of_two(size)); \
143146
return aq; \

0 commit comments

Comments
 (0)