From 08acfbbe47dd4d124b9fb2ba490b84e51bb0d167 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 7 Apr 2018 10:18:35 +0200 Subject: Set the number of threads as requested, drop explicit openmp usage. --- src/brill.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/brill.c b/src/brill.c index 2bf40a1..bc56734 100644 --- a/src/brill.c +++ b/src/brill.c @@ -9,8 +9,6 @@ #include -#include - #include "cctk.h" #include "cctk_Arguments.h" #include "cctk_Parameters.h" @@ -40,6 +38,7 @@ void brill_data(CCTK_ARGUMENTS) /* on the first run, solve the equation for ψ */ if (!prev_bd) { + const char *omp_threads = getenv("OMP_NUM_THREADS"); bd = bd_context_alloc(); if (!bd) @@ -53,6 +52,11 @@ void brill_data(CCTK_ARGUMENTS) bd->basis_scale_factor[0] = scale_factor; bd->basis_scale_factor[1] = scale_factor; + if (omp_threads) + bd->nb_threads = strtol(omp_threads, NULL, 0); + if (bd->nb_threads <= 0) + bd->nb_threads = 1; + ret = bd_solve(bd); if (ret < 0) CCTK_WARN(0, "Error solving the Brill wave initial data equation\n"); @@ -87,7 +91,6 @@ void brill_data(CCTK_ARGUMENTS) psi_val = malloc(sizeof(*psi_val) * grid_size); q_val = malloc(sizeof(*q_val) * grid_size); -#pragma omp parallel for for (int j = 0; j < cctkGH->cctk_lsh[1]; j++) { double *r_y = r_val + j * cctkGH->cctk_lsh[0]; double *psi_y = psi_val + j * cctkGH->cctk_lsh[0] * cctkGH->cctk_lsh[2]; -- cgit v1.2.3