Skip to content

Commit 69f7f3a

Browse files
nnethercoteLegNeato
authored andcommitted
Be consistent with backticks.
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
1 parent 7bea804 commit 69f7f3a

File tree

10 files changed

+25
-25
lines changed

10 files changed

+25
-25
lines changed

guide/src/SUMMARY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
- [The CUDA Toolkit](cuda/README.md)
1313
- [GPU Computing](cuda/gpu_computing.md)
1414
- [The CUDA Pipeline](cuda/pipeline.md)
15-
- [rustc_codegen_nvvm](nvvm/README.md)
15+
- [`rustc_codegen_nvvm`](nvvm/README.md)
1616
- [Custom Rustc Backends](nvvm/backends.md)
17-
- [rustc_codegen_nvvm](nvvm/nvvm.md)
17+
- [`rustc_codegen_nvvm`](nvvm/nvvm.md)
1818
- [Types](nvvm/types.md)
1919
- [PTX Generation](nvvm/ptxgen.md)
2020
- [Debugging](nvvm/debugging.md)

guide/src/cuda/gpu_computing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ AMD GPUs with OpenCL, since OpenCL is generally slower, clunkier, and lacks libr
2323

2424
# Why Rust?
2525

26-
Rust is a great choice for GPU programming, however, it has needed a kickstart, which is what rustc_codegen_nvvm tries to
26+
Rust is a great choice for GPU programming, however, it has needed a kickstart, which is what `rustc_codegen_nvvm` tries to
2727
accomplish; The initial hurdle of getting Rust to compile to something CUDA can run is over, now comes the design and
2828
polish part.
2929

guide/src/faq.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ things to gain in terms of safety using Rust.
153153
The reasoning for this is the same reasoning as to why you would use CUDA over opengl/vulkan compute shaders:
154154
- CUDA usually outperforms shaders if kernels are written well and launch configurations are optimal.
155155
- 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.
157157
- 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.
158158
While libNVVM (which uses a well documented subset of LLVM IR) and the PTX ISA are very thoroughly documented/specified.
159159
- rust-gpu is primarily focused on graphical shaders, compute shaders are secondary, which the rust ecosystem needs, but it also
160160
needs a project 100% focused on computing, and computing only.
161161
- 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
163163
for profiling kernels in something like nsight compute.
164164
165165
Moreover, CUDA is the primary tool used in big computing industries such as VFX and scientific computing. Therefore

guide/src/guide/getting_started.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Where `XX` is the latest version of `cuda_std`.
6060
We changed our crate's crate types to `cdylib` and `rlib`. We specified `cdylib` because the nvptx targets do not support binary crate types.
6161
`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.
6262

63-
## lib.rs
63+
## `lib.rs`
6464

6565
Before we can write any GPU kernels, we must add a few directives to our `lib.rs` which are required by the codegen:
6666

@@ -88,7 +88,7 @@ If you would like to use `alloc` or things like printing from GPU kernels (which
8888
extern crate alloc;
8989
```
9090

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).
9292

9393
```rs
9494
#![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
173173
+cuda_builder = "XX"
174174
```
175175

176-
Where `XX` is the current version of cuda_builder.
176+
Where `XX` is the current version of `cuda_builder`.
177177

178178
Then, you can simply invoke it in the build.rs of your CPU crate:
179179

guide/src/guide/kernel_abi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ other ABI we override purely to avoid footguns.
1515

1616
Functions marked as `#[kernel]` are enforced to be `extern "C"` by the kernel macro, and it is expected
1717
that __all__ GPU kernels be `extern "C"`, not that you should be declaring any kernels without the `#[kernel]` macro,
18-
because the codegen/cuda_std is allowed to rely on the behavior of `#[kernel]` for correctness.
18+
because the codegen/`cuda_std` is allowed to rely on the behavior of `#[kernel]` for correctness.
1919

2020
## Structs
2121

guide/src/nvvm/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# rustc_codegen_nvvm
1+
# `rustc_codegen_nvvm`
22

3-
This section will cover the more technical details of how rustc_codegen_nvvm works
3+
This section will cover the more technical details of how `rustc_codegen_nvvm` works
44
as well as the issues that came with it.
55

