diff options
-rw-r--r-- | CONTRIBUTING.md | 18 | ||||
-rw-r--r-- | Cargo.toml | 3 | ||||
-rw-r--r-- | README.md | 25 | ||||
-rw-r--r-- | level_zero-sys/build.rs | 13 | ||||
-rw-r--r-- | level_zero-sys/lib/ze_loader.lib (renamed from level_zero-sys/src/ze_loader.lib) | bin | 75668 -> 75668 bytes | |||
-rw-r--r-- | zluda/Cargo.toml | 1 | ||||
-rw-r--r-- | zluda/build.rs | 39 | ||||
-rw-r--r-- | zluda/lib/OpenCL.lib | bin | 0 -> 28824 bytes | |||
-rw-r--r-- | zluda_inject/Cargo.toml | 2 | ||||
-rw-r--r-- | zluda_inject/src/main.rs | 4 | ||||
-rw-r--r-- | zluda_lib/Cargo.toml | 12 | ||||
-rw-r--r-- | zluda_lib/README.md | 1 | ||||
-rw-r--r-- | zluda_lib/src/lib.rs | 3 |
13 files changed, 79 insertions, 42 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..fe467d1 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,18 @@ +## Dependencies
+
+Development builds of ZLUDA requires following dependencies:
+
+* CMake
+* Python 3
+
+Additionally repository have to be clone with Git submodules initalized. If you cloned the repo without initalizing submodules, do this:
+```
+git submodule update --init --recursive
+```
+
+## Tests
+
+Tests should be executed with `--workspace` option to test non-default targets:
+```
+cargo test --workspace
+```
@@ -6,11 +6,14 @@ members = [ "level_zero",
"spirv_tools-sys",
"zluda",
+ "zluda_lib",
"zluda_inject",
"zluda_redirect",
"ptx",
]
+default-members = ["zluda_lib", "zluda_inject", "zluda_redirect"]
+
[patch.crates-io]
rspirv = { git = 'https://github.com/vosen/rspirv', rev = '40f5aa4dedb0d9f1ec24bdd8b6019e01996d1d74' }
spirv_headers = { git = 'https://github.com/vosen/rspirv', rev = '40f5aa4dedb0d9f1ec24bdd8b6019e01996d1d74' }
\ No newline at end of file @@ -33,13 +33,13 @@ Overall in this suite of benchmarks faster by approximately 4% on ZLUDA. ## Details * Is ZLUDA a drop-in replacement for CUDA?\ - Yes, but certain applications use CUDA in ways which make it incompatible with ZLUDA. - * What is the status of the project\ + Yes, but certain applications use CUDA in ways which make it incompatible with ZLUDA + * What is the status of the project?\ This project is a Proof of Concept. About the only thing that works currently is Geekbench (and not even completely). It's amazingly buggy and incomplete. You should not rely on it for anything serious * Is it an Intel project? Is it an NVIDIA project?\ No, it's a private project * What is the performance?\ - Performance can be clode to the performance of similarly written OpenCL code (see GeekBench results in the previous section). NVIDIA GPUs and Intel GPUs have different architecture and feature set. Consequently, certain NVIDIA features have to be emulated in ZLUDA with performance penalty. Additionally, performance of ZLUDA will be always lower than the performance of code specifically optimized for Intel GPUs + Performance can be close to the performance of similarly written OpenCL code (see GeekBench results in the previous section). NVIDIA GPUs and Intel GPUs have different architecture and feature set. Consequently, certain NVIDIA features have to be emulated in ZLUDA with performance penalty. Additionally, performance of ZLUDA will be always lower than the performance of code specifically optimized for Intel GPUs * How it's different from AMD HIP or Intel DPC++ Compatibility toolkit?\ Both are porting toolkits which require programmer's effort to port applications to the API in question. With ZLUDA existing applications "just work" on an Intel GPU (if you are lucky and ZLUDA supports the particular subset of CUDA) * Which Intel GPU are supported?\ @@ -52,11 +52,11 @@ Overall in this suite of benchmarks faster by approximately 4% on ZLUDA. **Warning**: this is a very incomplete Proof of Concept. It's probably not going to work with your application. ZLUDA currently works only with applications which use CUDA Driver API. Linux builds also work with applications which use statically-linked CUDA Runtime API ### Windows -You should have the most recent GPU drivers installed.\ +You should have the most recent Intel GPU drivers installed.\ Copy `nvcuda.dll` to the application directory (the directory where .exe file is) and launch it normally ### Linux -A very recent version of [compute-runtime](https://github.com/intel/compute-runtime) is required. At the time of the writing 20.45.18403 is the recommended version. +A very recent version of [compute-runtime](https://github.com/intel/compute-runtime) and [Level Zero loader](https://github.com/oneapi-src/level-zero/releases) is required. At the time of the writing 20.45.18403 is the losest recommended version. Unpack the archive somewhere and run your application like this: ``` LD_LIBRARY_PATH=<PATH_TO_THE_DIRECTORY_WITH_ZLUDA_PROVIDED_LIBCUDA> <YOUR_APPLICATION> @@ -66,9 +66,20 @@ LD_LIBRARY_PATH=<PATH_TO_THE_DIRECTORY_WITH_ZLUDA_PROVIDED_LIBCUDA> <YOUR_APPLIC You should have a relatively recent version of Rust installed, then you just do: ``` -cargo build +cargo build --release ``` -in the main directory of the project +in the main directory of the project. +### Linux +If you are building on Linux you must also symlink (or rename) the ZLUDA output library: +``` +ln -s libnvcuda.so target/release/libcuda.so +ln -s libcuda.so target/release/libcuda.so.1 +``` + +## Contributing + +If you want to develop ZLUDA itself, read [CONTRIBUTING.md](CONTRIBUTING.md), it contains instructions how to set up dependencies and run tests + ## License diff --git a/level_zero-sys/build.rs b/level_zero-sys/build.rs index 4a638ec..0d2488c 100644 --- a/level_zero-sys/build.rs +++ b/level_zero-sys/build.rs @@ -1,18 +1,17 @@ use env::VarError; use std::{env, path::PathBuf}; -fn main() -> Result<(), VarError> { +fn main() -> Result<(), VarError> { println!("cargo:rustc-link-lib=dylib=ze_loader"); - if env::var("CARGO_CFG_WINDOWS").is_ok() { + if cfg!(windows) { let env = env::var("CARGO_CFG_TARGET_ENV")?; - if env == "gnu" { - println!("cargo:rustc-link-search=native=C:\\Windows\\System32"); - } else { + if env == "msvc" { let mut path = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?); - path.push("src"); + path.push("lib"); println!("cargo:rustc-link-search=native={}", path.display()); + } else { + println!("cargo:rustc-link-search=native=C:\\Windows\\System32"); }; } - println!("cargo:rerun-if-changed=build.rs"); Ok(()) } diff --git a/level_zero-sys/src/ze_loader.lib b/level_zero-sys/lib/ze_loader.lib Binary files differindex 661240c..661240c 100644 --- a/level_zero-sys/src/ze_loader.lib +++ b/level_zero-sys/lib/ze_loader.lib diff --git a/zluda/Cargo.toml b/zluda/Cargo.toml index 218fe8f..52a3445 100644 --- a/zluda/Cargo.toml +++ b/zluda/Cargo.toml @@ -6,7 +6,6 @@ edition = "2018" [lib] name = "zluda" -crate-type = ["cdylib"] [dependencies] ptx = { path = "../ptx" } diff --git a/zluda/build.rs b/zluda/build.rs index 3b8999f..94c2c6f 100644 --- a/zluda/build.rs +++ b/zluda/build.rs @@ -1,27 +1,20 @@ +use env::VarError;
+use std::{env, path::PathBuf};
+
// HACK ALERT
-// This buidl script has been copy-pasted from cl-sys to avoid CUDA libraries
-// overriding path to OpenCL
+// This is a temporary hack to to make sure that linker does not pick up
+// NVIDIA OpenCL .lib using paths injected by cl-sys
- fn main() {
+fn main() -> Result<(), VarError> {
if cfg!(windows) {
- let known_sdk = [
- // E.g. "c:\Program Files (x86)\Intel\OpenCL SDK\lib\x86\"
- ("INTELOCLSDKROOT", "x64", "x86"),
- // E.g. "c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\Win32\"
- ("CUDA_PATH", "x64", "Win32"),
- // E.g. "C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86\"
- ("AMDAPPSDKROOT", "x86_64", "x86"),
- ];
-
- for info in known_sdk.iter() {
- if let Ok(sdk) = std::env::var(info.0) {
- let mut path = std::path::PathBuf::from(sdk);
- path.push("lib");
- path.push(if cfg!(target_arch="x86_64") { info.1 } else { info.2 });
- println!("cargo:rustc-link-search=native={}", path.display());
- }
- }
-
- println!("cargo:rustc-link-search=native=C:\\Program Files (x86)\\OCL_SDK_Light\\lib\\x86_64");
+ let env = env::var("CARGO_CFG_TARGET_ENV")?;
+ if env == "msvc" {
+ let mut path = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
+ path.push("lib");
+ println!("cargo:rustc-link-search=native={}", path.display());
+ } else {
+ println!("cargo:rustc-link-search=native=C:\\Windows\\System32");
+ };
}
-}
\ No newline at end of file + Ok(())
+}
diff --git a/zluda/lib/OpenCL.lib b/zluda/lib/OpenCL.lib Binary files differnew file mode 100644 index 0000000..2b766ee --- /dev/null +++ b/zluda/lib/OpenCL.lib diff --git a/zluda_inject/Cargo.toml b/zluda_inject/Cargo.toml index 8f1cde5..193c36e 100644 --- a/zluda_inject/Cargo.toml +++ b/zluda_inject/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Andrzej Janik <[email protected]>"] edition = "2018" [[bin]] -name = "zluda" +name = "zluda_with" path = "src/main.rs" [target.'cfg(windows)'.dependencies] diff --git a/zluda_inject/src/main.rs b/zluda_inject/src/main.rs index f8c1921..201802b 100644 --- a/zluda_inject/src/main.rs +++ b/zluda_inject/src/main.rs @@ -4,10 +4,8 @@ mod win; #[cfg(target_os = "windows")]
mod bin;
-use std::error::Error;
-
#[cfg(target_os = "windows")]
-fn main() -> Result<(), Box<dyn Error>> {
+fn main() -> Result<(), Box<dyn std::error::Error>> {
bin::main_impl()
}
diff --git a/zluda_lib/Cargo.toml b/zluda_lib/Cargo.toml new file mode 100644 index 0000000..54a2d53 --- /dev/null +++ b/zluda_lib/Cargo.toml @@ -0,0 +1,12 @@ +[package]
+name = "zluda_lib"
+version = "0.0.0"
+authors = ["Andrzej Janik <[email protected]>"]
+edition = "2018"
+
+[lib]
+name = "nvcuda"
+crate-type = ["cdylib"]
+
+[dependencies]
+zluda = { path = "../zluda" }
diff --git a/zluda_lib/README.md b/zluda_lib/README.md new file mode 100644 index 0000000..a544147 --- /dev/null +++ b/zluda_lib/README.md @@ -0,0 +1 @@ +This project exist solely as a workaround, to make sure that ZLUDA-created CUDA driver does not clash with real CUDA driver when running unit tests
\ No newline at end of file diff --git a/zluda_lib/src/lib.rs b/zluda_lib/src/lib.rs new file mode 100644 index 0000000..2022614 --- /dev/null +++ b/zluda_lib/src/lib.rs @@ -0,0 +1,3 @@ +pub extern crate zluda;
+
+pub use zluda::*;
\ No newline at end of file |