Skip to content
Snippets Groups Projects

Round 1 of rodinia schedule optimization

Merged rarbore2 requested to merge rodinia_opt1 into main
2 files
+ 16
33
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 15
32
@@ -255,16 +255,6 @@ impl ParameterLattice {
}
}
fn try_const_dc(self, dcs: Ref<'_, Vec<DynamicConstant>>) -> Option<usize> {
if let ParameterLattice::DynamicConstant(id, _) = self
&& let DynamicConstant::Constant(val) = &dcs[id.idx()]
{
Some(*val)
} else {
None
}
}
fn meet(&mut self, b: Self, cons: Ref<'_, Vec<Constant>>, dcs: Ref<'_, Vec<DynamicConstant>>) {
use ParameterLattice::*;
*self = match (*self, b) {
@@ -312,8 +302,7 @@ impl ParameterLattice {
*
* 1. Not marked as entry.
* 2. At every call site, a particular parameter is always a specific constant
* or dynamic constant OR a particular dynamic constant parameter is always a
* specific constant.
* or dynamic constant.
*
* These functions can have that constant "inlined" - the parameter is removed
* and all uses of the parameter becomes uses of the constant directly.
@@ -327,16 +316,14 @@ pub fn const_inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
continue;
}
// Figure out what we know about the parameters (both normal and dynamic
// constant) to this function.
// Figure out what we know about the parameters to this function.
let mut param_lattice = vec![ParameterLattice::Top; func.param_types.len()];
let mut dc_param_lattice = vec![ParameterLattice::Top; func.num_dynamic_constants as usize];
let mut callers = vec![];
for caller in callgraph.get_callers(func_id) {
let editor = &editors[caller.idx()];
let nodes = &editor.func().nodes;
for id in editor.node_ids() {
if let Some((_, callee, dc_args, args)) = nodes[id.idx()].try_call()
if let Some((_, callee, _, args)) = nodes[id.idx()].try_call()
&& callee == func_id
{
if editor.is_mutable(id) {
@@ -348,31 +335,16 @@ pub fn const_inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
editor.get_dynamic_constants(),
);
}
for (idx, id) in dc_args.into_iter().enumerate() {
let lattice = ParameterLattice::DynamicConstant(*id, func_id);
dc_param_lattice[idx].meet(
lattice,
editor.get_constants(),
editor.get_dynamic_constants(),
);
}
} else {
// If we can't modify the call node in the caller, then
// we can't perform the inlining.
param_lattice = vec![ParameterLattice::Bottom; func.param_types.len()];
dc_param_lattice =
vec![ParameterLattice::Bottom; func.num_dynamic_constants as usize];
}
callers.push((caller, id));
}
}
}
if param_lattice.iter().all(|v| *v == ParameterLattice::Bottom)
&& dc_param_lattice
.iter()
.all(|v| *v == ParameterLattice::Bottom)
{
if param_lattice.iter().all(|v| *v == ParameterLattice::Bottom) {
continue;
}
@@ -392,6 +364,17 @@ pub fn const_inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
if let Some(node) = match param_lattice[idx] {
ParameterLattice::Top => Some(Node::Undef { ty: param_tys[idx] }),
ParameterLattice::Constant(id) => Some(Node::Constant { id }),
ParameterLattice::DynamicConstant(id, _) => {
// Rust moment.
let maybe_cons = edit.get_dynamic_constant(id).try_constant();
if let Some(val) = maybe_cons {
Some(Node::DynamicConstant {
id: edit.add_dynamic_constant(DynamicConstant::Constant(val)),
})
} else {
None
}
}
_ => None,
} && let Some(ids) = param_idx_to_ids.get(&idx)
{
Loading