-
Notifications
You must be signed in to change notification settings - Fork 13.3k
document some existing unstable features #41135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+123
−4
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,59 @@ | ||
# `abi_ptx` | ||
|
||
The tracking issue for this feature is: None. | ||
The tracking issue for this feature | ||
is: [38788](https://github.com/rust-lang/rust/issues/38788) | ||
|
||
------------------------ | ||
|
||
When emitting PTX code, all vanilla Rust functions (`fn`) get translated to | ||
"device" functions. These functions are *not* callable from the host via the | ||
CUDA API so a crate with only device functions is not too useful! | ||
|
||
OTOH, "global" functions *can* be called by the host; you can think of them | ||
as the real public API of your crate. To produce a global function use the | ||
`"ptx-kernel"` ABI. | ||
|
||
<!-- NOTE(ignore) this example is specific to the nvptx targets --> | ||
|
||
``` rust,ignore | ||
#![feature(abi_ptx)] | ||
#![no_std] | ||
|
||
pub unsafe extern "ptx-kernel" fn global_function() { | ||
device_function(); | ||
} | ||
|
||
pub fn device_function() { | ||
// .. | ||
} | ||
``` | ||
|
||
``` text | ||
$ xargo rustc --target nvptx64-nvidia-cuda --release -- --emit=asm | ||
|
||
$ cat $(find -name '*.s') | ||
// | ||
// Generated by LLVM NVPTX Back-End | ||
// | ||
|
||
.version 3.2 | ||
.target sm_20 | ||
.address_size 64 | ||
|
||
// .globl _ZN6kernel15global_function17h46111ebe6516b382E | ||
|
||
.visible .entry _ZN6kernel15global_function17h46111ebe6516b382E() | ||
{ | ||
|
||
|
||
ret; | ||
} | ||
|
||
// .globl _ZN6kernel15device_function17hd6a0e4993bbf3f78E | ||
.visible .func _ZN6kernel15device_function17hd6a0e4993bbf3f78E() | ||
{ | ||
|
||
|
||
ret; | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,35 @@ | ||
# `compiler_builtins_lib` | ||
|
||
This feature is internal to the Rust compiler and is not intended for general use. | ||
The tracking issue for this feature is: None. | ||
|
||
------------------------ | ||
|
||
This feature is required to link to the `compiler_builtins` crate which contains | ||
"compiler intrinsics". Compiler intrinsics are software implementations of basic | ||
operations like multiplication of `u64`s. These intrinsics are only required on | ||
platforms where these operations don't directly map to a hardware instruction. | ||
|
||
You should never need to explicitly link to the `compiler_builtins` crate when | ||
building "std" programs as `compiler_builtins` is already in the dependency | ||
graph of `std`. But you may need it when building `no_std` **binary** crates. If | ||
you get a *linker* error like: | ||
|
||
``` text | ||
$PWD/src/main.rs:11: undefined reference to `__aeabi_lmul' | ||
$PWD/src/main.rs:11: undefined reference to `__aeabi_uldivmod' | ||
``` | ||
|
||
That means that you need to link to this crate. | ||
|
||
When you link to this crate, make sure it only appears once in your crate | ||
dependency graph. Also, it doesn't matter where in the dependency graph, you | ||
place the `compiler_builtins` crate. | ||
|
||
<!-- NOTE(ignore) doctests don't support `no_std` binaries --> | ||
|
||
``` rust,ignore | ||
#![feature(compiler_builtins_lib)] | ||
#![no_std] | ||
|
||
extern crate compiler_builtins; | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# `compiler_builtins` | ||
|
||
The tracking issue for this feature is: None. | ||
This feature is internal to the Rust compiler and is not intended for general use. | ||
|
||
------------------------ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a standard form for this stuff, like this: https://github.com/rust-lang/rust/pull/41135/files#diff-d6ab7d3e772d67c4944af27d29e229cdR3
mind changing this to be identical? Thanks 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing. 😄