summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2018-12-28 12:51:14 +0100
committerAnton Khirnov <anton@khirnov.net>2018-12-28 12:51:14 +0100
commit133c5ff7ebce3bb4301a841bf9de9ba85fca23a2 (patch)
tree4afeee73a7d574fc44024e9044f552f38996e60f
parentb47af8f35656a42f1e94510159c64629b9a75d30 (diff)
Set the number of solver threads from OMP_NUM_THREADS.
-rw-r--r--src/maximal_slicing_axi_mg.c5
1 files changed, 5 insertions, 0 deletions
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 */