decuda 0.1.1

CUDA to HIP, SYCL, OpenCL, and Rust GPU migration tool — automatic source-code translator for porting CUDA C++ kernels to AMD ROCm HIP, Intel oneAPI SYCL, Khronos OpenCL, and Rust GPU (cust / rust-gpu)
Documentation
//! Rust backend. Generates a `.rs` file that uses the `cust` crate for runtime
//! API calls and either `rust-gpu` (in shaders) or `cust` (host-side) for
//! kernels, depending on how the source is consumed. v1 is host-side only;
//! kernel bodies are commented out and tagged for manual translation.

use crate::ir::TranslationUnit;
use crate::targets::TargetBackend;

pub struct RustBackend;

impl TargetBackend for RustBackend {
    fn banner(&self, _src: &str) -> String {
        "// Generated by decuda.\n\
         // Host-side runtime calls are translated to the `cust` crate. Kernels\n\
         // are emitted as `TODO(decuda)` blocks: rust-gpu translation requires\n\
         // the kernel to be authored as a Rust fn. See `examples/` for a\n\
         // scaffolded SPIR-V kernel module you can flesh out.\n\
         //\n\
         // Add to your Cargo.toml:\n\
         //   [dependencies]\n\
         //   cust = \"0.3\"\n\n"
            .to_string()
    }

    fn emit(&self, unit: &TranslationUnit) -> String {
        crate::emit::emit(crate::cli::Target::Rust, self, unit)
    }
}