Skip to content
Open
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ default = []
# C and CUDA features are determined during build
c = []
cuda = []
hip = []

[dev-dependencies]
insta = { version = "1.39.0", features = ["glob"] }
12 changes: 12 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ fn main() {
println!("cargo:rerun-if-changed=src/hvm.c");
println!("cargo:rerun-if-changed=src/run.cu");
println!("cargo:rerun-if-changed=src/hvm.cu");
println!("cargo:rerun-if-changed=src/run.hip");
println!("cargo:rerun-if-changed=src/hvm.hip");
println!("cargo:rustc-link-arg=-rdynamic");

match cc::Build::new()
Expand Down Expand Up @@ -41,6 +43,16 @@ fn main() {

println!("cargo:rustc-cfg=feature=\"cuda\"");
}
else if std::process::Command::new("hipcc").arg("--version").stdout(std::process::Stdio::null()).stderr(std::process::Stdio::null()).status().is_ok() {
std::env::set_var("CXX", "hipcc");
cc::Build::new()
.cpp(true)
.file("src/run.hip")
.define("IO", None)
.flag("-w") // Tempararily supress all warnings as some cannot be supressed individually TODO : Actually fix the warnings
.compile("hvm-rocm");
println!("cargo:rustc-cfg=feature=\"hip\"");
}
else {
println!("cargo:warning=\x1b[1m\x1b[31mWARNING: CUDA compiler not found.\x1b[0m \x1b[1mHVM will not be able to run on GPU.\x1b[0m");
}
Expand Down
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RUSTFLAGS="-C linker=hipcc" cargo build
21 changes: 21 additions & 0 deletions src/hip_check.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef HIP_ASSERT_H
#define HIP_ASSERT_H

#define __HIP_PLATFORM_AMD__
#include <iostream>


#define HIP_CHECK(expression) \
{ \
const hipError_t status = expression; \
if(status != hipSuccess){ \
std::cerr << "HIP error " \
<< status << ": " \
<< hipGetErrorString(status) \
<< " at " << __FILE__ << ":" \
<< __LINE__ << std::endl; \
} \
}


#endif
Loading