3 The tracking issue for this feature is: [#38788]
5 [#38788]: https://github.com/rust-lang/rust/issues/38788
7 ------------------------
9 When emitting PTX code, all vanilla Rust functions (`fn`) get translated to
10 "device" functions. These functions are *not* callable from the host via the
11 CUDA API so a crate with only device functions is not too useful!
13 OTOH, "global" functions *can* be called by the host; you can think of them
14 as the real public API of your crate. To produce a global function use the
17 <!-- NOTE(ignore) this example is specific to the nvptx targets -->
23 pub unsafe extern "ptx-kernel" fn global_function() {
27 pub fn device_function() {
33 $ xargo rustc --target nvptx64-nvidia-cuda --release -- --emit=asm
35 $ cat $(find -name '*.s')
37 // Generated by LLVM NVPTX Back-End
44 // .globl _ZN6kernel15global_function17h46111ebe6516b382E
46 .visible .entry _ZN6kernel15global_function17h46111ebe6516b382E()
53 // .globl _ZN6kernel15device_function17hd6a0e4993bbf3f78E
54 .visible .func _ZN6kernel15device_function17hd6a0e4993bbf3f78E()