MCPcopy Create free account
hub / github.com/KaHIP/KaHIP / construct_old_growing_matrix

Method construct_old_growing_matrix

lib/mapping/construct_mapping.cpp:56–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void construct_mapping::construct_old_growing_matrix( PartitionConfig & config, matrix & C, matrix & D, std::vector< NodeID > & perm_rank) {
57 std::cout << "constructing initial mapping matrix version of growing" << std::endl;
58
59 //initialze perm rank
60 //interpretation task 'node' is assinged to perm_rank[node]
61 for( unsigned int i = 0; i < perm_rank.size(); i++) {
62 perm_rank[i] = UNASSIGNED;
63 }
64
65 NodeWeight max_vol = 0;
66 NodeWeight max_vol_elem = 0;
67 for( unsigned int i = 0; i < C.get_x_dim(); i++) {
68 NodeWeight cur_vol = 0;
69 for( unsigned int j = 0; j < C.get_x_dim(); j++) {
70 cur_vol += C.get_xy(i,j);
71 }
72
73 if( cur_vol > max_vol ) {
74 max_vol = cur_vol;
75 max_vol_elem = i;
76 }
77 }
78
79 NodeWeight min_dist = std::numeric_limits< NodeWeight >::max();
80 NodeWeight min_dist_elem = 0;
81 for( unsigned int cpu = 0; cpu < D.get_x_dim(); cpu++) {
82 NodeWeight cur_dist = 0;
83 for( unsigned int cpu_bar = 0; cpu_bar < D.get_y_dim(); cpu_bar++) {
84 cur_dist += D.get_xy( cpu, cpu_bar );
85 }
86
87 if( cur_dist < min_dist ) {
88 min_dist = cur_dist;
89 min_dist_elem = cpu;
90 }
91 }
92
93 std::vector< NodeWeight > core_assigned( C.get_x_dim(), UNASSIGNED);
94 std::vector< NodeWeight > total_vol( C.get_x_dim(), 0); // store volume to assigned nodes
95 std::vector< NodeWeight > total_dist( C.get_x_dim(), 0);
96
97 std::vector< NodeWeight > unassigned_PEs;
98 std::vector< NodeWeight > unassigned_tasks;
99 for( unsigned int i = 0; i < C.get_x_dim(); i++) {
100 unassigned_PEs.push_back(i);
101 unassigned_tasks.push_back(i);
102 }
103
104 perm_rank[max_vol_elem] = min_dist_elem;
105 core_assigned[min_dist_elem] = ASSIGNED;
106
107 std::swap(unassigned_PEs[min_dist_elem], unassigned_PEs[unassigned_PEs.size()-1 ]);
108 unassigned_PEs.pop_back();
109
110 std::swap(unassigned_tasks[max_vol_elem], unassigned_tasks[unassigned_tasks.size()-1 ]);
111 unassigned_tasks.pop_back();
112
113 for( unsigned int i = 0; i < unassigned_PEs.size(); i++) {

Callers

nothing calls this directly

Calls 5

sizeMethod · 0.45
get_x_dimMethod · 0.45
get_xyMethod · 0.45
get_y_dimMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected