Skip to content
Snippets Groups Projects
Commit 32f2fcc1 authored by Russel Arbore's avatar Russel Arbore
Browse files

Code to convert representatives into partitions

parent c7bf3621
No related branches found
No related tags found
1 merge request!13Basic IR schedules framework
This commit is part of merge request !13. Comments created here will be created in the context of that merge request.
...@@ -171,7 +171,7 @@ pub fn partition_out_forks( ...@@ -171,7 +171,7 @@ pub fn partition_out_forks(
// its user as a representative node ID for a partition. A region node taking // its user as a representative node ID for a partition. A region node taking
// multiple node IDs as input belongs to the partition with the smaller // multiple node IDs as input belongs to the partition with the smaller
// representative node ID. // representative node ID.
let representatives = forward_dataflow( let control_representatives = forward_dataflow(
function, function,
reverse_postorder, reverse_postorder,
|inputs: &[&NodeID], node_id: NodeID| match function.nodes[node_id.idx()] { |inputs: &[&NodeID], node_id: NodeID| match function.nodes[node_id.idx()] {
...@@ -212,5 +212,20 @@ pub fn partition_out_forks( ...@@ -212,5 +212,20 @@ pub fn partition_out_forks(
}, },
); );
println!("{:?}", representatives); // Step 2:
// Step 3: deduplicate representative node IDs.
let mut representative_to_partition_ids = HashMap::new();
for rep in &representatives {
if !representative_to_partition_ids.contains_key(rep) {
representative_to_partition_ids
.insert(rep, PartitionID::new(representative_to_partition_ids.len()));
}
}
// Step 4: update plan.
plan.num_partitions = representative_to_partition_ids.len();
for id in (0..function.nodes.len()).map(NodeID::new) {
plan.partitions[id.idx()] = representative_to_partition_ids[&representatives[id.idx()]];
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment