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

More spart<->gpart link fixes.

parent 910721b2
...@@ -1224,7 +1224,7 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts, ...@@ -1224,7 +1224,7 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts,
s->sparts[offset_sparts + k].x[0], s->sparts[offset_sparts + k].x[1], s->sparts[offset_sparts + k].x[0], s->sparts[offset_sparts + k].x[1],
s->sparts[offset_sparts + k].x[2]); s->sparts[offset_sparts + k].x[2]);
/* Re-link the associated gpart with the buffer offset of the part. */ /* Re-link the associated gpart with the buffer offset of the spart. */
if (s->sparts[offset_sparts + k].gpart != NULL) { if (s->sparts[offset_sparts + k].gpart != NULL) {
s->sparts[offset_sparts + k].gpart->id_or_neg_offset = s->sparts[offset_sparts + k].gpart->id_or_neg_offset =
-e->proxies[pid].nr_sparts_out; -e->proxies[pid].nr_sparts_out;
...@@ -1307,7 +1307,7 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts, ...@@ -1307,7 +1307,7 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts,
memcpy(sparts_new, s->sparts, sizeof(struct spart) * offset_sparts); memcpy(sparts_new, s->sparts, sizeof(struct spart) * offset_sparts);
free(s->sparts); free(s->sparts);
s->sparts = sparts_new; s->sparts = sparts_new;
for (size_t k = 0; k < offset_parts; k++) { for (size_t k = 0; k < offset_sparts; k++) {
if (s->sparts[k].gpart != NULL) { if (s->sparts[k].gpart != NULL) {
s->sparts[k].gpart->id_or_neg_offset = -k; s->sparts[k].gpart->id_or_neg_offset = -k;
} }
......
...@@ -515,9 +515,9 @@ void space_rebuild(struct space *s, int verbose) { ...@@ -515,9 +515,9 @@ void space_rebuild(struct space *s, int verbose) {
space_sparts_get_cell_index(s, sind, cells_top, verbose); space_sparts_get_cell_index(s, sind, cells_top, verbose);
#ifdef WITH_MPI #ifdef WITH_MPI
const int local_nodeID = s->e->nodeID;
/* Move non-local parts to the end of the list. */ /* Move non-local parts to the end of the list. */
const int local_nodeID = s->e->nodeID;
for (size_t k = 0; k < nr_parts;) { for (size_t k = 0; k < nr_parts;) {
if (cells_top[ind[k]].nodeID != local_nodeID) { if (cells_top[ind[k]].nodeID != local_nodeID) {
nr_parts -= 1; nr_parts -= 1;
...@@ -669,10 +669,10 @@ void space_rebuild(struct space *s, int verbose) { ...@@ -669,10 +669,10 @@ void space_rebuild(struct space *s, int verbose) {
} }
/* Re-allocate the index array for the sparts if needed.. */ /* Re-allocate the index array for the sparts if needed.. */
if (s->nr_sparts + 1 > ind_size) { if (s->nr_sparts + 1 > sind_size) {
int *sind_new; int *sind_new;
if ((sind_new = (int *)malloc(sizeof(int) * (s->nr_sparts + 1))) == NULL) if ((sind_new = (int *)malloc(sizeof(int) * (s->nr_sparts + 1))) == NULL)
error("Failed to allocate temporary particle indices."); error("Failed to allocate temporary s-particle indices.");
memcpy(sind_new, sind, sizeof(int) * nr_sparts); memcpy(sind_new, sind, sizeof(int) * nr_sparts);
free(sind); free(sind);
sind = sind_new; sind = sind_new;
...@@ -681,7 +681,7 @@ void space_rebuild(struct space *s, int verbose) { ...@@ -681,7 +681,7 @@ void space_rebuild(struct space *s, int verbose) {
const int cdim[3] = {s->cdim[0], s->cdim[1], s->cdim[2]}; const int cdim[3] = {s->cdim[0], s->cdim[1], s->cdim[2]};
const double ih[3] = {s->iwidth[0], s->iwidth[1], s->iwidth[2]}; const double ih[3] = {s->iwidth[0], s->iwidth[1], s->iwidth[2]};
/* Assign each part to its cell. */ /* Assign each received part to its cell. */
for (size_t k = nr_parts; k < s->nr_parts; k++) { for (size_t k = nr_parts; k < s->nr_parts; k++) {
const struct part *const p = &s->parts[k]; const struct part *const p = &s->parts[k];
ind[k] = ind[k] =
...@@ -694,14 +694,14 @@ void space_rebuild(struct space *s, int verbose) { ...@@ -694,14 +694,14 @@ void space_rebuild(struct space *s, int verbose) {
} }
nr_parts = s->nr_parts; nr_parts = s->nr_parts;
/* Assign each spart to its cell. */ /* Assign each received spart to its cell. */
for (size_t k = nr_sparts; k < s->nr_sparts; k++) { for (size_t k = nr_sparts; k < s->nr_sparts; k++) {
const struct spart *const sp = &s->sparts[k]; const struct spart *const sp = &s->sparts[k];
sind[k] = sind[k] =
cell_getid(cdim, sp->x[0] * ih[0], sp->x[1] * ih[1], sp->x[2] * ih[2]); cell_getid(cdim, sp->x[0] * ih[0], sp->x[1] * ih[1], sp->x[2] * ih[2]);
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (cells_top[sind[k]].nodeID != local_nodeID) if (cells_top[sind[k]].nodeID != local_nodeID)
error("Received part that does not belong to me (nodeID=%i).", error("Received s-part that does not belong to me (nodeID=%i).",
cells_top[sind[k]].nodeID); cells_top[sind[k]].nodeID);
#endif #endif
} }
...@@ -772,7 +772,7 @@ void space_rebuild(struct space *s, int verbose) { ...@@ -772,7 +772,7 @@ void space_rebuild(struct space *s, int verbose) {
gind = gind_new; gind = gind_new;
} }
/* Assign each gpart to its cell. */ /* Assign each received gpart to its cell. */
for (size_t k = nr_gparts; k < s->nr_gparts; k++) { for (size_t k = nr_gparts; k < s->nr_gparts; k++) {
const struct gpart *const p = &s->gparts[k]; const struct gpart *const p = &s->gparts[k];
gind[k] = gind[k] =
...@@ -780,7 +780,7 @@ void space_rebuild(struct space *s, int verbose) { ...@@ -780,7 +780,7 @@ void space_rebuild(struct space *s, int verbose) {
#ifdef SWIFT_DEBUG_CHECKS #ifdef SWIFT_DEBUG_CHECKS
if (cells_top[gind[k]].nodeID != s->e->nodeID) if (cells_top[gind[k]].nodeID != s->e->nodeID)
error("Received part that does not belong to me (nodeID=%i).", error("Received g-part that does not belong to me (nodeID=%i).",
cells_top[gind[k]].nodeID); cells_top[gind[k]].nodeID);
#endif #endif
} }
...@@ -1416,21 +1416,22 @@ void space_sparts_sort_mapper(void *map_data, int num_elements, ...@@ -1416,21 +1416,22 @@ void space_sparts_sort_mapper(void *map_data, int num_elements,
} }
} }
#ifdef SWIFT_DEBUG_CHECKS /* #ifdef SWIFT_DEBUG_CHECKS */
/* Verify space_sort_struct. */ /* /\* Verify space_sort_struct. *\/ */
for (int k = i; k <= jj; k++) /* for (int k = i; k <= jj; k++) */
if (ind[k] > pivot) { /* if (ind[k] > pivot) { */
message("sorting failed at k=%i, ind[k]=%i, pivot=%i, i=%li, j=%li.", /* message("sorting failed at k=%i, ind[k]=%i, pivot=%i, i=%li, j=%li.", */
k, ind[k], pivot, i, j); /* k, ind[k], pivot, i, j); */
error("Partition failed (<=pivot)."); /* error("Partition failed (<=pivot)."); */
} /* } */
for (int k = jj + 1; k <= j; k++) /* for (int k = jj + 1; k <= j; k++) */
if (ind[k] <= pivot) { /* if (ind[k] <= pivot) { */
message("sorting failed at k=%i, ind[k]=%i, pivot=%i, i=%li, j=%li.", /* message("sorting failed at k=%i, ind[k]=%i, pivot=%i, i=%li, j=%li.", */
k, ind[k], pivot, i, j); /* k, ind[k], pivot, i, j); */
error("Partition failed (>pivot)."); /* error("Partition failed (>pivot)."); */
} /* } */
#endif /* #endif */
//MATTHIEU --> Check what happens here when Nspart == 0
/* Split-off largest interval. */ /* Split-off largest interval. */
if (jj - i > j - jj + 1) { if (jj - i > j - jj + 1) {
......
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