diff --git a/src/numa_helper.c b/src/numa_helper.c index 5f9fa9011f3213a554db555d975a49cf2f9fa525..6057ae3efba7805ec9820d3cac7daf79bdf1a43f 100644 --- a/src/numa_helper.c +++ b/src/numa_helper.c @@ -43,6 +43,21 @@ #include "cell.h" +/** + * @brief threadpool mapping function for hydro parts NUMA movement. + * + * + */ +void swiftnuma_cell_move_hydro_parts_threadpool_map(void *map_data, int num_elements, void *extra_data){ + + struct cell *cells = (struct cell *) map_data; + int32_t *nodes = (int32_t *)extra_data; + + for(int32_t i = 0; i < num_elements; i++){ + swiftnuma_cell_move_hydro_parts(&cells[i], nodes[i], 1); + } + +} /** * @brief Move a cell structure's hydro parts into a single NUMA region. diff --git a/src/numa_helper.h b/src/numa_helper.h index 68912b858967beaf874771e5d84bacb2e186b405..a1803ff7f8b78ab5100128034ec723608dab70b4 100644 --- a/src/numa_helper.h +++ b/src/numa_helper.h @@ -22,6 +22,7 @@ #include <stdint.h> #include "cell.h" +void swiftnuma_cell_move_hydro_parts_threadpool_map(void *map_data, int num_elements, void *extra_data); void swiftnuma_cell_move_hydro_parts(struct cell *c, int32_t node, int32_t verbose); #endif diff --git a/src/space.c b/src/space.c index 6ff567753244b46df5fb58fb12f10ac3ad880ec1..24d878b3132f6a17dc319dd906ff769f44ce5099 100644 --- a/src/space.c +++ b/src/space.c @@ -1169,10 +1169,15 @@ void space_rebuild(struct space *s, int repartitioned, int verbose) { /* Move pages for each cell's particles to be in a single NUMA region.*/ //TODO This doesn't make use of NUMA information yet so just assumes we have 2 domains... int32_t numanode = 0; + int32_t *nodes = malloc(sizeof(int32_t) * s->nr_cells); for(int32_t i = 0; i < s->nr_cells; i++){ if( i > s->nr_cells/2) numanode=1; - swiftnuma_cell_move_hydro_parts(&cells_top[i],numanode,1); + nodes[i] = numanode; +// swiftnuma_cell_move_hydro_parts(&cells_top[i],numanode,1); } + threadpool_map(s->e->tp, &swiftnuma_cell_move_hydro_parts_threadpool_map, s->c, s->nr_cells, + sizeof(struct cell), 0, nodes); + free(nodes); #endif if (verbose)