use decuda::cli::Target;
use decuda::cuda_db;
fn main() {
let target = std::env::args_os()
.nth(1)
.map(|s| s.to_string_lossy().into_owned())
.filter(|s| !s.is_empty());
let db = cuda_db::database();
let want = target.as_deref();
println!("decuda knows {} CUDA API entries.\n", db.len());
for (name, info) in db {
let line = match want {
Some("hip") => format!("{name:<32} hip={}", fmt_opt(info.hip)),
Some("sycl") => format!("{name:<32} sycl={}", fmt_opt(info.sycl)),
Some("rust") => format!("{name:<32} rust={}", fmt_opt(info.rust)),
Some("opencl") => format!("{name:<32} opencl={}", fmt_opt(info.opencl)),
_ => format!(
"{name:<32} hip={} sycl={} rust={} opencl={}",
fmt_opt(info.hip),
fmt_opt(info.sycl),
fmt_opt(info.rust),
fmt_opt(info.opencl),
),
};
println!("{line}");
}
let t = match want {
Some("hip") => Some(Target::Hip),
Some("sycl") => Some(Target::Sycl),
Some("rust") => Some(Target::Rust),
Some("opencl") => Some(Target::Opencl),
_ => None,
};
if let Some(t) = t {
let supported = db.values().filter(|info| info.supports(t)).count();
println!("\n{supported} entries have an automatic mapping for {t:?}.");
}
}
fn fmt_opt(o: Option<&str>) -> String {
match o {
Some(s) => s.to_string(),
None => "(none)".to_string(),
}
}