You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lot of names are used sometimes with backticks, sometimes without.
This commit removes backticks where necessary for these:
- rustc
- rust-gpu (which will become "Rust GPU" in a subsequent commit)
And adds backticks where necessary for these:
- rustc_codegen_*
- cuda_builder
- cuda_std
- lib.rs
Copy file name to clipboardExpand all lines: guide/src/faq.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -153,13 +153,13 @@ things to gain in terms of safety using Rust.
153
153
The reasoning for this is the same reasoning as to why you would use CUDA over opengl/vulkan compute shaders:
154
154
- CUDA usually outperforms shaders if kernels are written well and launch configurations are optimal.
155
155
- CUDA has many useful features such as shared memory, unified memory, graphs, fine grained thread control, streams, the PTX ISA, etc.
156
-
- rust-gpu does not perform many optimizations, and with rustc_codegen_ssa's less than ideal codegen, the optimizations by LLVM and libNVVM are needed.
156
+
- rust-gpu does not perform many optimizations, and with `rustc_codegen_ssa`'s less than ideal codegen, the optimizations by LLVM and libNVVM are needed.
157
157
- SPIR-V is arguably still not suitable for serious GPU kernel codegen, it is underspecced, complex, and does not mention many things which are needed.
158
158
While libNVVM (which uses a well documented subset of LLVM IR) and the PTX ISA are very thoroughly documented/specified.
159
159
- rust-gpu is primarily focused on graphical shaders, compute shaders are secondary, which the rust ecosystem needs, but it also
160
160
needs a project 100% focused on computing, and computing only.
161
161
- SPIR-V cannot access many useful CUDA libraries such as OptiX, cuDNN, cuBLAS, etc.
162
-
- SPIR-V debug info is still very young and rust-gpu cannot generate it. While rustc_codegen_nvvm does, which can be used
162
+
- SPIR-V debug info is still very young and rust-gpu cannot generate it. While `rustc_codegen_nvvm` does, which can be used
163
163
for profiling kernels in something like nsight compute.
164
164
165
165
Moreover, CUDA is the primary tool used in big computing industries such as VFX and scientific computing. Therefore
Copy file name to clipboardExpand all lines: guide/src/guide/getting_started.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ Where `XX` is the latest version of `cuda_std`.
60
60
We changed our crate's crate types to `cdylib` and `rlib`. We specified `cdylib` because the nvptx targets do not support binary crate types.
61
61
`rlib` is so that we will be able to use the crate as a dependency, such as if we would like to use it on the CPU.
62
62
63
-
## lib.rs
63
+
## `lib.rs`
64
64
65
65
Before we can write any GPU kernels, we must add a few directives to our `lib.rs` which are required by the codegen:
66
66
@@ -88,7 +88,7 @@ If you would like to use `alloc` or things like printing from GPU kernels (which
88
88
externcrate alloc;
89
89
```
90
90
91
-
Finally, if you would like to use types such as slices or arrays inside of GPU kernels you must allow `improper_cytypes_definitions` either on the whole crate or the individual GPU kernels. This is because on the CPU, such types are not guaranteed to be passed a certain way, so they should not be used in `extern "C"` functions (which is what kernels are implicitly declared as). However, `rustc_codegen_nvvm` guarantees the way in which things like structs, slices, and arrays are passed. See [Kernel ABI](./kernel_abi.md).
91
+
Finally, if you would like to use types such as slices or arrays inside of GPU kernels you must allow `improper_ctypes_definitions` either on the whole crate or the individual GPU kernels. This is because on the CPU, such types are not guaranteed to be passed a certain way, so they should not be used in `extern "C"` functions (which is what kernels are implicitly declared as). However, `rustc_codegen_nvvm` guarantees the way in which things like structs, slices, and arrays are passed. See [Kernel ABI](./kernel_abi.md).
92
92
93
93
```rs
94
94
#![allow(improper_ctypes_definitions)]
@@ -173,7 +173,7 @@ To use it you can simply add it as a build dependency in your CPU crate (the cra
173
173
+cuda_builder = "XX"
174
174
```
175
175
176
-
Where `XX` is the current version of cuda_builder.
176
+
Where `XX` is the current version of `cuda_builder`.
177
177
178
178
Then, you can simply invoke it in the build.rs of your CPU crate:
Copy file name to clipboardExpand all lines: guide/src/nvvm/backends.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Custom Rustc Backends
2
2
3
-
Before we get into the details of rustc_codegen_nvvm, we obviously need to explain what a codegen is!
3
+
Before we get into the details of `rustc_codegen_nvvm`, we obviously need to explain what a codegen is!
4
4
5
5
Custom codegens are rustc's answer to "well what if I want rust to compile to X?". This is a problem
6
6
that comes up in many situations, especially conversations of "well LLVM cannot target this, so we are screwed".
@@ -15,22 +15,22 @@ Nowadays, Rustc is almost fully decoupled from LLVM and it is instead generic ov
15
15
Rustc instead uses a system of codegen backends that implement traits and then get loaded as dynamically linked libraries.
16
16
This allows rust to compile to virtually anything with a surprisingly small amount of work. At the time of writing, there are
17
17
five publicly known codegens that exist:
18
-
- rustc_codegen_cranelift
19
-
- rustc_codegen_llvm
20
-
- rustc_codegen_gcc
21
-
- rustc_codegen_spirv
22
-
- rustc_codegen_nvvm, obviously the best codegen ;)
18
+
-`rustc_codegen_cranelift`
19
+
-`rustc_codegen_llvm`
20
+
-`rustc_codegen_gcc`
21
+
-`rustc_codegen_spirv`
22
+
-`rustc_codegen_nvvm`, obviously the best codegen ;)
23
23
24
24
`rustc_codegen_cranelift` targets the cranelift backend, which is a codegen backend written in rust that is faster than LLVM but does not have many optimizations
25
25
compared to LLVM. `rustc_codegen_llvm` is obvious, it is the backend almost everybody uses which targets LLVM. `rustc_codegen_gcc` targets GCC (GNU Compiler Collection)
26
26
which is able to target more exotic targets than LLVM, especially for embedded. `rustc_codegen_spirv` targets the SPIR-V (Standard Portable Intermediate Representation 5)
27
27
format, which is a format mostly used for compiling shader languages such as GLSL or WGSL to a standard representation that Vulkan/OpenGL can use, the reasons
28
-
why SPIR-V is not an alternative to CUDA/rustc_codegen_nvvm have been covered in the [FAQ](../../faq.md).
28
+
why SPIR-V is not an alternative to CUDA/`rustc_codegen_nvvm` have been covered in the [FAQ](../../faq.md).
29
29
30
30
Finally, we come to the star of the show, `rustc_codegen_nvvm`. This backend targets NVVM IR for compiling rust to GPU kernels that can be run by CUDA.
31
31
What NVVM IR/libNVVM are has been covered in the [CUDA section](../../cuda/pipeline.md).
32
32
33
-
# rustc_codegen_ssa
33
+
# `rustc_codegen_ssa`
34
34
35
35
`rustc_codegen_ssa` is the central crate behind every single codegen and does much of the hard work.
36
36
It abstracts away the MIR lowering logic so that custom codegens only have to implement some
0 commit comments