From 71173c0e24e055ec233e220501b015670a1305fb Mon Sep 17 00:00:00 2001 From: Pedro Gonnet <gonnet@google.com> Date: Sun, 18 Dec 2016 23:26:45 +0100 Subject: [PATCH] allocate the cell_buff arrays aligned, as gcc assumes they will be and emits aligned read/writes in memswap. --- src/space.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/space.c b/src/space.c index 4908933265..5ef0ee1df0 100644 --- a/src/space.c +++ b/src/space.c @@ -1481,8 +1481,8 @@ void space_split_recursive(struct space *s, struct cell *c, const int allocate_buffer = (buff == NULL && gbuff == NULL); if (allocate_buffer) { if (count > 0) { - if ((buff = (struct cell_buff *)malloc(sizeof(struct cell_buff) * - count)) == NULL) + if (posix_memalign((void *)&buff, SWIFT_STRUCT_ALIGNMENT, + sizeof(struct cell_buff) * count) != 0) error("Failed to allocate temporary indices."); for (int k = 0; k < count; k++) { buff[k].x[0] = parts[k].x[0]; @@ -1491,8 +1491,8 @@ void space_split_recursive(struct space *s, struct cell *c, } } if (gcount > 0) { - if ((gbuff = (struct cell_buff *)malloc(sizeof(struct cell_buff) * - gcount)) == NULL) + if (posix_memalign((void *)&gbuff, SWIFT_STRUCT_ALIGNMENT, + sizeof(struct cell_buff) * gcount) != 0) error("Failed to allocate temporary indices."); for (int k = 0; k < gcount; k++) { gbuff[k].x[0] = gparts[k].x[0]; -- GitLab