Start converting host code to HIP

This commit is contained in:
Andrzej Janik 2021-08-27 17:27:48 +00:00
parent 9631a8d242
commit 4ae7feb93a
10 changed files with 5806 additions and 0 deletions

View file

@ -2,6 +2,7 @@
members = [
"detours-sys",
"hip_runtime-sys",
"level_zero-sys",
"level_zero",
"spirv_tools-sys",

View file

@ -77,6 +77,7 @@ If you are building on Linux you must also symlink (or rename) the ZLUDA output
```
ln -s libnvcuda.so target/release/libcuda.so
ln -s libcuda.so target/release/libcuda.so.1
ln -s libnvidia-ml.so target/release/libnvml.so
```
## Contributing

View file

@ -0,0 +1,8 @@
[package]
name = "hip_runtime-sys"
version = "0.0.0"
authors = ["Andrzej Janik <vosen@vosen.pl>"]
edition = "2018"
links = "amdhip"
[lib]

2
hip_runtime-sys/README Normal file
View file

@ -0,0 +1,2 @@
bindgen include/hip_runtime_api.h -o src/hip_runtime_api.rs --no-layout-tests --size_t-is-usize --default-enum-style=newtype --whitelist-function "hip.*" --whitelist-type "hip.*" -- -I/opt/rocm/include
sed -i 's/pub struct hipError_t/#[must_use]\npub struct hipError_t/g' src/hip_runtime_api.rs

7
hip_runtime-sys/build.rs Normal file
View file

@ -0,0 +1,7 @@
use std::env::VarError;
fn main() -> Result<(), VarError> {
println!("cargo:rustc-link-lib=dylib=amdhip64");
println!("cargo:rustc-link-search=/opt/rocm/lib/");
Ok(())
}

View file

@ -0,0 +1,2 @@
#define __HIP_PLATFORM_HCC__
#include <hip/hip_runtime_api.h>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,3 @@
#![allow(warnings)]
pub mod hip_runtime_api;
pub use hip_runtime_api::*;

View file

@ -9,6 +9,7 @@ name = "zluda"
[dependencies]
ptx = { path = "../ptx" }
hip_runtime-sys = { path = "../hip_runtime-sys" }
lazy_static = "1.4"
num_enum = "0.4"
lz4-sys = "1.9"

View file

@ -265,6 +265,7 @@ impl GlobalState {
}
pub fn init() -> Result<(), CUresult> {
eprintln!("{:?}", unsafe { hip_runtime_sys::hipInit(0) });
let mut global_state = GLOBAL_STATE
.lock()
.map_err(|_| CUresult::CUDA_ERROR_UNKNOWN)?;