[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Andriy Andreykiv |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Thu, 24 Jan 2019 11:01:02 -0500 (EST) |
branch: partitions_initiation
commit 75a1155d123a568a6016c59447cdf016e8e8059c
Author: Andriy.Andreykiv <address@hidden>
Date: Thu Jan 24 17:00:46 2019 +0100
allowing to have lower number of partitions than max_concurrency
---
src/getfem/getfem_omp.h | 1 +
src/getfem_omp.cc | 15 +++++++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/getfem/getfem_omp.h b/src/getfem/getfem_omp.h
index 4e86fdc..faffba4 100644
--- a/src/getfem/getfem_omp.h
+++ b/src/getfem/getfem_omp.h
@@ -446,6 +446,7 @@ namespace getfem
thread_behaviour behaviour = thread_behaviour::partition_threads;
std::atomic<bool> partitions_updated{false};
size_type nb_partitions;
+ bool partitions_set_by_user = false;
static partition_master instance;
};
diff --git a/src/getfem_omp.cc b/src/getfem_omp.cc
index 5f1bd89..5097a4c 100644
--- a/src/getfem_omp.cc
+++ b/src/getfem_omp.cc
@@ -183,6 +183,7 @@ namespace getfem{
update_partitions();
nb_user_threads = true_thread_policy::num_threads();
}
+ if (!partitions_set_by_user) set_nb_partitions(max_concurrency());
}
void partition_master::set_nb_partitions(size_type n){
@@ -192,11 +193,12 @@ namespace getfem{
update_partitions();
dal::singletons_manager::on_partitions_change();
}
- else{
+ else if (n < nb_partitions){
GMM_WARNING1("Not reducing number of partitions from "
<< nb_partitions <<" to " << n <<
" as it might invalidate global storage");
}
+ partitions_set_by_user = true;
}
partition_iterator partition_master::begin(){
@@ -221,7 +223,13 @@ namespace getfem{
partition_master::partition_master()
: nb_user_threads{true_thread_policy::num_threads()},
- nb_partitions{max_concurrency()} {
+ nb_partitions{1} // keeping at 1 to allow the user setting it
+ // to a number below max_concurrency.
+ // If the user doesn't set it, it will be set
+ // to max_concurrency before the fist parallel
+ // section (reducing nb_partitions is not allowed
+ // to preserve global storage)
+ {
partitions_updated = false;
update_partitions();
}
@@ -259,8 +267,7 @@ namespace getfem{
void partition_master::update_partitions(){
partitions_updated = false;
- auto guard = omp_guard{};
- GMM_NOPERATION(guard);
+ GLOBAL_OMP_GUARD
if (partitions_updated) return;