Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • llvm/hercules
1 result
Show changes
gvn(*); macro simpl!(X) {
dce(*); ccp(X);
simplify-cfg(X);
lift-dc-math(X);
gvn(X);
phi-elim(X);
dce(X);
infer-schedules(X);
}
phi-elim(*); phi-elim(*);
dce(*); let sum_loop = outline(srad@loop1);
let main_loops = outline(srad@loop2 | srad@loop3);
gpu(main_loops, extract, compress);
simpl!(*);
const-inline[true](*);
crc(*); crc(*);
dce(*);
slf(*); slf(*);
dce(*); write-predication(*);
simpl!(*);
let auto = auto-outline(srad); predication(*);
gpu(auto.srad); simpl!(*);
predication(*);
inline(auto.srad); simpl!(*);
inline(auto.srad); fixpoint {
delete-uncalled(*); forkify(*);
fork-guard-elim(*);
fork-coalesce(*);
}
simpl!(*);
reduce-slf(*);
simpl!(*);
array-slf(*);
simpl!(*);
slf(*);
simpl!(*);
sroa[false](auto.srad); fork-dim-merge(sum_loop);
dce(*); simpl!(sum_loop);
float-collections(*); fork-tile[32, 0, false, true](sum_loop);
dce(*); let out = fork-split(sum_loop);
clean-monoid-reduces(sum_loop);
simpl!(sum_loop);
let fission = fork-fission[out.srad_0.fj0](sum_loop);
simpl!(sum_loop);
fork-tile[32, 0, false, true](fission.srad_0.fj_bottom);
let out = fork-split(fission.srad_0.fj_bottom);
clean-monoid-reduces(sum_loop);
simpl!(sum_loop);
let top = outline(fission.srad_0.fj_top);
let bottom = outline(out.srad_0.fj0);
gpu(top, bottom);
ip-sroa(*);
sroa(*);
simpl!(*);
gcm(*); gcm(*);
...@@ -114,7 +114,7 @@ pub fn srad_harness(args: SRADInputs) { ...@@ -114,7 +114,7 @@ pub fn srad_harness(args: SRADInputs) {
.max() .max()
.unwrap_or(0); .unwrap_or(0);
assert!( assert!(
max_diff <= 1, max_diff <= 2,
"Verification failed: maximum pixel difference of {} exceeds threshold of 1", "Verification failed: maximum pixel difference of {} exceeds threshold of 1",
max_diff max_diff
); );
......
...@@ -12,8 +12,8 @@ fn srad_test() { ...@@ -12,8 +12,8 @@ fn srad_test() {
srad_harness(SRADInputs { srad_harness(SRADInputs {
niter: 100, niter: 100,
lambda: 0.5, lambda: 0.5,
nrows: 502, nrows: 512,
ncols: 458, ncols: 512,
image: "data/image.pgm".to_string(), image: "data/image.pgm".to_string(),
output: None, output: None,
verify: true, verify: true,
......
...@@ -38,7 +38,7 @@ fn srad<nrows, ncols: usize>( ...@@ -38,7 +38,7 @@ fn srad<nrows, ncols: usize>(
// These loops should really be interchanged, but they aren't in the // These loops should really be interchanged, but they aren't in the
// Rodinia source (though they are in the HPVM source) // Rodinia source (though they are in the HPVM source)
for i in 0..nrows { @loop1 for i in 0..nrows {
for j in 0..ncols { for j in 0..ncols {
let tmp = image[j, i]; let tmp = image[j, i];
sum += tmp; sum += tmp;
...@@ -50,14 +50,14 @@ fn srad<nrows, ncols: usize>( ...@@ -50,14 +50,14 @@ fn srad<nrows, ncols: usize>(
let varROI = (sum2 / nelems as f32) - meanROI * meanROI; let varROI = (sum2 / nelems as f32) - meanROI * meanROI;
let q0sqr = varROI / (meanROI * meanROI); let q0sqr = varROI / (meanROI * meanROI);
let dN : f32[ncols, nrows]; @dirs let dN : f32[ncols, nrows];
let dS : f32[ncols, nrows]; @dirs let dS : f32[ncols, nrows];
let dE : f32[ncols, nrows]; @dirs let dE : f32[ncols, nrows];
let dW : f32[ncols, nrows]; @dirs let dW : f32[ncols, nrows];
let c : f32[ncols, nrows]; let c : f32[ncols, nrows];
for j in 0..ncols { @loop2 for j in 0..ncols {
for i in 0..nrows { for i in 0..nrows {
let Jc = image[j, i]; let Jc = image[j, i];
dN[j, i] = image[j, iN[i] as u64] - Jc; dN[j, i] = image[j, iN[i] as u64] - Jc;
...@@ -75,14 +75,15 @@ fn srad<nrows, ncols: usize>( ...@@ -75,14 +75,15 @@ fn srad<nrows, ncols: usize>(
let qsqr = num / (den * den); let qsqr = num / (den * den);
let den = (qsqr - q0sqr) / (q0sqr * (1 + q0sqr)); let den = (qsqr - q0sqr) / (q0sqr * (1 + q0sqr));
c[j, i] = 1.0 / (1.0 + den); let val = 1.0 / (1.0 + den);
if c[j, i] < 0 { c[j, i] = 0; } if val < 0 { c[j, i] = 0; }
else if c[j, i] > 1 { c[j, i] = 1; } else if val > 1 { c[j, i] = 1; }
else { c[j, i] = val; }
} }
} }
for j in 0..ncols { @loop3 for j in 0..ncols {
for i in 0..nrows { for i in 0..nrows {
let cN = c[j, i]; let cN = c[j, i];
let cS = c[j, iS[i] as u64]; let cS = c[j, iS[i] as u64];
......
...@@ -112,6 +112,7 @@ impl FromStr for Appliable { ...@@ -112,6 +112,7 @@ impl FromStr for Appliable {
"ccp" => Ok(Appliable::Pass(ir::Pass::CCP)), "ccp" => Ok(Appliable::Pass(ir::Pass::CCP)),
"crc" | "collapse-read-chains" => Ok(Appliable::Pass(ir::Pass::CRC)), "crc" | "collapse-read-chains" => Ok(Appliable::Pass(ir::Pass::CRC)),
"clean-monoid-reduces" => Ok(Appliable::Pass(ir::Pass::CleanMonoidReduces)), "clean-monoid-reduces" => Ok(Appliable::Pass(ir::Pass::CleanMonoidReduces)),
"const-inline" => Ok(Appliable::Pass(ir::Pass::ConstInline)),
"dce" => Ok(Appliable::Pass(ir::Pass::DCE)), "dce" => Ok(Appliable::Pass(ir::Pass::DCE)),
"delete-uncalled" => Ok(Appliable::DeleteUncalled), "delete-uncalled" => Ok(Appliable::DeleteUncalled),
"float-collections" | "collections" => Ok(Appliable::Pass(ir::Pass::FloatCollections)), "float-collections" | "collections" => Ok(Appliable::Pass(ir::Pass::FloatCollections)),
......
...@@ -8,8 +8,9 @@ pub enum Pass { ...@@ -8,8 +8,9 @@ pub enum Pass {
ArrayToProduct, ArrayToProduct,
AutoOutline, AutoOutline,
CCP, CCP,
CleanMonoidReduces,
CRC, CRC,
CleanMonoidReduces,
ConstInline,
DCE, DCE,
FloatCollections, FloatCollections,
ForkChunk, ForkChunk,
...@@ -53,14 +54,15 @@ impl Pass { ...@@ -53,14 +54,15 @@ impl Pass {
pub fn is_valid_num_args(&self, num: usize) -> bool { pub fn is_valid_num_args(&self, num: usize) -> bool {
match self { match self {
Pass::ArrayToProduct => num == 0 || num == 1, Pass::ArrayToProduct => num == 0 || num == 1,
Pass::ConstInline => num == 0 || num == 1,
Pass::ForkChunk => num == 4, Pass::ForkChunk => num == 4,
Pass::ForkExtend => num == 1, Pass::ForkExtend => num == 1,
Pass::ForkFissionBufferize => num == 2 || num == 1, Pass::ForkFissionBufferize => num == 2 || num == 1,
Pass::ForkInterchange => num == 2, Pass::ForkInterchange => num == 2,
Pass::InterproceduralSROA => num == 0 || num == 1,
Pass::Print => num == 1, Pass::Print => num == 1,
Pass::Rename => num == 1, Pass::Rename => num == 1,
Pass::SROA => num == 0 || num == 1, Pass::SROA => num == 0 || num == 1,
Pass::InterproceduralSROA => num == 0 || num == 1,
Pass::Xdot => num == 0 || num == 1, Pass::Xdot => num == 0 || num == 1,
_ => num == 0, _ => num == 0,
} }
...@@ -69,14 +71,15 @@ impl Pass { ...@@ -69,14 +71,15 @@ impl Pass {
pub fn valid_arg_nums(&self) -> &'static str { pub fn valid_arg_nums(&self) -> &'static str {
match self { match self {
Pass::ArrayToProduct => "0 or 1", Pass::ArrayToProduct => "0 or 1",
Pass::ConstInline => "0 or 1",
Pass::ForkChunk => "4", Pass::ForkChunk => "4",
Pass::ForkExtend => "1", Pass::ForkExtend => "1",
Pass::ForkFissionBufferize => "1 or 2", Pass::ForkFissionBufferize => "1 or 2",
Pass::ForkInterchange => "2", Pass::ForkInterchange => "2",
Pass::InterproceduralSROA => "0 or 1",
Pass::Print => "1", Pass::Print => "1",
Pass::Rename => "1", Pass::Rename => "1",
Pass::SROA => "0 or 1", Pass::SROA => "0 or 1",
Pass::InterproceduralSROA => "0 or 1",
Pass::Xdot => "0 or 1", Pass::Xdot => "0 or 1",
_ => "0", _ => "0",
} }
......
...@@ -951,6 +951,7 @@ impl PassManager { ...@@ -951,6 +951,7 @@ impl PassManager {
for idx in 0..module.functions.len() { for idx in 0..module.functions.len() {
match devices[idx] { match devices[idx] {
Device::LLVM => cpu_codegen( Device::LLVM => cpu_codegen(
&module_name,
&module.functions[idx], &module.functions[idx],
&module.types, &module.types,
&module.constants, &module.constants,
...@@ -966,6 +967,7 @@ impl PassManager { ...@@ -966,6 +967,7 @@ impl PassManager {
error: format!("{}", e), error: format!("{}", e),
})?, })?,
Device::CUDA => gpu_codegen( Device::CUDA => gpu_codegen(
&module_name,
&module.functions[idx], &module.functions[idx],
&module.types, &module.types,
&module.constants, &module.constants,
...@@ -986,6 +988,7 @@ impl PassManager { ...@@ -986,6 +988,7 @@ impl PassManager {
error: format!("{}", e), error: format!("{}", e),
})?, })?,
Device::AsyncRust => rt_codegen( Device::AsyncRust => rt_codegen(
&module_name,
FunctionID::new(idx), FunctionID::new(idx),
&module, &module,
&def_uses[idx], &def_uses[idx],
...@@ -1833,6 +1836,34 @@ fn run_pass( ...@@ -1833,6 +1836,34 @@ fn run_pass(
pm.delete_gravestones(); pm.delete_gravestones();
pm.clear_analyses(); pm.clear_analyses();
} }
Pass::ConstInline => {
let inline_collections = match args.get(0) {
Some(Value::Boolean { val }) => *val,
Some(_) => {
return Err(SchedulerError::PassError {
pass: "constInline".to_string(),
error: "expected boolean argument".to_string(),
});
}
None => true,
};
pm.make_callgraph();
let callgraph = pm.callgraph.take().unwrap();
let mut editors: Vec<_> = build_selection(pm, selection, true)
.into_iter()
.map(|editor| editor.unwrap())
.collect();
const_inline(&mut editors, &callgraph, inline_collections);
for func in editors {
changed |= func.modified();
}
pm.delete_gravestones();
pm.clear_analyses();
}
Pass::CRC => { Pass::CRC => {
assert!(args.is_empty()); assert!(args.is_empty());
for func in build_selection(pm, selection, false) { for func in build_selection(pm, selection, false) {
......