Build the partition hypergraph from a profile. A net is created for every block that has at least one *external* consumer (i.e. is delta-unfolded by some other block); singleton nets are omitted as they can never be cut.
(profile: &BlockProfile)
| 167 | /// block that has at least one *external* consumer (i.e. is delta-unfolded by |
| 168 | /// some other block); singleton nets are omitted as they can never be cut. |
| 169 | pub fn from_profile(profile: &BlockProfile) -> Hypergraph { |
| 170 | let n = profile.num_blocks(); |
| 171 | let vweight: Vec<u64> = |
| 172 | (0..n as u32).map(|i| block_step_cost(profile.block(i))).collect(); |
| 173 | let (row, col) = profile.consumers_csr(); |
| 174 | let mut net_weight = Vec::new(); |
| 175 | let mut net_pins = Vec::new(); |
| 176 | for p in 0..n { |
| 177 | let consumers = &col[row[p]..row[p + 1]]; |
| 178 | if consumers.is_empty() { |
| 179 | continue; |
| 180 | } |
| 181 | let mut pins = Vec::with_capacity(consumers.len() + 1); |
| 182 | pins.push(p as u32); // home pin |
| 183 | pins.extend_from_slice(consumers); |
| 184 | net_weight.push(u64::from(profile.block(p as u32).serialized_size)); |
| 185 | net_pins.push(pins); |
| 186 | } |
| 187 | Hypergraph { vweight, net_weight, net_pins } |
| 188 | } |
| 189 | |
| 190 | pub fn num_vertices(&self) -> usize { |
| 191 | self.vweight.len() |
nothing calls this directly
no test coverage detected