getfem-commits
[Top][All Lists]
Advanced

[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, 31 Jan 2019 05:47:30 -0500 (EST)

branch: partitions_initiation
commit 8bd82f1df8c0d6dcb325b5d522733e7e7bee3c36
Author: Andriy.Andreykiv <address@hidden>
Date:   Thu Jan 31 11:47:17 2019 +0100

    thread based partitioning:
     - flag in mesh region needs to atomic, not distributed,
       not to depend on the thread policy used
     - initializing threads to 1, to be able to expand it to the desired number
       (setting them to any large number prevents later setting to 1, as 
shrinking
        partitions is not possible)
---
 src/getfem/getfem_mesh_region.h | 11 +++++++----
 src/getfem_mesh_region.cc       |  8 ++++----
 src/getfem_omp.cc               |  1 +
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/getfem/getfem_mesh_region.h b/src/getfem/getfem_mesh_region.h
index a3f414c..0b942ea 100644
--- a/src/getfem/getfem_mesh_region.h
+++ b/src/getfem/getfem_mesh_region.h
@@ -37,6 +37,7 @@
 
 #pragma once
 
+#include <atomic>
 #include <bitset>
 #include <iostream>
 #include <map>
@@ -72,10 +73,12 @@ namespace getfem {
                                  constructor is used */
 
     size_type type_; //optional type of the region
-    omp_distribute<bool> partitioning_allowed; /** specifies that in
-                          multithreaded code only a partition of the
-                          region is visible in index() and size() methods,
-                          as well as during iteration with mr_visitor */
+
+    std::atomic_bool partitioning_allowed; /* specifies that in multithreaded 
code only a
+                                           partition of the region is visible 
in index()
+                                           and size() methods, as well as 
during iteration
+                                           with mr_visitor */
+
     mesh *parent_mesh; /* used for mesh_region "extracted" from
                           a mesh (to provide feedback) */
 
diff --git a/src/getfem_mesh_region.cc b/src/getfem_mesh_region.cc
index 5cb2b59..7a5e6fa 100644
--- a/src/getfem_mesh_region.cc
+++ b/src/getfem_mesh_region.cc
@@ -34,26 +34,26 @@ namespace getfem {
 
   mesh_region::mesh_region()
     : p(std::make_shared<impl>()), id_(size_type(-2)), type_(size_type(-1)),
-    partitioning_allowed(true), parent_mesh(nullptr){
+    partitioning_allowed{true}, parent_mesh(nullptr){
     if (me_is_multithreaded_now()) prohibit_partitioning();
     mark_region_changed();
   }
 
   mesh_region::mesh_region(size_type id__) : id_(id__), type_(size_type(-1)),
-    partitioning_allowed(true), parent_mesh(nullptr){
+    partitioning_allowed{true}, parent_mesh(nullptr){
     mark_region_changed();
   }
 
   mesh_region::mesh_region(mesh& m, size_type id__, size_type type) :
     p(std::make_shared<impl>()), id_(id__), type_(type),
-    partitioning_allowed(true), parent_mesh(&m){
+    partitioning_allowed{true}, parent_mesh(&m){
     if (me_is_multithreaded_now()) prohibit_partitioning();
     mark_region_changed();
   }
 
   mesh_region::mesh_region(const dal::bit_vector &bv)
     : p(std::make_shared<impl>()), id_(size_type(-2)), type_(size_type(-1)),
-    partitioning_allowed(true), parent_mesh(nullptr){
+    partitioning_allowed{true}, parent_mesh(nullptr){
     if (me_is_multithreaded_now()) prohibit_partitioning();
     add(bv);
     mark_region_changed();
diff --git a/src/getfem_omp.cc b/src/getfem_omp.cc
index 438bc5e..888e22a 100644
--- a/src/getfem_omp.cc
+++ b/src/getfem_omp.cc
@@ -234,6 +234,7 @@ namespace getfem{
   partition_master::partition_master()
     : nb_user_threads{1}, nb_partitions{1} {
         partitions_updated = false;
+        set_num_threads(1);
         update_partitions();
   }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]