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(*);
dce(*);
macro simpl!(X) {
ccp(X);
simplify-cfg(X);
lift-dc-math(X);
gvn(X);
phi-elim(X);
dce(X);
infer-schedules(X);
}
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(*);
dce(*);
slf(*);
dce(*);
let auto = auto-outline(srad);
gpu(auto.srad);
inline(auto.srad);
inline(auto.srad);
delete-uncalled(*);
write-predication(*);
simpl!(*);
predication(*);
simpl!(*);
predication(*);
simpl!(*);
fixpoint {
forkify(*);
fork-guard-elim(*);
fork-coalesce(*);
}
simpl!(*);
reduce-slf(*);
simpl!(*);
array-slf(*);
simpl!(*);
slf(*);
simpl!(*);
sroa[false](auto.srad);
dce(*);
float-collections(*);
dce(*);
fork-dim-merge(sum_loop);
simpl!(sum_loop);
fork-tile[32, 0, false, true](sum_loop);
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(*);
......@@ -114,7 +114,7 @@ pub fn srad_harness(args: SRADInputs) {
.max()
.unwrap_or(0);
assert!(
max_diff <= 1,
max_diff <= 2,
"Verification failed: maximum pixel difference of {} exceeds threshold of 1",
max_diff
);
......
......@@ -12,8 +12,8 @@ fn srad_test() {
srad_harness(SRADInputs {
niter: 100,
lambda: 0.5,
nrows: 502,
ncols: 458,
nrows: 512,
ncols: 512,
image: "data/image.pgm".to_string(),
output: None,
verify: true,
......
......@@ -38,7 +38,7 @@ fn srad<nrows, ncols: usize>(
// These loops should really be interchanged, but they aren't in the
// 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 {
let tmp = image[j, i];
sum += tmp;
......@@ -50,14 +50,14 @@ fn srad<nrows, ncols: usize>(
let varROI = (sum2 / nelems as f32) - meanROI * meanROI;
let q0sqr = varROI / (meanROI * meanROI);
let dN : f32[ncols, nrows];
let dS : f32[ncols, nrows];
let dE : f32[ncols, nrows];
let dW : f32[ncols, nrows];
@dirs let dN : f32[ncols, nrows];
@dirs let dS : f32[ncols, nrows];
@dirs let dE : f32[ncols, nrows];
@dirs let dW : f32[ncols, nrows];
let c : f32[ncols, nrows];
for j in 0..ncols {
@loop2 for j in 0..ncols {
for i in 0..nrows {
let Jc = image[j, i];
dN[j, i] = image[j, iN[i] as u64] - Jc;
......@@ -75,14 +75,15 @@ fn srad<nrows, ncols: usize>(
let qsqr = num / (den * den);
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; }
else if c[j, i] > 1 { c[j, i] = 1; }
if val < 0 { c[j, i] = 0; }
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 {
let cN = c[j, i];
let cS = c[j, iS[i] as u64];
......
......@@ -112,6 +112,7 @@ impl FromStr for Appliable {
"ccp" => Ok(Appliable::Pass(ir::Pass::CCP)),
"crc" | "collapse-read-chains" => Ok(Appliable::Pass(ir::Pass::CRC)),
"clean-monoid-reduces" => Ok(Appliable::Pass(ir::Pass::CleanMonoidReduces)),
"const-inline" => Ok(Appliable::Pass(ir::Pass::ConstInline)),
"dce" => Ok(Appliable::Pass(ir::Pass::DCE)),
"delete-uncalled" => Ok(Appliable::DeleteUncalled),
"float-collections" | "collections" => Ok(Appliable::Pass(ir::Pass::FloatCollections)),
......
......@@ -8,8 +8,9 @@ pub enum Pass {
ArrayToProduct,
AutoOutline,
CCP,
CleanMonoidReduces,
CRC,
CleanMonoidReduces,
ConstInline,
DCE,
FloatCollections,
ForkChunk,
......@@ -53,14 +54,15 @@ impl Pass {
pub fn is_valid_num_args(&self, num: usize) -> bool {
match self {
Pass::ArrayToProduct => num == 0 || num == 1,
Pass::ConstInline => num == 0 || num == 1,
Pass::ForkChunk => num == 4,
Pass::ForkExtend => num == 1,
Pass::ForkFissionBufferize => num == 2 || num == 1,
Pass::ForkInterchange => num == 2,
Pass::InterproceduralSROA => num == 0 || num == 1,
Pass::Print => num == 1,
Pass::Rename => num == 1,
Pass::SROA => num == 0 || num == 1,
Pass::InterproceduralSROA => num == 0 || num == 1,
Pass::Xdot => num == 0 || num == 1,
_ => num == 0,
}
......@@ -69,14 +71,15 @@ impl Pass {
pub fn valid_arg_nums(&self) -> &'static str {
match self {
Pass::ArrayToProduct => "0 or 1",
Pass::ConstInline => "0 or 1",
Pass::ForkChunk => "4",
Pass::ForkExtend => "1",
Pass::ForkFissionBufferize => "1 or 2",
Pass::ForkInterchange => "2",
Pass::InterproceduralSROA => "0 or 1",
Pass::Print => "1",
Pass::Rename => "1",
Pass::SROA => "0 or 1",
Pass::InterproceduralSROA => "0 or 1",
Pass::Xdot => "0 or 1",
_ => "0",
}
......
......@@ -951,6 +951,7 @@ impl PassManager {
for idx in 0..module.functions.len() {
match devices[idx] {
Device::LLVM => cpu_codegen(
&module_name,
&module.functions[idx],
&module.types,
&module.constants,
......@@ -966,6 +967,7 @@ impl PassManager {
error: format!("{}", e),
})?,
Device::CUDA => gpu_codegen(
&module_name,
&module.functions[idx],
&module.types,
&module.constants,
......@@ -986,6 +988,7 @@ impl PassManager {
error: format!("{}", e),
})?,
Device::AsyncRust => rt_codegen(
&module_name,
FunctionID::new(idx),
&module,
&def_uses[idx],
......@@ -1833,6 +1836,34 @@ fn run_pass(
pm.delete_gravestones();
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 => {
assert!(args.is_empty());
for func in build_selection(pm, selection, false) {
......