Skip to content
Snippets Groups Projects
Commit f65599a3 authored by Aaron Councilman's avatar Aaron Councilman
Browse files

Example of using features

parent 743bc32e
No related branches found
No related tags found
1 merge request!211Conditional schedules
Pipeline #201989 passed
use juno_build::JunoCompiler;
fn main() {
#[cfg(not(feature = "cuda"))]
{
JunoCompiler::new()
.file_in_src("matmul.jn")
.unwrap()
.schedule_in_src("cpu.sch")
.unwrap()
.build()
.unwrap();
}
#[cfg(feature = "cuda")]
{
JunoCompiler::new()
.file_in_src("matmul.jn")
.unwrap()
.schedule_in_src("gpu.sch")
.unwrap()
.build()
.unwrap();
}
JunoCompiler::new()
.file_in_src("matmul.jn")
.unwrap()
.schedule_in_src("matmul.sch")
.unwrap()
.build()
.unwrap();
}
macro optimize!(X) {
gvn(X);
phi-elim(X);
dce(X);
ip-sroa(X);
sroa(X);
dce(X);
gvn(X);
phi-elim(X);
dce(X);
}
macro codegen-prep!(X) {
optimize!(X);
gcm(X);
float-collections(X);
dce(X);
gcm(X);
}
macro forkify!(X) {
fixpoint {
forkify(X);
fork-guard-elim(X);
}
}
macro fork-tile![n](X) {
fork-tile[n, 0, false, true](X);
}
macro parallelize!(X) {
parallel-fork(X);
parallel-reduce(X);
}
macro unforkify!(X) {
fork-split(X);
unforkify(X);
}
optimize!(*);
forkify!(*);
if feature("cuda") {
fixpoint {
reduce-slf(*);
slf(*);
infer-schedules(*);
}
fork-coalesce(*);
infer-schedules(*);
dce(*);
rewrite(*);
fixpoint {
simplify-cfg(*);
dce(*);
}
optimize!(*);
codegen-prep!(*);
} else {
associative(matmul@outer);
// Parallelize by computing output array as 16 chunks
let par = matmul@outer \ matmul@inner;
fork-tile![4](par);
let (outer, inner, _) = fork-reshape[[1, 3], [0], [2]](par);
parallelize!(outer \ inner);
let body = outline(inner);
cpu(body);
// Tile for cache, assuming 64B cache lines
fork-tile![16](body);
let (outer, inner) = fork-reshape[[0, 2, 4, 1, 3], [5]](body);
reduce-slf(inner);
unforkify!(body);
codegen-prep!(*);
}
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