| 1 | #ifndef SUBDOMAIN_NODES_HPP |
| 2 | #define SUBDOMAIN_NODES_HPP |
| 3 | |
| 4 | #include <boost/fusion/container/vector.hpp> |
| 5 | #include <boost/fusion/include/at_c.hpp> |
| 6 | #include "memory_ly/Encap.hpp" |
| 7 | |
| 8 | /* In a decomposition graph each node represent a sub-domain while an edge represent |
| 9 | * an interaction between sub-domain (it mean that they have to communicate). |
| 10 | * |
| 11 | * Here we list the of property that a vertex node can carry with a brief |
| 12 | * explanation: |
| 13 | * |
| 14 | * x = position x of the sub-domain |
| 15 | * y = position y of the sub-domain |
| 16 | * z = position z of the sub-domain |
| 17 | * communication = is the estimated total communication produced by the sub-domain |
| 18 | * computation = the total computation produced by the sub-domain |
| 19 | * memory = estimated memory required by the sub-domain |
| 20 | * id = which processor own this sub-domain |
| 21 | * sub-id = sub-decomposition where each group of sub-domain is organized in an |
| 22 | * hyper-cube |
| 23 | * |
| 24 | * Here we list the properties that an edge node can carry with a brief explanation |
| 25 | * |
| 26 | * communication = is the estimated communication between sub-domains |
| 27 | * |
| 28 | */ |
| 29 | |
| 30 | constexpr unsigned int nm_v_x = 0; |
| 31 | constexpr unsigned int nm_v_migration = 1; |
| 32 | constexpr unsigned int nm_v_computation = 2; |
| 33 | constexpr unsigned int nm_v_global_id = 3; |
| 34 | constexpr unsigned int nm_v_id = 4; |
| 35 | constexpr unsigned int nm_v_sub_id = 5; |
| 36 | constexpr unsigned int nm_v_proc_id = 6; |
| 37 | |
| 38 | template<unsigned int dim> |
| 39 | struct nm_v |
| 40 | { |
| 41 | //! The node contain 3 unsigned long integer for communication computation memory and id |
| 42 | typedef boost::fusion::vector<float[3], size_t, size_t, size_t, size_t, long int, size_t> type; |
| 43 | |
| 44 | //! type of the positional field |
| 45 | typedef float s_type; |
| 46 | |
| 47 | //! Attributes name |
| 48 | struct attributes |
| 49 | { |
| 50 | static const std::string name[]; |
| 51 | }; |
| 52 | |
| 53 | //! The data |
| 54 | type data; |
| 55 | |
| 56 | //! pos property id in boost::fusion::vector |
| 57 | static const unsigned int x = 0; |
| 58 | //! migration property id in boost::fusion::vector |
| 59 | static const unsigned int migration = 1; |
| 60 | //! computation property id in boost::fusion::vector |
| 61 | static const unsigned int computation = 2; |
| 62 | //! global_id property id in boost::fusion::vector |
| 63 | static const unsigned int global_id = 3; |
| 64 | //! id property id in boost::fusion::vector |
| 65 | static const unsigned int id = 4; |
| 66 | //! sub_id property id in boost::fusion::vector |
| 67 | static const unsigned int sub_id = 5; |
| 68 | //! proc_id property id in boost::fusion::vector |
| 69 | static const unsigned int proc_id = 6; |
| 70 | |
| 71 | //! total number of properties boost::fusion::vector |
| 72 | static const unsigned int max_prop = 7; |
| 73 | |
| 74 | //! default constructor |
| 75 | nm_v() |
| 76 | { |
| 77 | |
| 78 | } |
| 79 | |
| 80 | inline nm_v(const nm_v & p) |
| 81 | { |
| 82 | for (size_t i = 0 ; i < dim ; i++) |
| 83 | {boost::fusion::at_c<0>(data)[i] = boost::fusion::at_c<0>(p.data)[i];} |
| 84 | boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data); |
| 85 | boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data); |
| 86 | boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data); |
| 87 | boost::fusion::at_c<4>(data) = boost::fusion::at_c<4>(p.data); |
| 88 | boost::fusion::at_c<5>(data) = boost::fusion::at_c<5>(p.data); |
| 89 | boost::fusion::at_c<6>(data) = boost::fusion::at_c<6>(p.data); |
| 90 | } |
| 91 | |
| 92 | template<unsigned int dime, typename Mem> inline nm_v(const encapc<dime, nm_v, Mem> & p) |
| 93 | { |
| 94 | this->operator=(p); |
| 95 | } |
| 96 | |
| 97 | template<unsigned int dime, typename Mem> inline nm_v & operator=(const encapc<dime, nm_v, Mem> & p) |
| 98 | { |
| 99 | for (size_t i = 0 ; i < dim ; i++) |
| 100 | {boost::fusion::at_c<0>(data)[i] = boost::fusion::at_c<0>(p.data)[i];} |
| 101 | boost::fusion::at_c<1>(data) = p.template get<1>(); |
| 102 | boost::fusion::at_c<2>(data) = p.template get<2>(); |
| 103 | boost::fusion::at_c<3>(data) = p.template get<3>(); |
| 104 | boost::fusion::at_c<4>(data) = p.template get<4>(); |
| 105 | boost::fusion::at_c<5>(data) = p.template get<5>(); |
| 106 | boost::fusion::at_c<6>(data) = p.template get<6>(); |
| 107 | |
| 108 | return *this; |
| 109 | } |
| 110 | |
| 111 | template<unsigned int id> inline auto get() -> decltype(boost::fusion::at_c < id > (data)) |
| 112 | { |
| 113 | return boost::fusion::at_c<id>(data); |
| 114 | } |
| 115 | |
| 116 | template<unsigned int id> inline auto get() const -> const decltype(boost::fusion::at_c < id > (data)) |
| 117 | { |
| 118 | return boost::fusion::at_c<id>(data); |
| 119 | } |
| 120 | |
| 121 | static bool noPointers() |
| 122 | { |
| 123 | return true; |
| 124 | } |
| 125 | |
| 126 | }; |
| 127 | |
| 128 | /*! \brief sub-domain edge graph node |
| 129 | * |
| 130 | */ |
| 131 | |
| 132 | struct nm_e |
| 133 | { |
| 134 | //! The node contain 3 unsigned long integer for comunication computation and memory |
| 135 | typedef boost::fusion::vector<size_t, size_t, size_t> type; |
| 136 | |
| 137 | //! Attributes name |
| 138 | struct attributes |
| 139 | { |
| 140 | static const std::string name[]; |
| 141 | }; |
| 142 | |
| 143 | //! The data |
| 144 | type data; |
| 145 | |
| 146 | //! computation property id in boost::fusion::vector |
| 147 | static const unsigned int communication = 0; |
| 148 | static const unsigned int srcgid = 1; |
| 149 | static const unsigned int dstgid = 2; |
| 150 | //! total number of properties boost::fusion::vector |
| 151 | static const unsigned int max_prop = 3; |
| 152 | |
| 153 | nm_e() |
| 154 | { |
| 155 | |
| 156 | } |
| 157 | |
| 158 | template<unsigned int dim, typename Mem> inline nm_e(const encapc<dim, nm_e, Mem> & p) |
| 159 | { |
| 160 | boost::fusion::at_c<0>(data) = p.template get<0>(); |
| 161 | boost::fusion::at_c<1>(data) = p.template get<1>(); |
| 162 | boost::fusion::at_c<2>(data) = p.template get<2>(); |
| 163 | |
| 164 | } |
| 165 | |
| 166 | template<unsigned int id> inline auto get() -> decltype(boost::fusion::at_c < id > (data)) |
| 167 | { |
| 168 | return boost::fusion::at_c<id>(data); |
| 169 | } |
| 170 | |
| 171 | static bool noPointers() |
| 172 | { |
| 173 | return true; |
| 174 | } |
| 175 | }; |
| 176 | |
| 177 | /*! \brief Reduced sub-domain vertex graph node |
| 178 | * |
| 179 | * It contain only the processor id for each node |
| 180 | * |
| 181 | */ |
| 182 | |
| 183 | struct nm_part_v |
| 184 | { |
| 185 | //! The node contain 3 unsigned long integer for comunication computation and memory |
| 186 | typedef boost::fusion::vector<size_t, size_t> type; |
| 187 | |
| 188 | typedef float s_type; |
| 189 | |
| 190 | //! Attributes name |
| 191 | struct attributes |
| 192 | { |
| 193 | static const std::string name[]; |
| 194 | }; |
| 195 | |
| 196 | //! The data |
| 197 | |
| 198 | type data; |
| 199 | |
| 200 | //! partition id in the boost::fusion::vector |
| 201 | static const unsigned int id = 0; |
| 202 | //! partition id in the boost::fusion::vector |
| 203 | static const unsigned int sub_id = 1; |
| 204 | |
| 205 | //! total number of properties |
| 206 | static const unsigned int max_prop = 2; |
| 207 | |
| 208 | //! default constructor |
| 209 | nm_part_v() |
| 210 | { |
| 211 | |
| 212 | } |
| 213 | |
| 214 | template<unsigned int dim, typename Mem> inline nm_part_v(const encapc<dim, nm_part_v, Mem> & p) |
| 215 | { |
| 216 | boost::fusion::at_c<0>(data) = p.template get<0>(); |
| 217 | boost::fusion::at_c<1>(data) = p.template get<1>(); |
| 218 | } |
| 219 | |
| 220 | static inline bool noPointers() |
| 221 | { |
| 222 | return true; |
| 223 | } |
| 224 | |
| 225 | }; |
| 226 | |
| 227 | /*! \brief Reduced edge graph node |
| 228 | * |
| 229 | * It contain only the communication between nodes |
| 230 | * |
| 231 | */ |
| 232 | |
| 233 | struct nm_part_e |
| 234 | { |
| 235 | //! The node contain 3 unsigned long integer for comunication computation and memory |
| 236 | typedef boost::fusion::vector<> type; |
| 237 | |
| 238 | //! The data |
| 239 | |
| 240 | type data; |
| 241 | |
| 242 | //! total number of properties |
| 243 | static const unsigned int max_prop = 0; |
| 244 | |
| 245 | //! Attributes name |
| 246 | struct attributes |
| 247 | { |
| 248 | static const std::string name[]; |
| 249 | }; |
| 250 | |
| 251 | static inline bool noPointers() |
| 252 | { |
| 253 | return true; |
| 254 | } |
| 255 | }; |
| 256 | |
| 257 | |
| 258 | |
| 259 | #endif |
| 260 | |