Serialize to the `.ixprof` binary format.
(&self)
| 213 | &self.delta_col[lo..hi] |
| 214 | } |
| 215 | |
| 216 | /// Build the reverse delta adjacency: for each producer block, the sorted set |
| 217 | /// of consumer blocks that unfold it. This is the natural form for the |
| 218 | /// partition hypergraph, where `net(p) = {p} ∪ consumers_of(p)`. |
| 219 | pub fn consumers_csr(&self) -> (Vec<usize>, Vec<u32>) { |
| 220 | let n = self.num_blocks(); |
| 221 | let mut counts = vec![0usize; n + 1]; |
| 222 | for &p in &self.delta_col { |
| 223 | counts[p as usize + 1] += 1; |
| 224 | } |
| 225 | for i in 0..n { |
| 226 | counts[i + 1] += counts[i]; |
| 227 | } |
| 228 | let row = counts.clone(); |
| 229 | let mut col = vec![0u32; self.delta_col.len()]; |
| 230 | let mut cursor = counts; |
| 231 | for c in 0..n as u32 { |
| 232 | for &p in self.producers(c) { |
| 233 | let slot = cursor[p as usize]; |
| 234 | col[slot] = c; |
| 235 | cursor[p as usize] += 1; |
| 236 | } |
| 237 | } |
| 238 | (row, col) |
| 239 | } |
| 240 | |
| 241 | /// Total heartbeats across all blocks. |
| 242 | pub fn total_heartbeats(&self) -> u128 { |