From 8a6cb734d21d5582052fa5b38089d1aa0f4d582f Mon Sep 17 00:00:00 2001 From: jac-cbi <61760310+jac-cbi@users.noreply.github.com> Date: Fri, 1 Jul 2022 17:05:30 -0400 Subject: [PATCH] Fix guide book to mention `rust-toolchain` and small build fix (#76) --- guide/src/guide/getting_started.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/guide/src/guide/getting_started.md b/guide/src/guide/getting_started.md index 9764c4c..eb4ea1e 100644 --- a/guide/src/guide/getting_started.md +++ b/guide/src/guide/getting_started.md @@ -65,6 +65,8 @@ 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: @@ -72,6 +74,7 @@ This does a couple of things: - 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: @@ -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.