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

Partition data nodes based on GCM, execute in hercules_dot

parent 32f2fcc1
No related branches found
No related tags found
1 merge request!13Basic IR schedules framework
......@@ -177,6 +177,7 @@ name = "hercules_dot"
version = "0.1.0"
dependencies = [
"clap",
"hercules_cg",
"hercules_ir",
"hercules_opt",
"rand",
......
......@@ -36,6 +36,7 @@ pub fn default_plan(
function: &Function,
reverse_postorder: &Vec<NodeID>,
fork_join_map: &HashMap<NodeID, NodeID>,
bbs: &Vec<NodeID>,
) -> Plan {
// Start by creating a completely bare-bones plan doing nothing interesting.
let mut plan = Plan {
......@@ -48,7 +49,7 @@ pub fn default_plan(
infer_parallel_reduce(function, fork_join_map, &mut plan);
// Infer a partitioning.
partition_out_forks(function, reverse_postorder, fork_join_map, &mut plan);
partition_out_forks(function, reverse_postorder, fork_join_map, bbs, &mut plan);
plan
}
......@@ -143,6 +144,7 @@ pub fn partition_out_forks(
function: &Function,
reverse_postorder: &Vec<NodeID>,
fork_join_map: &HashMap<NodeID, NodeID>,
bbs: &Vec<NodeID>,
plan: &mut Plan,
) {
impl Semilattice for NodeID {
......@@ -171,7 +173,7 @@ pub fn partition_out_forks(
// 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
// representative node ID.
let control_representatives = forward_dataflow(
let mut representatives = forward_dataflow(
function,
reverse_postorder,
|inputs: &[&NodeID], node_id: NodeID| match function.nodes[node_id.idx()] {
......@@ -212,7 +214,13 @@ pub fn partition_out_forks(
},
);
// Step 2:
// Step 2: assign data nodes to the partitions of the control nodes they are
// assigned to by GCM.
for idx in 0..function.nodes.len() {
if !function.nodes[idx].is_control() {
representatives[idx] = representatives[bbs[idx].idx()];
}
}
// Step 3: deduplicate representative node IDs.
let mut representative_to_partition_ids = HashMap::new();
......
......@@ -7,4 +7,5 @@ authors = ["Russel Arbore <rarbore2@illinois.edu>"]
clap = { version = "*", features = ["derive"] }
hercules_ir = { path = "../../hercules_ir" }
hercules_opt = { path = "../../hercules_opt" }
hercules_cg = { path = "../../hercules_cg" }
rand = "*"
......@@ -58,18 +58,36 @@ fn main() {
(function, (types, constants, dynamic_constants))
},
);
let (_def_uses, reverse_postorders, typing, _subgraphs, doms, _postdoms, fork_join_maps) =
let (def_uses, reverse_postorders, typing, subgraphs, doms, _postdoms, fork_join_maps) =
hercules_ir::verify::verify(&mut module)
.expect("PANIC: Failed to verify Hercules IR module.");
println!(
"{:?}",
hercules_ir::schedule::default_plan(
&module.functions[0],
&reverse_postorders[0],
&fork_join_maps[0]
)
);
let plans: Vec<_> = module
.functions
.iter()
.enumerate()
.map(|(idx, function)| {
hercules_ir::schedule::default_plan(
function,
&reverse_postorders[idx],
&fork_join_maps[idx],
&hercules_cg::gcm::gcm(
function,
&def_uses[idx],
&reverse_postorders[idx],
&subgraphs[idx],
&doms[idx],
&fork_join_maps[idx],
&hercules_cg::antideps::array_antideps(
function,
&def_uses[idx],
&module.types,
&typing[idx],
),
),
)
})
.collect();
if args.output.is_empty() {
let mut tmp_path = temp_dir();
......
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