MCPcopy Create free account
hub / github.com/argumentcomputer/ix / from_profile

Method from_profile

crates/kernel/src/shard.rs:169–188  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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()

Callers

nothing calls this directly

Calls 7

block_step_costFunction · 0.85
num_blocksMethod · 0.80
blockMethod · 0.80
consumers_csrMethod · 0.80
pushMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected