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

edge fork schedule, found issue in RT backend

parent 6bce8641
No related branches found
No related tags found
1 merge request!192Optimize edge detection
Pipeline #201776 failed
This commit is part of merge request !192. Comments created here will be created in the context of that merge request.
...@@ -127,17 +127,8 @@ simpl!(fuse5); ...@@ -127,17 +127,8 @@ simpl!(fuse5);
delete-uncalled(*); delete-uncalled(*);
simpl!(*); simpl!(*);
fork-split(fuse1, fuse2, fuse3, fuse4, fuse5);
fork-split(fuse1); unforkify(fuse1, fuse2, fuse3, fuse4, fuse5);
unforkify(fuse1);
fork-split(fuse2);
unforkify(fuse2);
fork-split(fuse3);
unforkify(fuse3);
fork-split(fuse4);
unforkify(fuse4);
fork-split(fuse5);
unforkify(fuse5);
simpl!(*); simpl!(*);
......
...@@ -14,6 +14,8 @@ fn main() { ...@@ -14,6 +14,8 @@ fn main() {
JunoCompiler::new() JunoCompiler::new()
.file_in_src("edge_detection.jn") .file_in_src("edge_detection.jn")
.unwrap() .unwrap()
.schedule_in_src("cpu.sch")
.unwrap()
.build() .build()
.unwrap(); .unwrap();
} }
macro simpl!(X) {
ccp(X);
simplify-cfg(X);
lift-dc-math(X);
gvn(X);
phi-elim(X);
dce(X);
infer-schedules(X);
}
simpl!(*);
ip-sroa(*);
sroa(*);
simpl!(*);
no-memset(gaussian_smoothing@res);
fixpoint {
forkify(gaussian_smoothing);
fork-guard-elim(gaussian_smoothing);
fork-coalesce(gaussian_smoothing);
}
predication(gaussian_smoothing);
simpl!(gaussian_smoothing);
predication(gaussian_smoothing);
simpl!(gaussian_smoothing);
no-memset(laplacian_estimate@res, laplacian_estimate@shr1, laplacian_estimate@shr2);
fixpoint {
forkify(laplacian_estimate);
fork-guard-elim(laplacian_estimate);
fork-coalesce(laplacian_estimate);
}
simpl!(laplacian_estimate);
no-memset(zero_crossings@res, zero_crossings@shr1, zero_crossings@shr2);
fixpoint {
forkify(zero_crossings);
fork-guard-elim(zero_crossings);
fork-coalesce(zero_crossings);
}
simpl!(zero_crossings);
no-memset(gradient@res);
fixpoint {
forkify(gradient);
fork-guard-elim(gradient);
fork-coalesce(gradient);
}
predication(gradient);
simpl!(gradient);
predication(gradient);
simpl!(gradient);
fixpoint {
forkify(max_gradient);
fork-guard-elim(max_gradient);
fork-coalesce(max_gradient);
}
simpl!(max_gradient);
no-memset(reject_zero_crossings@res);
fixpoint {
forkify(reject_zero_crossings);
fork-guard-elim(reject_zero_crossings);
fork-coalesce(reject_zero_crossings);
}
predication(reject_zero_crossings);
simpl!(reject_zero_crossings);
async-call(edge_detection@le, edge_detection@zc);
fork-split(gaussian_smoothing, laplacian_estimate, zero_crossings, gradient, max_gradient, reject_zero_crossings);
unforkify(gaussian_smoothing, laplacian_estimate, zero_crossings, gradient, max_gradient, reject_zero_crossings);
simpl!(*);
delete-uncalled(*);
gcm(*);
...@@ -2,7 +2,7 @@ fn gaussian_smoothing<n, m, gs : usize>( ...@@ -2,7 +2,7 @@ fn gaussian_smoothing<n, m, gs : usize>(
input: f32[n, m], input: f32[n, m],
filter: f32[gs, gs], filter: f32[gs, gs],
) -> f32[n, m] { ) -> f32[n, m] {
let result : f32[n, m]; @res let result : f32[n, m];
// Define the gaussian radius as half the gaussian size // Define the gaussian radius as half the gaussian size
const gr = gs / 2; const gr = gs / 2;
...@@ -39,12 +39,12 @@ fn laplacian_estimate<n, m, sz: usize>( ...@@ -39,12 +39,12 @@ fn laplacian_estimate<n, m, sz: usize>(
) -> f32[n, m] { ) -> f32[n, m] {
const r = sz / 2; const r = sz / 2;
let result : f32[n, m]; @res let result : f32[n, m];
for row = 0 to n { for row = 0 to n {
for col = 0 to m { for col = 0 to m {
// Copy data for dilation filter // Copy data for dilation filter
let imageArea : f32[sz, sz]; @shr1 let imageArea : f32[sz, sz];
for i = 0 to sz { for i = 0 to sz {
for j = 0 to sz { for j = 0 to sz {
imageArea[i, j] = if row + i < r then MIN_BR imageArea[i, j] = if row + i < r then MIN_BR
...@@ -64,7 +64,7 @@ fn laplacian_estimate<n, m, sz: usize>( ...@@ -64,7 +64,7 @@ fn laplacian_estimate<n, m, sz: usize>(
} }
// Data copy for erotion filter // Data copy for erotion filter
let imageArea : f32[sz, sz]; @shr2 let imageArea : f32[sz, sz];
for i = 0 to sz { for i = 0 to sz {
for j = 0 to sz { for j = 0 to sz {
imageArea[i, j] = if row + i < r then MAX_BR imageArea[i, j] = if row + i < r then MAX_BR
...@@ -97,12 +97,12 @@ fn zero_crossings<n, m, sz: usize>( ...@@ -97,12 +97,12 @@ fn zero_crossings<n, m, sz: usize>(
) -> f32[n, m] { ) -> f32[n, m] {
const r = sz / 2; const r = sz / 2;
let result : f32[n, m]; @res let result : f32[n, m];
for row = 0 to n { for row = 0 to n {
for col = 0 to m { for col = 0 to m {
// Data copy for dilation filter // Data copy for dilation filter
let imageArea : f32[sz, sz]; @shr1 let imageArea : f32[sz, sz];
for i = 0 to sz { for i = 0 to sz {
for j = 0 to sz { for j = 0 to sz {
imageArea[i, j] = if row + i < r then MIN_BR imageArea[i, j] = if row + i < r then MIN_BR
...@@ -124,7 +124,7 @@ fn zero_crossings<n, m, sz: usize>( ...@@ -124,7 +124,7 @@ fn zero_crossings<n, m, sz: usize>(
} }
// Data copy for erotion filter // Data copy for erotion filter
let imageArea : f32[sz, sz]; @shr2 let imageArea : f32[sz, sz];
for i = 0 to sz { for i = 0 to sz {
for j = 0 to sz { for j = 0 to sz {
imageArea[i, j] = if row + i < r then MAX_BR imageArea[i, j] = if row + i < r then MAX_BR
...@@ -160,7 +160,7 @@ fn gradient<n, m, sb: usize>( ...@@ -160,7 +160,7 @@ fn gradient<n, m, sb: usize>(
) -> f32[n, m] { ) -> f32[n, m] {
const sbr = sb / 2; const sbr = sb / 2;
let result : f32[n, m]; @res let result : f32[n, m];
for row = 0 to n { for row = 0 to n {
for col = 0 to m { for col = 0 to m {
...@@ -206,7 +206,7 @@ fn reject_zero_crossings<n, m: usize>( ...@@ -206,7 +206,7 @@ fn reject_zero_crossings<n, m: usize>(
max_gradient: f32, max_gradient: f32,
theta: f32, theta: f32,
) -> f32[n, m] { ) -> f32[n, m] {
let result : f32[n, m]; @res let result : f32[n, m];
for row = 0 to n { for row = 0 to n {
for col = 0 to m { for col = 0 to m {
...@@ -229,10 +229,10 @@ fn edge_detection<n, m, gs, sz, sb: usize>( ...@@ -229,10 +229,10 @@ fn edge_detection<n, m, gs, sz, sb: usize>(
sy: f32[sb, sb], sy: f32[sb, sb],
theta: f32, theta: f32,
) -> f32[n, m] { ) -> f32[n, m] {
let smoothed = gaussian_smoothing::<n, m, gs>(input, gaussian_filter); let smoothed = gaussian_smoothing::<n, m, gs>(input, gaussian_filter);
let laplacian = laplacian_estimate::<n, m, sz>(smoothed, structure); @le let laplacian = laplacian_estimate::<n, m, sz>(smoothed, structure);
let zcs = zero_crossings::<n, m, sz>(laplacian, structure); @zc let zcs = zero_crossings::<n, m, sz>(laplacian, structure);
let gradient = gradient::<n, m, sb>(smoothed, sx, sy); let gradient = gradient::<n, m, sb>(smoothed, sx, sy);
let maxgrad = max_gradient::<n, m>(gradient); let maxgrad = max_gradient::<n, m>(gradient);
return reject_zero_crossings::<n, m>(zcs, gradient, maxgrad, theta); return reject_zero_crossings::<n, m>(zcs, gradient, maxgrad, theta);
} }
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