Skip to content
Snippets Groups Projects
Commit 248d64fc authored by rarbore2's avatar rarbore2
Browse files

Fix DC param ID identfication

parent 694dacca
No related branches found
No related tags found
1 merge request!161Fix DC param ID identfication
/target /target
*.dot *.dot
!paper_resources/*.dot
*.bc *.bc
*.out *.out
*.ll *.ll
......
...@@ -24,21 +24,19 @@ pub fn inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) { ...@@ -24,21 +24,19 @@ pub fn inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
.map(|editor| collapse_returns(editor)) .map(|editor| collapse_returns(editor))
.collect(); .collect();
// Step 3: verify that each possible dynamic constant parameter index has a // Step 3: get dynamic constant IDs for parameters.
// single unique dynamic constant ID. If this isn't true, dynamic constant let max_num_dc_params = editors
// substitution won't work, and this should be true anyway! .iter()
let mut found_idxs = HashMap::new(); .map(|editor| editor.func().num_dynamic_constants)
for id in editors[0].dynamic_constant_ids() { .max()
let dc = editors[0].get_dynamic_constant(id); .unwrap();
if let DynamicConstant::Parameter(idx) = *dc { let mut dc_args = vec![];
assert!(!found_idxs.contains_key(&idx)); editors[0].edit(|mut edit| {
found_idxs.insert(idx, id); dc_args = (0..max_num_dc_params as usize)
} .map(|i| edit.add_dynamic_constant(DynamicConstant::Parameter(i)))
} .collect();
let mut dc_param_idx_to_dc_id = vec![]; Ok(edit)
for idx in 0..found_idxs.len() { });
dc_param_idx_to_dc_id.push(found_idxs[&idx]);
}
// Step 4: run inlining on each function individually. Iterate the functions // Step 4: run inlining on each function individually. Iterate the functions
// in topological order. // in topological order.
...@@ -49,12 +47,7 @@ pub fn inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) { ...@@ -49,12 +47,7 @@ pub fn inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
// 2. Shared references to all of the functions called by that function. // 2. Shared references to all of the functions called by that function.
let callees = callgraph.get_callees(to_inline_id); let callees = callgraph.get_callees(to_inline_id);
let editor_refs = get_mut_and_immuts(editors, to_inline_id, callees); let editor_refs = get_mut_and_immuts(editors, to_inline_id, callees);
inline_func( inline_func(editor_refs.0, editor_refs.1, &single_return_nodes, &dc_args);
editor_refs.0,
editor_refs.1,
&single_return_nodes,
&dc_param_idx_to_dc_id,
);
} }
} }
......
...@@ -235,18 +235,18 @@ fn compress_return_products(editors: &mut Vec<FunctionEditor>, all_callsites_edi ...@@ -235,18 +235,18 @@ fn compress_return_products(editors: &mut Vec<FunctionEditor>, all_callsites_edi
// dc_param_idx_to_dc_id to get the id of the dynamic constants in the function, // dc_param_idx_to_dc_id to get the id of the dynamic constants in the function,
// and then replace dc_param_idx_to_dc_id[i] with call.dynamic_constants[i], // and then replace dc_param_idx_to_dc_id[i] with call.dynamic_constants[i],
// for all i. // for all i.
let mut found_idxs = HashMap::new(); let max_num_dc_params = editors
for id in editors[0].dynamic_constant_ids() { .iter()
let dc = editors[0].get_dynamic_constant(id); .map(|editor| editor.func().num_dynamic_constants)
if let DynamicConstant::Parameter(idx) = *dc { .max()
assert!(!found_idxs.contains_key(&idx)); .unwrap();
found_idxs.insert(idx, id); let mut dc_args = vec![];
} editors[0].edit(|mut edit| {
} dc_args = (0..max_num_dc_params as usize)
let mut dc_param_idx_to_dc_id = vec![]; .map(|i| edit.add_dynamic_constant(DynamicConstant::Parameter(i)))
for idx in 0..found_idxs.len() { .collect();
dc_param_idx_to_dc_id.push(found_idxs[&idx]); Ok(edit)
} });
// Step 2. Modify the return type of all editors corresponding to a function // Step 2. Modify the return type of all editors corresponding to a function
// for which we can edit every callsite, and the return type is a product. // for which we can edit every callsite, and the return type is a product.
...@@ -314,7 +314,7 @@ fn compress_return_products(editors: &mut Vec<FunctionEditor>, all_callsites_edi ...@@ -314,7 +314,7 @@ fn compress_return_products(editors: &mut Vec<FunctionEditor>, all_callsites_edi
// a better abstraction around bulk replacement. // a better abstraction around bulk replacement.
let new_dcs = (*dynamic_constants).to_vec(); let new_dcs = (*dynamic_constants).to_vec();
let old_dcs = dc_param_idx_to_dc_id[..new_dcs.len()].to_vec(); let old_dcs = dc_args[..new_dcs.len()].to_vec();
assert_eq!(old_dcs.len(), new_dcs.len()); assert_eq!(old_dcs.len(), new_dcs.len());
let substs = old_dcs let substs = old_dcs
.into_iter() .into_iter()
......
digraph "Module" {
margin=0;
subgraph sum {
label="sum<1>"
style=invis
cluster=true
ranksep=1;
nodesep=1;
start_0_0 [xlabel=0, label=<Start<BR /><FONT POINT-SIZE="8">Control</FONT>>, color=darkred];
parameter_0_1 [xlabel=1, label=<Parameter (#0)<BR /><FONT POINT-SIZE="8">Array(Float32, #0)</FONT>>, color=darkblue];
dynamic_constant_0_2 [xlabel=2, label=<DynamicConstant (#0)<BR /><FONT POINT-SIZE="8">UnsignedInteger64</FONT>>, color=darkblue];
projection_0_3 [xlabel=3, label=<Projection<BR /><FONT POINT-SIZE="8">Control</FONT>>, color=darkred];
add_0_4 [xlabel=4, label=<Add<BR /><FONT POINT-SIZE="8">UnsignedInteger64</FONT>>, color=darkblue];
add_0_5 [xlabel=5, label=<Add<BR /><FONT POINT-SIZE="8">Float32</FONT>>, color=darkblue];
read_0_6 [xlabel=6, label=<Read<BR /><FONT POINT-SIZE="8">Float32</FONT>>, color=darkblue];
lt_0_7 [xlabel=7, label=<LT<BR /><FONT POINT-SIZE="8">Boolean</FONT>>, color=darkblue];
if_0_8 [xlabel=8, label=<If<BR /><FONT POINT-SIZE="8">Control</FONT>>, color=darkred];
projection_0_9 [xlabel=9, label=<Projection<BR /><FONT POINT-SIZE="8">Control</FONT>>, color=darkred];
return_0_10 [xlabel=10, label=<Return>, color=darkred];
constant_0_11 [xlabel=11, label=<Constant (0)<BR /><FONT POINT-SIZE="8">UnsignedInteger64</FONT>>, color=darkblue];
constant_0_12 [xlabel=12, label=<Constant (1)<BR /><FONT POINT-SIZE="8">UnsignedInteger64</FONT>>, color=darkblue];
constant_0_13 [xlabel=13, label=<Constant (0)<BR /><FONT POINT-SIZE="8">Float32</FONT>>, color=darkblue];
phi_0_14 [xlabel=14, label=<Phi<BR /><FONT POINT-SIZE="8">UnsignedInteger64</FONT>>, color=darkblue];
phi_0_15 [xlabel=15, label=<Phi<BR /><FONT POINT-SIZE="8">Float32</FONT>>, color=darkblue];
region_0_16 [xlabel=16, label=<Region<BR /><FONT POINT-SIZE="8">Control</FONT>>, color=darkred];
if_0_8 -> projection_0_3 [color=black, style="dashed"];
phi_0_14 -> add_0_4 [color=black, style=""];
constant_0_12 -> add_0_4 [color=black, style=""];
phi_0_15 -> add_0_5 [color=black, style=""];
read_0_6 -> add_0_5 [color=black, style=""];
parameter_0_1 -> read_0_6 [color=black, style=""];
phi_0_14 -> read_0_6 [color=black, style=""];
add_0_4 -> lt_0_7 [color=black, style=""];
dynamic_constant_0_2 -> lt_0_7 [color=black, style=""];
if_0_8 -> region_0_16 [dir=back, color=black, style="dashed"];
lt_0_7 -> if_0_8 [color=black, style="dotted"];
if_0_8 -> projection_0_9 [color=black, style="dashed"];
projection_0_9 -> return_0_10 [color=black, style="dashed"];
add_0_5 -> return_0_10 [color=black, style="dotted"];
constant_0_11 -> phi_0_14 [color=black, style=""];
phi_0_14 -> add_0_4 [dir=back, color=black, style=""];
region_0_16 -> phi_0_14 [color=black, style="dotted"];
constant_0_13 -> phi_0_15 [color=black, style=""];
add_0_5 -> phi_0_15 [color=black, style=""];
region_0_16 -> phi_0_15 [color=black, style="dotted"];
start_0_0 -> region_0_16 [color=black, style="dashed"];
projection_0_3 -> region_0_16 [color=black, style="dashed"];
}
}
File added
digraph "Module" {
margin=0;
subgraph matmul {
label="matmul<3>"
style=invis
cluster=true
ranksep=1;
nodesep=1;
start_0_0 [xlabel=0, label=<Start<BR /><FONT POINT-SIZE="8">Control</FONT>>, color=darkred];
parameter_0_1 [xlabel=1, label=<Parameter (#0)<BR /><FONT POINT-SIZE="8">Array(Integer32, #0, #1)</FONT>>, color=darkblue];
parameter_0_2 [xlabel=2, label=<Parameter (#1)<BR /><FONT POINT-SIZE="8">Array(Integer32, #1, #2)</FONT>>, color=darkblue];
fork_0_3 [xlabel=3, label=<Fork (#0, #2)<BR /><FONT POINT-SIZE="8">Control</FONT><BR /><FONT POINT-SIZE="8">ParallelFork</FONT>>, color=darkred];
thread_id_0_4 [xlabel=4, label=<ThreadID (0)<BR /><FONT POINT-SIZE="8">UnsignedInteger64</FONT>>, color=darkblue];
thread_id_0_5 [xlabel=5, label=<ThreadID (1)<BR /><FONT POINT-SIZE="8">UnsignedInteger64</FONT>>, color=darkblue];
fork_0_6 [xlabel=6, label=<Fork (#1)<BR /><FONT POINT-SIZE="8">Control</FONT><BR /><FONT POINT-SIZE="8">Vectorizable</FONT>>, color=darkred];
thread_id_0_7 [xlabel=7, label=<ThreadID (0)<BR /><FONT POINT-SIZE="8">UnsignedInteger64</FONT>>, color=darkblue];
join_0_8 [xlabel=8, label=<Join<BR /><FONT POINT-SIZE="8">Control</FONT>>, color=darkred];
join_0_9 [xlabel=9, label=<Join<BR /><FONT POINT-SIZE="8">Control</FONT>>, color=darkred];
reduce_0_10 [xlabel=10, label=<Reduce<BR /><FONT POINT-SIZE="8">Array(Integer32, #0, #2)</FONT><BR /><FONT POINT-SIZE="8">ParallelReduce</FONT>>, color=darkblue];
return_0_11 [xlabel=11, label=<Return>, color=darkred];
read_0_12 [xlabel=12, label=<Read<BR /><FONT POINT-SIZE="8">Integer32</FONT>>, color=darkblue];
read_0_13 [xlabel=13, label=<Read<BR /><FONT POINT-SIZE="8">Integer32</FONT>>, color=darkblue];
mul_0_14 [xlabel=14, label=<Mul<BR /><FONT POINT-SIZE="8">Integer32</FONT>>, color=darkblue];
reduce_0_15 [xlabel=15, label=<Reduce<BR /><FONT POINT-SIZE="8">Integer32</FONT><BR /><FONT POINT-SIZE="8">TightAssociative</FONT>>, color=darkblue];
add_0_16 [xlabel=16, label=<Add<BR /><FONT POINT-SIZE="8">Integer32</FONT>>, color=darkblue];
write_0_17 [xlabel=17, label=<Write<BR /><FONT POINT-SIZE="8">Array(Integer32, #0, #2)</FONT>>, color=darkblue];
constant_0_18 [xlabel=18, label=<Constant ([])<BR /><FONT POINT-SIZE="8">Array(Integer32, #0, #2)</FONT><BR /><FONT POINT-SIZE="8">NoResetConstant</FONT>>, color=darkblue];
constant_0_19 [xlabel=19, label=<Constant (0)<BR /><FONT POINT-SIZE="8">Integer32</FONT>>, color=darkblue];
start_0_0 -> fork_0_3 [color=black, style="dashed"];
fork_0_3 -> thread_id_0_4 [color=black, style="dotted"];
fork_0_3 -> thread_id_0_5 [color=black, style="dotted"];
fork_0_3 -> fork_0_6 [color=black, style="dashed"];
fork_0_6 -> thread_id_0_7 [color=black, style="dotted"];
fork_0_6 -> join_0_8 [color=black, style="dashed"];
join_0_8 -> join_0_9 [color=black, style="dashed"];
join_0_9 -> reduce_0_10 [color=black, style="dotted"];
constant_0_18 -> reduce_0_10 [color=black, style=""];
write_0_17 -> reduce_0_10 [color=black, style=""];
join_0_9 -> return_0_11 [color=black, style="dashed"];
reduce_0_10 -> return_0_11 [color=black, style="dotted"];
parameter_0_1 -> read_0_12 [color=black, style=""];
thread_id_0_4 -> read_0_12 [color=black, style=""];
thread_id_0_7 -> read_0_12 [color=black, style=""];
parameter_0_2 -> read_0_13 [color=black, style=""];
thread_id_0_7 -> read_0_13 [color=black, style=""];
thread_id_0_5 -> read_0_13 [color=black, style=""];
read_0_12 -> mul_0_14 [color=black, style=""];
read_0_13 -> mul_0_14 [color=black, style=""];
join_0_8 -> reduce_0_15 [color=black, style="dotted"];
constant_0_19 -> reduce_0_15 [color=black, style=""];
add_0_16 -> reduce_0_15 [color=black, style=""];
mul_0_14 -> add_0_16 [color=black, style=""];
reduce_0_15 -> add_0_16 [color=black, style=""];
reduce_0_10 -> write_0_17 [color=black, style=""];
reduce_0_15 -> write_0_17 [color=black, style=""];
thread_id_0_4 -> write_0_17 [color=black, style=""];
thread_id_0_5 -> write_0_17 [color=black, style=""];
parameter_0_1 -> thread_id_0_4 [style=invis];
parameter_0_2 -> thread_id_0_5 [style=invis];
}
}
File added
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