ug4
process_hierarchy.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017: G-CSC, Goethe University Frankfurt
3  * Author: Sebastian Reiter
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 // NOTE: Classes in this file were originally defined in 'load_balancer.h'
34 #ifndef __H__UG_process_hierarchy
35 #define __H__UG_process_hierarchy
36 
37 #include <vector>
38 #include "common/util/variant.h"
39 
40 #ifdef UG_PARALLEL
42 #endif
43 
44 namespace ug{
45 
46 class ProcessHierarchy;
49 
52 
54 
56  public:
59 
60  //todo: add a proc list for more sophisticated hierarchy levels
61  void add_hierarchy_level(size_t gridLvl, size_t numProcsPerProc);
62 
63  bool empty() const;
64  size_t num_hierarchy_levels() const;
65  size_t num_global_procs_involved(size_t hierarchyLevel) const;
66  size_t grid_base_level(size_t hierarchyLevel) const;
67  size_t hierarchy_level_from_grid_level(size_t gridLevel) const;
68 
72  pcl::ProcessCommunicator global_proc_com(size_t hierarchyLevel) const;
73 
76  //pcl::ProcessCommunicator cluster_proc_com(size_t hierarchyLevel);
77  const std::vector<int>& cluster_procs(size_t hierarchyLevel) const;
78 
80  std::string to_string() const;
81 
83 
89  void add_partition_hint(int hlvl, const std::string& name, const Variant& value);
90 
92 
94  bool partition_hint(Variant& valOut, int hlvl, const std::string& name) const;
95 
96  protected:
97  typedef std::map<std::string, Variant> PartitionHintMap;
98 
99  struct HLevelInfo{
101  //pcl::ProcessCommunicator clusterCom;
102  std::vector<int> clusterProcs;
103  size_t gridLvl;
106  };
107 
108  HLevelInfo& get_hlevel_info(size_t lvl) {return m_levels.at(lvl);}
109  const HLevelInfo& get_hlevel_info(size_t lvl) const {return m_levels.at(lvl);}
110 
111 // virtual pcl::ProcessCommunicator
112 // create_cluster_communicator(size_t hlvl, size_t gridLvl, size_t numProcsPerProc);
113  void init_cluster_procs(std::vector<int>& clusterProcs, size_t hlvl,
114  size_t numProcsPerProc);
115 
116  private:
117  std::vector<HLevelInfo> m_levels;
118 };
119 
121 
122 }// end of namespace
123 
124 #endif //__H__UG_process_hierarchy
location name
Definition: checkpoint_util.lua:128
Definition: smart_pointer.h:296
Definition: pcl_process_communicator.h:70
Defines how the different levels of a grid shall be distributed across the available processes.
Definition: process_hierarchy.h:55
std::vector< HLevelInfo > m_levels
Definition: process_hierarchy.h:117
std::string to_string() const
Returns a string which describes the hierarchy layout.
Definition: load_balancer.cpp:205
size_t hierarchy_level_from_grid_level(size_t gridLevel) const
Definition: load_balancer.cpp:176
bool partition_hint(Variant &valOut, int hlvl, const std::string &name) const
returns true if the queried partition hint exists and writes it value to 'valOut'
Definition: load_balancer.cpp:227
void init_cluster_procs(std::vector< int > &clusterProcs, size_t hlvl, size_t numProcsPerProc)
Definition: load_balancer.cpp:115
std::map< std::string, Variant > PartitionHintMap
Definition: process_hierarchy.h:97
void add_hierarchy_level(size_t gridLvl, size_t numProcsPerProc)
Definition: load_balancer.cpp:54
size_t num_global_procs_involved(size_t hierarchyLevel) const
Definition: load_balancer.cpp:164
pcl::ProcessCommunicator global_proc_com(size_t hierarchyLevel) const
Definition: load_balancer.cpp:193
void add_partition_hint(int hlvl, const std::string &name, const Variant &value)
allows specification of partitioning hints per hierarchy level.
Definition: load_balancer.cpp:219
const std::vector< int > & cluster_procs(size_t hierarchyLevel) const
Definition: load_balancer.cpp:199
size_t grid_base_level(size_t hierarchyLevel) const
Definition: load_balancer.cpp:170
static SPProcessHierarchy create()
Definition: process_hierarchy.h:57
size_t num_hierarchy_levels() const
Definition: load_balancer.cpp:158
bool empty() const
Definition: load_balancer.cpp:152
const HLevelInfo & get_hlevel_info(size_t lvl) const
Definition: process_hierarchy.h:109
HLevelInfo & get_hlevel_info(size_t lvl)
Definition: process_hierarchy.h:108
~ProcessHierarchy()
Definition: load_balancer.cpp:49
A variant can represent variables of different types.
Definition: variant.h:87
the ug namespace
SmartPtr< ProcessHierarchy > SPProcessHierarchy
Definition: process_hierarchy.h:46
ConstSmartPtr< ProcessHierarchy > ConstSPProcessHierarchy
Definition: process_hierarchy.h:48
Definition: process_hierarchy.h:99
size_t numGlobalProcsInUse
Definition: process_hierarchy.h:104
PartitionHintMap m_partitionHints
Definition: process_hierarchy.h:105
size_t gridLvl
Definition: process_hierarchy.h:103
pcl::ProcessCommunicator globalCom
Definition: process_hierarchy.h:100
std::vector< int > clusterProcs
Definition: process_hierarchy.h:102