| 258 | } |
| 259 | |
| 260 | void construct_mapping::construct_old_growing_faster( PartitionConfig & config, graph_access & C, matrix & D, std::vector< NodeID > & perm_rank) { |
| 261 | std::cout << "constructing initial mapping with faster growing" << std::endl; |
| 262 | |
| 263 | //initialze perm rank |
| 264 | //interpretation task 'node' is assinged to perm_rank[node] |
| 265 | for( unsigned int i = 0; i < perm_rank.size(); i++) { |
| 266 | perm_rank[i] = UNASSIGNED; |
| 267 | } |
| 268 | |
| 269 | maxNodeHeap unassigned_tasks; // contains unassigned tasks and their priority |
| 270 | NodeWeight max_vol = 0; |
| 271 | NodeWeight max_vol_elem = 0; |
| 272 | forall_nodes(C, node) { |
| 273 | NodeWeight cur_vol = 0; |
| 274 | forall_out_edges(C, e, node) { |
| 275 | cur_vol += C.getEdgeWeight(e); |
| 276 | } endfor |
| 277 | |
| 278 | unassigned_tasks.insert( node, 0); |
| 279 | |
| 280 | if( cur_vol > max_vol ) { |
| 281 | max_vol = cur_vol; |
| 282 | max_vol_elem = node; |
| 283 | } |
| 284 | } endfor |
| 285 | |
| 286 | NodeWeight min_dist = std::numeric_limits< NodeWeight >::max(); |
| 287 | NodeWeight min_dist_elem = 0; |
| 288 | for( unsigned int cpu = 0; cpu < C.number_of_nodes(); cpu++) { |
| 289 | NodeWeight cur_dist = 0; |
| 290 | for( unsigned int cpu_bar = 0; cpu_bar < C.number_of_nodes(); cpu_bar++) { |
| 291 | cur_dist += D.get_xy( cpu, cpu_bar ); |
| 292 | } |
| 293 | |
| 294 | if( cur_dist < min_dist ) { |
| 295 | min_dist = cur_dist; |
| 296 | min_dist_elem = cpu; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | std::vector< NodeWeight > core_assigned( C.number_of_nodes(), UNASSIGNED); |
| 301 | std::vector< NodeWeight > total_vol( C.number_of_nodes(), 0); // store volume to assigned nodes |
| 302 | std::vector< NodeWeight > total_dist( C.number_of_nodes(), 0); |
| 303 | |
| 304 | std::vector< NodeWeight > unassigned_PEs; |
| 305 | for( unsigned int cpu = 0; cpu < C.number_of_nodes(); cpu++) { |
| 306 | unassigned_PEs.push_back(cpu); |
| 307 | } |
| 308 | |
| 309 | perm_rank[max_vol_elem] = min_dist_elem; |
| 310 | core_assigned[min_dist_elem] = ASSIGNED; |
| 311 | |
| 312 | std::swap(unassigned_PEs[min_dist_elem], unassigned_PEs[unassigned_PEs.size()-1 ]); |
| 313 | unassigned_PEs.pop_back(); |
| 314 | unassigned_tasks.deleteNode(max_vol_elem); |
| 315 | |
| 316 | for( unsigned int i = 0; i < unassigned_PEs.size(); i++) { |
| 317 | NodeID cpu = unassigned_PEs[i]; |
nothing calls this directly
no test coverage detected