Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split out IO into separate files #374

Merged
merged 10 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ fn main() {
let cores = num_cpus::get();
let tpcl2 = (cores as f64).log2().floor() as u32;

println!("cargo:rerun-if-changed=src/run.c");
println!("cargo:rerun-if-changed=src/hvm.c");
println!("cargo:rerun-if-changed=src/run.cu");
println!("cargo:rerun-if-changed=src/hvm.cu");

match cc::Build::new()
.file("src/hvm.c")
.file("src/run.c")
.opt_level(3)
.warnings(false)
.define("TPC_L2", &*tpcl2.to_string())
.define("IO", None)
.try_compile("hvm-c") {
Ok(_) => println!("cargo:rustc-cfg=feature=\"c\""),
Err(e) => {
println!("cargo:warning=\x1b[1m\x1b[31mWARNING: Failed to compile hvm.c:\x1b[0m {}", e);
println!("cargo:warning=Ignoring hvm.c and proceeding with build. \x1b[1mThe C runtime will not be available.\x1b[0m");
println!("cargo:warning=\x1b[1m\x1b[31mWARNING: Failed to compile/run.c:\x1b[0m {}", e);
println!("cargo:warning=Ignoring/run.c and proceeding with build. \x1b[1mThe C runtime will not be available.\x1b[0m");
}
}

Expand All @@ -28,7 +31,8 @@ fn main() {

cc::Build::new()
.cuda(true)
.file("src/hvm.cu")
.file("src/run.cu")
.define("IO", None)
.flag("-diag-suppress=177") // variable was declared but never referenced
.flag("-diag-suppress=550") // variable was set but never used
.flag("-diag-suppress=20039") // a __host__ function redeclared with __device__, hence treated as a __host__ __device__ function
Expand Down
4 changes: 2 additions & 2 deletions src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn compile_book(trg: Target, book: &hvm::Book) -> String {
code.push_str(&format!(" u32 fid = get_val(a) & 0xFFFFFFF;\n"));
code.push_str(&format!(" switch (fid) {{\n"));
for (fid, def) in book.defs.iter().enumerate() {
code.push_str(&format!(" case {}: return interact_call_{}(net, tm, a, b);\n", fid, &def.name.replace("/","_").replace(".","_")));
code.push_str(&format!(" case {}: return interact_call_{}(net, tm, a, b);\n", fid, &def.name.replace("/","_").replace(".","_").replace("-","_")));
}
code.push_str(&format!(" default: return FALSE;\n"));
code.push_str(&format!(" }}\n"));
Expand All @@ -36,7 +36,7 @@ pub fn compile_book(trg: Target, book: &hvm::Book) -> String {
// Compiles a single Def.
pub fn compile_def(trg: Target, code: &mut String, book: &hvm::Book, tab: usize, fid: hvm::Val) {
let def = &book.defs[fid as usize];
let fun = &def.name.replace("/","_").replace(".","_");
let fun = &def.name.replace("/","_").replace(".","_").replace("-","_");

// Initializes context
let neo = &mut 0;
Expand Down
Loading
Loading