| 333 | /// This dotfile can be turned into an image with graphviz. |
| 334 | #[cfg(any(windows, unix))] |
| 335 | pub fn dump_debug_dotfile<P: AsRef<Path>>(&mut self, path: P) -> CudaResult<()> { |
| 336 | // not currently present in cuda-driver-sys for some reason |
| 337 | extern "C" { |
| 338 | fn cuGraphDebugDotPrint( |
| 339 | hGraph: cuda::CUgraph, |
| 340 | path: *const c_char, |
| 341 | flags: c_uint, |
| 342 | ) -> cuda::CUresult; |
| 343 | } |
| 344 | |
| 345 | let path = path.as_ref(); |
| 346 | let mut buf = Vec::new(); |
| 347 | #[cfg(unix)] |
| 348 | { |
| 349 | use std::os::unix::ffi::OsStrExt; |
| 350 | buf.extend(path.as_os_str().as_bytes()); |
| 351 | buf.push(0); |
| 352 | } |
| 353 | |
| 354 | #[cfg(windows)] |
| 355 | { |
| 356 | use std::os::windows::ffi::OsStrExt; |
| 357 | buf.extend( |
| 358 | path.as_os_str() |
| 359 | .encode_wide() |
| 360 | .chain(Some(0)) |
| 361 | .map(|b| { |
| 362 | let b = b.to_ne_bytes(); |
| 363 | b.get(0).copied().into_iter().chain(b.get(1).copied()) |
| 364 | }) |
| 365 | .flatten(), |
| 366 | ); |
| 367 | } |
| 368 | |
| 369 | unsafe { cuGraphDebugDotPrint(self.raw, "./out.dot\0".as_ptr().cast(), 1 << 0).to_result() } |
| 370 | } |
| 371 | |
| 372 | /// Adds a kernel invocation node to this graph, [`KernelInvocation`] can be created using |
| 373 | /// [`kernel_invocation`] which uses the same syntax as [`launch`](crate::launch). This will |