| 176 | } |
| 177 | |
| 178 | void construct_mapping::construct_old_growing( PartitionConfig & config, graph_access & C, matrix & D, std::vector< NodeID > & perm_rank) { |
| 179 | std::cout << "constructing initial mapping" << std::endl; |
| 180 | |
| 181 | std::vector< NodeWeight > total_dist( C.number_of_nodes(), 0); |
| 182 | std::vector< NodeWeight > total_vol( C.number_of_nodes(), 0); |
| 183 | std::vector< NodeWeight > core_assigned( C.number_of_nodes(), UNASSIGNED); |
| 184 | |
| 185 | NodeWeight max_vol = 0; |
| 186 | NodeWeight max_vol_elem = 0; |
| 187 | forall_nodes(C, node) { |
| 188 | forall_out_edges(C, e, node) { |
| 189 | total_vol[node] += C.getEdgeWeight(e); |
| 190 | } endfor |
| 191 | if( total_vol[node] > max_vol ) { |
| 192 | max_vol = total_vol[node]; |
| 193 | max_vol_elem = node; |
| 194 | } |
| 195 | } endfor |
| 196 | |
| 197 | NodeWeight min_dist = std::numeric_limits< NodeWeight >::max(); |
| 198 | NodeWeight min_dist_elem = 0; |
| 199 | for( unsigned int cpu = 0; cpu < C.number_of_nodes(); cpu++) { |
| 200 | total_dist[cpu] = 0; |
| 201 | for( unsigned int cpu_bar = 0; cpu_bar < C.number_of_nodes(); cpu_bar++) { |
| 202 | total_dist[cpu] += D.get_xy( cpu, cpu_bar ); |
| 203 | } |
| 204 | |
| 205 | if( total_dist[cpu] < min_dist ) { |
| 206 | min_dist = total_dist[cpu]; |
| 207 | min_dist_elem = cpu; |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | //initialze perm rank |
| 212 | //interpretation task 'node' is assinged to perm_rank[node] |
| 213 | for( unsigned int i = 0; i < perm_rank.size(); i++) { |
| 214 | perm_rank[i] = UNASSIGNED; |
| 215 | } |
| 216 | perm_rank[max_vol_elem] = min_dist_elem; |
| 217 | core_assigned[min_dist_elem] = ASSIGNED; |
| 218 | //initialization, now assign the rest of the ranks to the tasks |
| 219 | for( unsigned i = 0; i < C.number_of_nodes()-1; i++) { |
| 220 | max_vol = 0; |
| 221 | max_vol_elem = std::numeric_limits< NodeWeight >::max(); |
| 222 | forall_nodes(C, node) { |
| 223 | if(perm_rank[node] != UNASSIGNED) continue; |
| 224 | |
| 225 | total_vol[node] = 0; |
| 226 | forall_out_edges(C, e, node) { |
| 227 | NodeID target = C.getEdgeTarget(e); |
| 228 | if( perm_rank[target] != UNASSIGNED ) { |
| 229 | total_vol[node] += C.getEdgeWeight(e); |
| 230 | } |
| 231 | } endfor |
| 232 | if( total_vol[node] >= max_vol ) { |
| 233 | max_vol = total_vol[node]; |
| 234 | max_vol_elem = node; |
| 235 | } |
nothing calls this directly
no test coverage detected