Commit e3ef36a3 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Also align the proxy-cells and the proxy-multipoles.

parent a6aef317
...@@ -1482,9 +1482,9 @@ void engine_exchange_cells(struct engine *e) { ...@@ -1482,9 +1482,9 @@ void engine_exchange_cells(struct engine *e) {
} }
/* Allocate the pcells. */ /* Allocate the pcells. */
struct pcell *pcells; struct pcell *pcells = NULL;
if ((pcells = (struct pcell *)malloc(sizeof(struct pcell) * count_out)) == if (posix_memalign((void **)&pcells, SWIFT_CACHE_ALIGNMENT,
NULL) sizeof(struct pcell) * count_out) != 0)
error("Failed to allocate pcell buffer."); error("Failed to allocate pcell buffer.");
/* Pack the cells. */ /* Pack the cells. */
...@@ -2048,11 +2048,14 @@ void engine_exchange_proxy_multipoles(struct engine *e) { ...@@ -2048,11 +2048,14 @@ void engine_exchange_proxy_multipoles(struct engine *e) {
} }
/* Allocate the buffers for the packed data */ /* Allocate the buffers for the packed data */
struct gravity_tensors *buffer_send = struct gravity_tensors *buffer_send = NULL;
malloc(sizeof(struct gravity_tensors) * count_send); if (posix_memalign((void **)&buffer_send, SWIFT_CACHE_ALIGNMENT,
struct gravity_tensors *buffer_recv = count_send * sizeof(struct gravity_tensors)) != 0)
malloc(sizeof(struct gravity_tensors) * count_recv); error("Unable to allocate memory for multipole transactions");
if (buffer_send == NULL || buffer_recv == NULL)
struct gravity_tensors *buffer_recv = NULL;
if (posix_memalign((void **)&buffer_recv, SWIFT_CACHE_ALIGNMENT,
count_recv * sizeof(struct gravity_tensors)) != 0)
error("Unable to allocate memory for multipole transactions"); error("Unable to allocate memory for multipole transactions");
/* Also allocate the MPI requests */ /* Also allocate the MPI requests */
...@@ -4893,8 +4896,10 @@ void engine_split(struct engine *e, struct partition *initial_partition) { ...@@ -4893,8 +4896,10 @@ void engine_split(struct engine *e, struct partition *initial_partition) {
posix_memalign((void **)&xparts_new, xpart_align, posix_memalign((void **)&xparts_new, xpart_align,
sizeof(struct xpart) * s->size_parts) != 0) sizeof(struct xpart) * s->size_parts) != 0)
error("Failed to allocate new part data."); error("Failed to allocate new part data.");
if (s->nr_parts > 0) {
memcpy(parts_new, s->parts, sizeof(struct part) * s->nr_parts); memcpy(parts_new, s->parts, sizeof(struct part) * s->nr_parts);
memcpy(xparts_new, s->xparts, sizeof(struct xpart) * s->nr_parts); memcpy(xparts_new, s->xparts, sizeof(struct xpart) * s->nr_parts);
}
free(s->parts); free(s->parts);
free(s->xparts); free(s->xparts);
s->parts = parts_new; s->parts = parts_new;
...@@ -4913,6 +4918,7 @@ void engine_split(struct engine *e, struct partition *initial_partition) { ...@@ -4913,6 +4918,7 @@ void engine_split(struct engine *e, struct partition *initial_partition) {
if (posix_memalign((void **)&sparts_new, spart_align, if (posix_memalign((void **)&sparts_new, spart_align,
sizeof(struct spart) * s->size_sparts) != 0) sizeof(struct spart) * s->size_sparts) != 0)
error("Failed to allocate new spart data."); error("Failed to allocate new spart data.");
if (s->nr_sparts > 0)
memcpy(sparts_new, s->sparts, sizeof(struct spart) * s->nr_sparts); memcpy(sparts_new, s->sparts, sizeof(struct spart) * s->nr_sparts);
free(s->sparts); free(s->sparts);
s->sparts = sparts_new; s->sparts = sparts_new;
...@@ -4930,6 +4936,7 @@ void engine_split(struct engine *e, struct partition *initial_partition) { ...@@ -4930,6 +4936,7 @@ void engine_split(struct engine *e, struct partition *initial_partition) {
if (posix_memalign((void **)&gparts_new, gpart_align, if (posix_memalign((void **)&gparts_new, gpart_align,
sizeof(struct gpart) * s->size_gparts) != 0) sizeof(struct gpart) * s->size_gparts) != 0)
error("Failed to allocate new gpart data."); error("Failed to allocate new gpart data.");
if (s->nr_gparts > 0)
memcpy(gparts_new, s->gparts, sizeof(struct gpart) * s->nr_gparts); memcpy(gparts_new, s->gparts, sizeof(struct gpart) * s->nr_gparts);
free(s->gparts); free(s->gparts);
s->gparts = gparts_new; s->gparts = gparts_new;
...@@ -5450,7 +5457,7 @@ void engine_init(struct engine *e, struct space *s, ...@@ -5450,7 +5457,7 @@ void engine_init(struct engine *e, struct space *s,
parser_get_opt_param_int(params, "Scheduler:mpi_message_limit", 4) * 1024; parser_get_opt_param_int(params, "Scheduler:mpi_message_limit", 4) * 1024;
/* Allocate and init the threads. */ /* Allocate and init the threads. */
if (posix_memalign((void *)&e->runners, SWIFT_STRUCT_ALIGNMENT, if (posix_memalign((void **)&e->runners, SWIFT_CACHE_ALIGNMENT,
e->nr_threads * sizeof(struct runner)) != 0) e->nr_threads * sizeof(struct runner)) != 0)
error("Failed to allocate threads array."); error("Failed to allocate threads array.");
for (int k = 0; k < e->nr_threads; k++) { for (int k = 0; k < e->nr_threads; k++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment