diff --git a/src/engine.c b/src/engine.c index f14f004c7bc3455b2c997fe52c39694947ddad6b..2e59fb6a9cd5f0afbc2f35c66034d3477fe668c0 100644 --- a/src/engine.c +++ b/src/engine.c @@ -596,29 +596,32 @@ void engine_exchange_cells(struct engine *e) { * @brief Exchange straying parts with other nodes. * * @param e The #engine. - * @param offset_parts The index in the parts array as of which the foreign parts + * @param offset_parts The index in the parts array as of which the foreign + *parts *reside. * @param ind_part The foreign #cell ID of each part. * @param Npart The number of stray parts, contains the number of parts received * on return. - * @param offset_gparts The index in the gparts array as of which the foreign parts + * @param offset_gparts The index in the gparts array as of which the foreign + *parts *reside. * @param ind_gpart The foreign #cell ID of each gpart. - * @param Ngpart The number of stray gparts, contains the number of gparts received + * @param Ngpart The number of stray gparts, contains the number of gparts + *received * on return. * * @return The number of arrived parts copied to parts and xparts. */ -void engine_exchange_strays(struct engine *e, size_t offset_parts, int *ind_part, - size_t *Npart, size_t offset_gparts, int *ind_gpart, - size_t *Ngpart) { +void engine_exchange_strays(struct engine *e, size_t offset_parts, + int *ind_part, size_t *Npart, size_t offset_gparts, + int *ind_gpart, size_t *Ngpart) { #ifdef WITH_MPI struct space *s = e->s; ticks tic = getticks(); - + /* Re-set the proxies. */ for (int k = 0; k < e->nr_proxies; k++) e->proxies[k].nr_parts_out = 0; @@ -632,8 +635,9 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts, int *ind_part error( "Do not have a proxy for the requested nodeID %i for part with " "id=%llu, x=[%e,%e,%e].", - node_id, s->parts[offset_parts + k].id, s->parts[offset_parts + k].x[0], - s->parts[offset_parts + k].x[1], s->parts[offset_parts + k].x[2]); + node_id, s->parts[offset_parts + k].id, + s->parts[offset_parts + k].x[0], s->parts[offset_parts + k].x[1], + s->parts[offset_parts + k].x[2]); proxy_parts_load(&e->proxies[pid], &s->parts[offset_parts + k], &s->xparts[offset_parts + k], 1); } @@ -646,8 +650,9 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts, int *ind_part error( "Do not have a proxy for the requested nodeID %i for part with " "id=%zi, x=[%e,%e,%e].", - node_id, s->gparts[offset_parts + k].id, s->gparts[offset_gparts + k].x[0], - s->gparts[offset_parts + k].x[1], s->gparts[offset_gparts + k].x[2]); + node_id, s->gparts[offset_parts + k].id, + s->gparts[offset_gparts + k].x[0], s->gparts[offset_parts + k].x[1], + s->gparts[offset_gparts + k].x[2]); proxy_gparts_load(&e->proxies[pid], &s->gparts[offset_gparts + k], 1); } @@ -685,7 +690,7 @@ void engine_exchange_strays(struct engine *e, size_t offset_parts, int *ind_part } if (e->verbose) { message("sent out %zi/%zi parts/gparts, got %i/%i back.", *Npart, *Ngpart, - count_parts_in, count_gparts_in); + count_parts_in, count_gparts_in); } if (offset_parts + count_parts_in > s->size_parts) { s->size_parts = (offset_parts + count_parts_in) * 1.05; @@ -1231,8 +1236,8 @@ void engine_print_task_counts(struct engine *e) { else counts[task_type_count] += 1; #ifdef WITH_MPI - printf("[%04i] %s engine_print_task_counts: task counts are [ %s=%i", e->nodeID, - clocks_get_timesincestart(), taskID_names[0], counts[0]); + printf("[%04i] %s engine_print_task_counts: task counts are [ %s=%i", + e->nodeID, clocks_get_timesincestart(), taskID_names[0], counts[0]); #else printf("%s engine_print_task_counts: task counts are [ %s=%i", clocks_get_timesincestart(), taskID_names[0], counts[0]); diff --git a/src/proxy.c b/src/proxy.c index 41ae0308b5f914ab4e043f4501c7e216cb1fe4e0..2da14767848cfc4b242e4d6a45810e07410e1e52 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -249,7 +249,7 @@ void proxy_parts_exch2(struct proxy *p) { /* Unpack the incomming parts counts. */ p->nr_parts_in = p->buff_in[0]; p->nr_gparts_in = p->buff_in[1]; - + /* Is there enough space in the buffer? */ if (p->nr_parts_in > p->size_parts_in) { do { @@ -268,8 +268,8 @@ void proxy_parts_exch2(struct proxy *p) { p->size_gparts_in *= proxy_buffgrow; } while (p->nr_gparts_in > p->size_gparts_in); free(p->gparts_in); - if ((p->gparts_in = (struct gpart *)malloc( - sizeof(struct gpart) *p->size_gparts_in)) == NULL) + if ((p->gparts_in = (struct gpart *)malloc(sizeof(struct gpart) * + p->size_gparts_in)) == NULL) error("Failed to re-allocate gparts_in buffers."); } @@ -286,8 +286,9 @@ void proxy_parts_exch2(struct proxy *p) { // p->nodeID ); fflush(stdout); } if (p->nr_gparts_in > 0) { - if (MPI_Irecv(p->gparts_in, sizeof(struct gpart) * p->nr_gparts_in, MPI_BYTE, - p->nodeID, p->nodeID * proxy_tag_shift + proxy_tag_gparts, + if (MPI_Irecv(p->gparts_in, sizeof(struct gpart) * p->nr_gparts_in, + MPI_BYTE, p->nodeID, + p->nodeID * proxy_tag_shift + proxy_tag_gparts, MPI_COMM_WORLD, &p->req_gparts_in) != MPI_SUCCESS) error("Failed to irecv gpart data."); // message( "irecv gpart data (%i) from node %i." , p->nr_gparts_in , @@ -355,8 +356,8 @@ void proxy_gparts_load(struct proxy *p, struct gpart *gparts, int N) { p->size_gparts_out *= proxy_buffgrow; } while (p->nr_gparts_out + N > p->size_gparts_out); struct gpart *tp; - if ((tp = (struct gpart *)malloc(sizeof(struct gpart) *p->size_gparts_out)) == - NULL) + if ((tp = (struct gpart *)malloc(sizeof(struct gpart) * + p->size_gparts_out)) == NULL) error("Failed to re-allocate gparts_out buffers."); memcpy(tp, p->gparts_out, sizeof(struct gpart) * p->nr_gparts_out); free(p->gparts_out); @@ -423,15 +424,15 @@ void proxy_init(struct proxy *p, int mynodeID, int nodeID) { /* Allocate the gpart send and receive buffers, if needed. */ if (p->gparts_in == NULL) { p->size_gparts_in = proxy_buffinit; - if ((p->gparts_in = (struct gpart *)malloc( - sizeof(struct gpart) *p->size_gparts_in)) == NULL) + if ((p->gparts_in = (struct gpart *)malloc(sizeof(struct gpart) * + p->size_gparts_in)) == NULL) error("Failed to allocate gparts_in buffers."); } p->nr_gparts_in = 0; if (p->gparts_out == NULL) { p->size_gparts_out = proxy_buffinit; - if ((p->gparts_out = (struct gpart *)malloc( - sizeof(struct gpart) *p->size_gparts_out)) == NULL) + if ((p->gparts_out = (struct gpart *)malloc(sizeof(struct gpart) * + p->size_gparts_out)) == NULL) error("Failed to allocate gparts_out buffers."); } p->nr_gparts_out = 0; diff --git a/src/proxy.h b/src/proxy.h index 595147c0b60da5fc44359eff2d38fc4016293945..126be0b8136a0b62041a4fe47dac9f10aedcd512 100644 --- a/src/proxy.h +++ b/src/proxy.h @@ -59,7 +59,7 @@ struct proxy { int nr_parts_in, nr_parts_out; int size_gparts_in, size_gparts_out; int nr_gparts_in, nr_gparts_out; - + /* Buffer to hold the incomming/outgoing particle counts. */ int buff_out[2], buff_in[2]; diff --git a/src/space.c b/src/space.c index 8b9c32b730daae15ad90946eb8225e6d48388530..60e52969741053d8ddd8e0c4fcb9986e362e12fd 100644 --- a/src/space.c +++ b/src/space.c @@ -374,8 +374,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { until they are fully implemented. */ size_t nr_parts_exchanged = s->nr_parts - nr_parts; size_t nr_gparts_exchanged = 0; - engine_exchange_strays(s->e, nr_parts, &ind[nr_parts], - &nr_parts_exchanged, 0, NULL, &nr_gparts_exchanged); + engine_exchange_strays(s->e, nr_parts, &ind[nr_parts], &nr_parts_exchanged, 0, + NULL, &nr_gparts_exchanged); s->nr_parts = nr_parts + nr_parts_exchanged; /* Re-allocate the index array if needed.. */ diff --git a/src/space.h b/src/space.h index 1b510a81b5635e9a204a13dbd48bf4c64934d305..49e83d37c5939cf37c9bd3073d73799d75ae1f05 100644 --- a/src/space.h +++ b/src/space.h @@ -129,7 +129,8 @@ extern struct parallel_sort space_sort_struct; /* function prototypes. */ void space_parts_sort(struct space *s, int *ind, size_t N, int min, int max, int verbose); -void space_gparts_sort(struct gpart *gparts, int *ind, size_t N, int min, int max); +void space_gparts_sort(struct gpart *gparts, int *ind, size_t N, int min, + int max); struct cell *space_getcell(struct space *s); int space_getsid(struct space *s, struct cell **ci, struct cell **cj, double *shift);