From 133c5ff7ebce3bb4301a841bf9de9ba85fca23a2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 28 Dec 2018 12:51:14 +0100 Subject: Set the number of solver threads from OMP_NUM_THREADS. --- src/maximal_slicing_axi_mg.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/maximal_slicing_axi_mg.c b/src/maximal_slicing_axi_mg.c index a94452e..0fe9a54 100644 --- a/src/maximal_slicing_axi_mg.c +++ b/src/maximal_slicing_axi_mg.c @@ -158,6 +158,7 @@ static void log_callback(const MG2DContext *ctx, int level, static CoordPatch *get_coord_patch(MSMGContext *ms, int level) { + const char *omp_threads = getenv("OMP_NUM_THREADS"); cGH *gh = ms->gh; const size_t grid_size = gh->cctk_lsh[2] * gh->cctk_lsh[1] * gh->cctk_lsh[0]; @@ -242,6 +243,10 @@ static CoordPatch *get_coord_patch(MSMGContext *ms, int level) cp->solver->opaque = ms; cp->solver->log_callback = log_callback; + if (omp_threads) + cp->solver->nb_threads = strtol(omp_threads, NULL, 0); + if (cp->solver->nb_threads <= 0) + cp->solver->nb_threads = 1; /* initialize boundary values to zero, * non-zero values on the outer boundaries of refined levels are filled in elsewhere */ -- cgit v1.2.3