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
//! OpenCL backend. Produces an .cl source file. Note that the host code (the
//! `cudaMalloc` etc. wrappers) is *also* emitted for reference, with an
//! additional comment block encouraging the user to convert it to
//! clCreateBuffer / clEnqueue* calls.

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

pub struct OpenClBackend;

impl TargetBackend for OpenClBackend {
    fn banner(&self, _src: &str) -> String {
        "// Generated by decuda.\n\
         // OpenCL device code is the bulk of this file. The host-side calls\n\
         // (`cudaXxx`) have been rewritten to OpenCL equivalents inline; the\n\
         // surrounding host program still needs a cl_context + cl_queue, not\n\
         // included here. Look for TODO(decuda) markers for items requiring\n\
         // manual attention.\n\n"
            .to_string()
    }

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