66
It will also explain some technical details about CUDA/PTX/etc, it is not necessarily
7-
limited to rustc_codegen_nvvm.
7+
limited to `rustc_codegen_nvvm`.
88

99
Basic knowledge of how rustc and LLVM work and what they do is assumed. You can find
1010
info about rustc in the [rustc dev guide](https://rustc-dev-guide.rust-lang.org/).

guide/src/nvvm/backends.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Custom Rustc Backends
22

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!
44

55
Custom codegens are rustc's answer to "well what if I want rust to compile to X?". This is a problem
66
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
1515
Rustc instead uses a system of codegen backends that implement traits and then get loaded as dynamically linked libraries.
1616
This allows rust to compile to virtually anything with a surprisingly small amount of work. At the time of writing, there are
1717
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 ;)
2323

2424
`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
2525
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)
2626
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)
2727
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).
2929

3030
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.
3131
What NVVM IR/libNVVM are has been covered in the [CUDA section](../../cuda/pipeline.md).
3232

33-
# rustc_codegen_ssa
33+
# `rustc_codegen_ssa`
3434

3535
`rustc_codegen_ssa` is the central crate behind every single codegen and does much of the hard work.
3636
It abstracts away the MIR lowering logic so that custom codegens only have to implement some

guide/src/nvvm/nvvm.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# rustc_codegen_nvvm
1+
# `rustc_codegen_nvvm`
22

33
At the highest level, our codegen workflow goes like this:
44

@@ -14,7 +14,7 @@ Source code -> Typechecking -> MIR -> SSA Codegen -> LLVM IR (NVVM IR) -> PTX ->
1414
Before we do anything, rustc does its normal job, it typechecks, converts everything to MIR, etc. Then,
1515
rustc loads our codegen shared lib and invokes it to codegen the MIR. It creates an instance of
1616
`NvvmCodegenBackend` and it invokes `codegen_crate`. You could do anything inside `codegen_crate` but
17-
we just defer back to rustc_codegen_ssa and tell it to do the job for us:
17+
we just defer back to `rustc_codegen_ssa` and tell it to do the job for us:
1818

1919
```rs
2020
fn codegen_crate<'tcx>(

guide/src/nvvm/ptxgen.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ important one is libdevice, libdevice is essentially a bitcode module containing
6161
that nvidia provides for us. You can find it as a `.bc` file in the libdevice folder inside your NVVM install location.
6262
Every function inside of it is prefixed with `__nv_`, you can find docs for it [here](https://docs.nvidia.com/cuda/libdevice-users-guide/index.html).
6363

64-
We declare these intrinsics inside of `ctx_intrinsics.rs` and link to them inside cuda_std. We also use them to codegen
64+
We declare these intrinsics inside of `ctx_intrinsics.rs` and link to them inside `cuda_std`. We also use them to codegen
6565
a lot of intrinsics inside `intrinsic.rs`, such as `sqrtf32`.
6666

6767
libdevice is also lazy loaded so we do not import useless intrinsics.

guide/src/nvvm/types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Types! who doesn't love types, especially those that cause libNVVM to randomly s
44
Anyways, types are an integral part of the codegen and everything revolves around them and you will see them everywhere.
55

66
`rustc_codegen_ssa` does not actually tell you what your type representation should be, it allows you to decide. For
7-
example, `rust-gpu` represents it as a `SpirvType` enum, while both `rustc_codegen_llvm` and our codegen represent it as
7+
example, rust-gpu represents it as a `SpirvType` enum, while both `rustc_codegen_llvm` and our codegen represent it as
88
opaque LLVM types:
99

1010
```rs
@@ -13,7 +13,7 @@ type Type = &'ll llvm::Type;
1313

1414
`llvm::Type` is an opaque type that comes from llvm-c. `'ll` is one of the main lifetimes you will see
1515
throughout the whole codegen, it is used for anything that lasts as long as the current usage of LLVM.
16-
LLVM gives you back pointers when you ask for a type or value, some time ago rustc_codegen_llvm fully switched to using
16+
LLVM gives you back pointers when you ask for a type or value, some time ago `rustc_codegen_llvm` fully switched to using
1717
references over pointers, and we follow in their footsteps.
1818

1919
One important fact about types is that they are opaque, you cannot take a type and ask "is this X struct?",

0 commit comments

Comments
 (0)