1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Procedural macros for compiling CUDA source and generating typed Singe kernel launch modules.
use TokenStream;
/// Compiles CUDA source with `nvcc` and generates a typed kernel-launch module.
///
/// The macro expects a module declaration containing a CUDA source file, exported
/// kernel names, optional header files, and optional compiler arguments:
///
/// ```ignore
/// cuda_module! {
/// pub mod kernels {
/// source: "kernels/add.cu",
/// exports: [add_kernel],
/// headers: ["kernels/common.cuh"],
/// compile: {
/// nvcc_args: ["--std=c++17"],
/// nvrtc_args: ["--std=c++17"],
/// },
/// }
/// }
/// ```
///
/// Expansion runs `nvcc`, using the surrounding CUDA environment including
/// `CUDA_CCBIN` when set, parses the resulting PTX with `singe-ptx`, and emits a
/// Rust module with a `create` constructor plus typed wrappers for exported
/// kernels. Syntax errors, missing files, `nvcc` failures, unsupported PTX, and
/// exports mismatches are reported as compile-time errors.