Skip to content

Commit 078ae20

Browse files
authored
Improve build procedure and instructions (vosen#28)
Fixes issues pointed out in vosen#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)
1 parent 2c0e9b9 commit 078ae20

File tree

13 files changed

+79
-42
lines changed

13 files changed

+79
-42
lines changed

CONTRIBUTING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Dependencies
2+
3+
Development builds of ZLUDA requires following dependencies:
4+
5+
* CMake
6+
* Python 3
7+
8+
Additionally repository have to be clone with Git submodules initalized. If you cloned the repo without initalizing submodules, do this:
9+
```
10+
git submodule update --init --recursive
11+
```
12+
13+
## Tests
14+
15+
Tests should be executed with `--workspace` option to test non-default targets:
16+
```
17+
cargo test --workspace
18+
```

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ members = [
66
"level_zero",
77
"spirv_tools-sys",
88
"zluda",
9+
"zluda_lib",
910
"zluda_inject",
1011
"zluda_redirect",
1112
"ptx",
1213
]
1314

15+
default-members = ["zluda_lib", "zluda_inject", "zluda_redirect"]
16+
1417
[patch.crates-io]
1518
rspirv = { git = 'https://github.com/vosen/rspirv', rev = '40f5aa4dedb0d9f1ec24bdd8b6019e01996d1d74' }
1619
spirv_headers = { git = 'https://github.com/vosen/rspirv', rev = '40f5aa4dedb0d9f1ec24bdd8b6019e01996d1d74' }

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ Overall in this suite of benchmarks faster by approximately 4% on ZLUDA.
3333
## Details
3434

3535
* Is ZLUDA a drop-in replacement for CUDA?\
36-
Yes, but certain applications use CUDA in ways which make it incompatible with ZLUDA.
37-
* What is the status of the project\
36+
Yes, but certain applications use CUDA in ways which make it incompatible with ZLUDA
37+
* What is the status of the project?\
3838
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
3939
* Is it an Intel project? Is it an NVIDIA project?\
4040
No, it's a private project
4141
* What is the performance?\
42-
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
42+
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
4343
* How it's different from AMD HIP or Intel DPC++ Compatibility toolkit?\
4444
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)
4545
* Which Intel GPU are supported?\
@@ -52,11 +52,11 @@ Overall in this suite of benchmarks faster by approximately 4% on ZLUDA.
5252
**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
5353

5454
### Windows
55-
You should have the most recent GPU drivers installed.\
55+
You should have the most recent Intel GPU drivers installed.\
5656
Copy `nvcuda.dll` to the application directory (the directory where .exe file is) and launch it normally
5757

5858
### Linux
59-
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.
59+
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.
6060
Unpack the archive somewhere and run your application like this:
6161
```
6262
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
6666
You should have a relatively recent version of Rust installed, then you just do:
6767

6868
```
69-
cargo build
69+
cargo build --release
7070
```
71-
in the main directory of the project
71+
in the main directory of the project.
72+
### Linux
73+
If you are building on Linux you must also symlink (or rename) the ZLUDA output library:
74+
```
75+
ln -s libnvcuda.so target/release/libcuda.so
76+
ln -s libcuda.so target/release/libcuda.so.1
77+
```
78+
79+
## Contributing
80+
81+
If you want to develop ZLUDA itself, read [CONTRIBUTING.md](CONTRIBUTING.md), it contains instructions how to set up dependencies and run tests
82+
7283

7384
## License
7485

level_zero-sys/build.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
use env::VarError;
22
use std::{env, path::PathBuf};
33

4-
fn main() -> Result<(), VarError> {
4+
fn main() -> Result<(), VarError> {
55
println!("cargo:rustc-link-lib=dylib=ze_loader");
6-
if env::var("CARGO_CFG_WINDOWS").is_ok() {
6+
if cfg!(windows) {
77
let env = env::var("CARGO_CFG_TARGET_ENV")?;
8-
if env == "gnu" {
9-
println!("cargo:rustc-link-search=native=C:\\Windows\\System32");
10-
} else {
8+
if env == "msvc" {
119
let mut path = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
12-
path.push("src");
10+
path.push("lib");
1311
println!("cargo:rustc-link-search=native={}", path.display());
12+
} else {
13+
println!("cargo:rustc-link-search=native=C:\\Windows\\System32");
1414
};
1515
}
16-
println!("cargo:rerun-if-changed=build.rs");
1716
Ok(())
1817
}
File renamed without changes.

zluda/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ edition = "2018"
66

77
[lib]
88
name = "zluda"
9-
crate-type = ["cdylib"]
109

1110
[dependencies]
1211
ptx = { path = "../ptx" }

zluda/build.rs

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
1+
use env::VarError;
2+
use std::{env, path::PathBuf};
3+
14
// HACK ALERT
2-
// This buidl script has been copy-pasted from cl-sys to avoid CUDA libraries
3-
// overriding path to OpenCL
5+
// This is a temporary hack to to make sure that linker does not pick up
6+
// NVIDIA OpenCL .lib using paths injected by cl-sys
47

5-
fn main() {
8+
fn main() -> Result<(), VarError> {
69
if cfg!(windows) {
7-
let known_sdk = [
8-
// E.g. "c:\Program Files (x86)\Intel\OpenCL SDK\lib\x86\"
9-
("INTELOCLSDKROOT", "x64", "x86"),
10-
// E.g. "c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\Win32\"
11-
("CUDA_PATH", "x64", "Win32"),
12-
// E.g. "C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86\"
13-
("AMDAPPSDKROOT", "x86_64", "x86"),
14-
];
15-
16-
for info in known_sdk.iter() {
17-
if let Ok(sdk) = std::env::var(info.0) {
18-
let mut path = std::path::PathBuf::from(sdk);
19-
path.push("lib");
20-
path.push(if cfg!(target_arch="x86_64") { info.1 } else { info.2 });
21-
println!("cargo:rustc-link-search=native={}", path.display());
22-
}
23-
}
24-
25-
println!("cargo:rustc-link-search=native=C:\\Program Files (x86)\\OCL_SDK_Light\\lib\\x86_64");
10+
let env = env::var("CARGO_CFG_TARGET_ENV")?;
11+
if env == "msvc" {
12+
let mut path = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
13+
path.push("lib");
14+
println!("cargo:rustc-link-search=native={}", path.display());
15+
} else {
16+
println!("cargo:rustc-link-search=native=C:\\Windows\\System32");
17+
};
2618
}
27-
}
19+
Ok(())
20+
}

zluda/lib/OpenCL.lib

28.1 KB
Binary file not shown.

zluda_inject/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Andrzej Janik <[email protected]>"]
55
edition = "2018"
66

77
[[bin]]
8-
name = "zluda"
8+
name = "zluda_with"
99
path = "src/main.rs"
1010

1111
[target.'cfg(windows)'.dependencies]

zluda_inject/src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ mod win;
44
#[cfg(target_os = "windows")]
55
mod bin;
66

7-
use std::error::Error;
8-
97
#[cfg(target_os = "windows")]
10-
fn main() -> Result<(), Box<dyn Error>> {
8+
fn main() -> Result<(), Box<dyn std::error::Error>> {
119
bin::main_impl()
1210
}
1311

0 commit comments

Comments
 (0)