[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: |
Mon, 11 Feb 2019 05:01:57 -0500 (EST) |
branch: partitions_initiation
commit 467ae55d2e5ea1ae9a837ab0c6355964a1716073
Author: Andriy.Andreykiv <address@hidden>
Date: Mon Feb 11 11:01:41 2019 +0100
1) partitioning can be changed only once; 2) flag in the region should be
atomic; 3) starting from one thread, if more desired, this should be specified
---
src/getfem_mesh_region.cc | 6 +++---
src/getfem_omp.cc | 13 ++++++++++++-
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/getfem_mesh_region.cc b/src/getfem_mesh_region.cc
index 7a5e6fa..4986739 100644
--- a/src/getfem_mesh_region.cc
+++ b/src/getfem_mesh_region.cc
@@ -91,7 +91,7 @@ namespace getfem {
if (!parent_mesh && !from.parent_mesh){
id_ = from.id_;
type_ = from.type_;
- partitioning_allowed = from.partitioning_allowed;
+ partitioning_allowed.store(from.partitioning_allowed.load());
if (from.p) {
if (!p) p = std::make_shared<impl>();
wp() = from.rp();
@@ -103,13 +103,13 @@ namespace getfem {
id_ = from.id_;
type_ = from.type_;
parent_mesh = from.parent_mesh;
- partitioning_allowed = from.partitioning_allowed;
+ partitioning_allowed.store(from.partitioning_allowed.load());
}
else {
if (from.p){
wp() = from.rp();
type_= from.get_type();
- partitioning_allowed = from.partitioning_allowed;
+ partitioning_allowed.store(from.partitioning_allowed.load());
}
else if (from.id_ == size_type(-1)) {
clear();
diff --git a/src/getfem_omp.cc b/src/getfem_omp.cc
index 888e22a..2f13e60 100644
--- a/src/getfem_omp.cc
+++ b/src/getfem_omp.cc
@@ -196,6 +196,8 @@ namespace getfem{
}
void partition_master::set_nb_partitions(size_type n){
+ GMM_ASSERT1 (!partitions_set_by_user,
+ "Number of partitions can be set only once");
if (n > nb_partitions){
nb_partitions = n;
nb_user_threads = true_thread_policy::num_threads();
@@ -239,6 +241,11 @@ namespace getfem{
}
size_type partition_master::get_current_partition() const {
+ GMM_ASSERT2(behaviour == thread_behaviour::partition_threads ?
+ true_thread_policy::this_thread() < nb_partitions : true,
+ "Requesting current partition for thread " <<
+ true_thread_policy::this_thread() <<
+ " while number of partitions is " << nb_partitions);
return behaviour == thread_behaviour::partition_threads ?
current_partition : true_thread_policy::this_thread();
}
@@ -336,6 +343,10 @@ namespace getfem{
void parallel_execution(std::function<void(void)> lambda,
bool iterate_over_partitions){
parallel_boilerplate boilerplate;
+ auto &pm = partition_master::get();
+ if (pm.get_nb_partitions() < true_thread_policy::num_threads()){
+ pm.set_nb_partitions(true_thread_policy::num_threads());
+ }
#pragma omp parallel default(shared)
{
if (iterate_over_partitions) {
@@ -351,4 +362,4 @@ namespace getfem{
if (iterate_over_partitions) partition_master::get().rewind_partitions();
}
-} /* end of namespace getfem. */
+} /* end of namespace getfem. */
\ No newline at end of file