From 9592743a2c5fde48b422333bbddcf9244dd19944 Mon Sep 17 00:00:00 2001 From: Pedro Gonnet <gonnet@google.com> Date: Fri, 28 Jul 2017 18:18:10 +0200 Subject: [PATCH] wrap engine_make_hierarchical_tasks in a threadpool mapper function. --- src/engine.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/engine.c b/src/engine.c index 28904eacf7..71b3a8f26a 100644 --- a/src/engine.c +++ b/src/engine.c @@ -253,6 +253,16 @@ void engine_make_hierarchical_tasks(struct engine *e, struct cell *c) { } } +void engine_make_hierarchical_tasks_mapper(void *map_data, int num_elements, + void *extra_data) { + struct engine *e = (struct engine *)extra_data; + + for (int ind = 0; ind < num_elements; ind++) { + struct cell *c = &((struct cell *)map_data)[ind]; + engine_make_hierarchical_tasks(e, c); + } +} + #ifdef WITH_MPI /** * Do the exchange of one type of particles with all the other nodes. @@ -2515,8 +2525,8 @@ void engine_maketasks(struct engine *e) { sizeof(struct cell), 0, NULL); /* Append hierarchical tasks to each cell. */ - for (int k = 0; k < nr_cells; k++) - engine_make_hierarchical_tasks(e, &cells[k]); + threadpool_map(&e->threadpool, engine_make_hierarchical_tasks_mapper, cells, + nr_cells, sizeof(struct cell), 0, e); /* Run through the tasks and make force tasks for each density task. Each force task depends on the cell ghosts and unlocks the kick task -- GitLab