Skip to content

Commit

Permalink
Fix guide book to mention rust-toolchain and small build fix (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
jac-cbi authored Jul 1, 2022
1 parent b8127c7 commit 8a6cb73
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions guide/src/guide/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,16 @@ Before we can write any GPU kernels, we must add a few directives to our `lib.rs
feature(register_attr),
register_attr(nvvm_internal)
)]

use cuda_std::*;
```

This does a couple of things:
- It only applies the attributes if we are compiling the crate for the GPU (target_os = "cuda").
- It declares the crate to be `no_std` on CUDA targets.
- It registers a special attribute required by the codegen for things like figuring out
what functions are GPU kernels.
- It explicitly includes `kernel` macro and `thread`

If you would like to use `alloc` or things like printing from GPU kernels (which requires alloc) then you need to declare `alloc` too:

Expand Down Expand Up @@ -191,6 +194,20 @@ static PTX: &str = include_str!("some/path.ptx");

Then execute it using cust.

Don't forget to include the current `rust-toolchain` in the top of your project:

```toml
# If you see this, run `rustup self update` to get rustup 1.23 or newer.

# NOTE: above comment is for older `rustup` (before TOML support was added),
# which will treat the first line as the toolchain name, and therefore show it
# to the user in the error, instead of "error: invalid channel name '[toolchain]'".

[toolchain]
channel = "nightly-2021-12-04"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
```

## Docker

There is also a [Dockerfile](Dockerfile) prepared as a quickstart with all the necessary libraries for base cuda development.
Expand Down

0 comments on commit 8a6cb73

Please sign in to comment.