mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-04-19 16:04:44 +00:00
Improve build procedure and instructions (#28)
Fixes issues pointed out in #27: * spirv_tools-sys was build in non-test profiles * By default ZLUDA dll has a wrong name * We relied on third-party OpenCL installation on Windows * We encouraged building debug configuration * We didn't provide build information for developers (cmake, python, submodules)
This commit is contained in:
parent
2c0e9b912f
commit
078ae20c2c
13 changed files with 79 additions and 42 deletions
18
CONTRIBUTING.md
Normal file
18
CONTRIBUTING.md
Normal file
|
@ -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' }
|
25
README.md
25
README.md
|
@ -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
|
||||
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ edition = "2018"
|
|||
|
||||
[lib]
|
||||
name = "zluda"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
ptx = { path = "../ptx" }
|
||||
|
|
|
@ -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");
|
||||
};
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
BIN
zluda/lib/OpenCL.lib
Normal file
BIN
zluda/lib/OpenCL.lib
Normal file
Binary file not shown.
|
@ -5,7 +5,7 @@ authors = ["Andrzej Janik <vosen@vosen.pl>"]
|
|||
edition = "2018"
|
||||
|
||||
[[bin]]
|
||||
name = "zluda"
|
||||
name = "zluda_with"
|
||||
path = "src/main.rs"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
12
zluda_lib/Cargo.toml
Normal file
12
zluda_lib/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "zluda_lib"
|
||||
version = "0.0.0"
|
||||
authors = ["Andrzej Janik <vosen@vosen.pl>"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
name = "nvcuda"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
zluda = { path = "../zluda" }
|
1
zluda_lib/README.md
Normal file
1
zluda_lib/README.md
Normal file
|
@ -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
|
3
zluda_lib/src/lib.rs
Normal file
3
zluda_lib/src/lib.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub extern crate zluda;
|
||||
|
||||
pub use zluda::*;
|
Loading…
Add table
Reference in a new issue