aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/dist.cc
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2008-01-14 15:04:00 +0000
committerErik Schnetter <schnetter@cct.lsu.edu>2008-01-14 15:04:00 +0000
commit39a9cb3421a4389682f976e96f56ce5c12b19367 (patch)
tree52ec752204f883413ce386b544e67708e023e4d7 /Carpet/CarpetLib/src/dist.cc
parentf807babfa91385dd4b949704c8761b0b71940eb3 (diff)
CarpetLib: Set number of OpenMP threads via an external function call
Set the number of OpenMP threads via an external function call instead of via a CarpetLib parameter. darcs-hash:20080114150439-dae7b-a6a6a629162ca195411852823e1ece0a2071d771.gz
Diffstat (limited to 'Carpet/CarpetLib/src/dist.cc')
-rw-r--r--Carpet/CarpetLib/src/dist.cc18
1 files changed, 3 insertions, 15 deletions
diff --git a/Carpet/CarpetLib/src/dist.cc b/Carpet/CarpetLib/src/dist.cc
index 1af4bcf38..7ac6f73f6 100644
--- a/Carpet/CarpetLib/src/dist.cc
+++ b/Carpet/CarpetLib/src/dist.cc
@@ -1,9 +1,9 @@
#include <cassert>
+#include <mpi.h>
#ifdef _OPENMP
# include <omp.h>
#endif
-#include <mpi.h>
#include "cctk.h"
#include "cctk_Parameters.h"
@@ -66,33 +66,21 @@ namespace dist {
}
}
- // Local number of threads
- int num_threads_worker ()
+ // Set number of threads
+ void set_num_threads (int const num_threads)
{
- DECLARE_CCTK_PARAMETERS;
- int num_threads_;
#ifdef _OPENMP
if (num_threads > 0) {
// Set number of threads which should be used
// TODO: do this at startup, not in this routine
omp_set_num_threads (num_threads);
}
-#pragma omp parallel
- {
-#pragma omp single nowait
- {
- num_threads_ = omp_get_num_threads();
- }
- }
#else
if (num_threads > 0 and num_threads != 1) {
CCTK_WARN (CCTK_WARN_ABORT,
"OpenMP is not enabled. Cannot set the number of threads.");
}
- num_threads_ = 1;
#endif
- assert (num_threads_ >= 1);
- return num_threads_;
}
// Global number of threads