fn main() {
println!("cargo:rerun-if-changed=src/optimized_kernels.cu");
#[cfg(feature = "cuda")]
{
let cuda_path = std::env::var("CUDA_PATH")
.or_else(|_| std::env::var("CUDA_HOME"))
.unwrap_or_else(|_| "/usr/local/cuda".to_string());
println!("cargo:rustc-link-search=native={}/lib64", cuda_path);
println!("cargo:rustc-link-lib=cudart");
println!("cargo:rustc-link-lib=cublas");
cc::Build::new()
.cuda(true)
.flag("-arch=sm_70") .flag("-gencode=arch=compute_70,code=sm_70")
.flag("-gencode=arch=compute_75,code=sm_75")
.flag("-gencode=arch=compute_80,code=sm_80")
.flag("-gencode=arch=compute_86,code=sm_86")
.flag("--use_fast_math")
.flag("-O3")
.file("src/optimized_kernels.cu")
.compile("ghostflow_cuda_kernels");
println!("cargo:warning=Compiled CUDA kernels successfully");
}
#[cfg(not(feature = "cuda"))]
{
println!("cargo:warning=Building without CUDA support - GPU operations will use CPU fallback");
}
}