@@ -65,13 +65,16 @@ Before we can write any GPU kernels, we must add a few directives to our `lib.rs
6565 feature(register_attr),
6666 register_attr(nvvm_internal)
6767)]
68+
69+ use cuda_std :: * ;
6870```
6971
7072This does a couple of things:
7173- It only applies the attributes if we are compiling the crate for the GPU (target_os = "cuda").
7274- It declares the crate to be ` no_std ` on CUDA targets.
7375- It registers a special attribute required by the codegen for things like figuring out
7476what functions are GPU kernels.
77+ - It explicitly includes ` kernel ` macro and ` thread `
7578
7679If you would like to use ` alloc ` or things like printing from GPU kernels (which requires alloc) then you need to declare ` alloc ` too:
7780
@@ -191,6 +194,20 @@ static PTX: &str = include_str!("some/path.ptx");
191194
192195Then execute it using cust.
193196
197+ Don't forget to include the current ` rust-toolchain ` in the top of your project:
198+
199+ ``` toml
200+ # If you see this, run `rustup self update` to get rustup 1.23 or newer.
201+
202+ # NOTE: above comment is for older `rustup` (before TOML support was added),
203+ # which will treat the first line as the toolchain name, and therefore show it
204+ # to the user in the error, instead of "error: invalid channel name '[toolchain]'".
205+
206+ [toolchain ]
207+ channel = " nightly-2021-12-04"
208+ components = [" rust-src" , " rustc-dev" , " llvm-tools-preview" ]
209+ ```
210+
194211## Docker
195212
196213There is also a [ Dockerfile] ( Dockerfile ) prepared as a quickstart with all the necessary libraries for base cuda development.
0 commit comments