MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / prefetch_to_host

Method prefetch_to_host

crates/cust/src/memory/unified.rs:636–650  ·  view source on GitHub ↗

Advises the driver to enqueue an operation on the stream to prefetch the memory to the CPU. This will cause the driver to fetch the data back to the CPU as soon as the operation is reached on the stream. The CPU must have the attribute [`DeviceAttribute::ConcurrentManagedAccess`]. # Example ```no_run # fn main() -> Result<(), Box > { # let _context = cust::quick_init().unw

(&self, stream: &Stream)

Source from the content-addressed store, hash-verified

634 /// # }
635 /// ```
636 fn prefetch_to_host(&self, stream: &Stream) -> CudaResult<()> {
637 let slice = self.as_slice();
638 let mem_size = std::mem::size_of_val(slice);
639
640 unsafe {
641 cuda::cuMemPrefetchAsync(
642 slice.as_ptr() as cuda::CUdeviceptr,
643 mem_size,
644 -1, // CU_DEVICE_CPU #define
645 stream.as_inner(),
646 )
647 .to_result()?;
648 }
649 Ok(())
650 }
651
652 /// Advises the driver to enqueue an operation on the stream to prefetch the memory to a certain GPU.
653 /// This will cause the driver to fetch the data to the specified device as soon as the operation

Callers

nothing calls this directly

Implementers 1

unified.rscrates/cust/src/memory/unified.rs

Calls 4

as_ptrMethod · 0.80
as_sliceMethod · 0.45
to_resultMethod · 0.45
as_innerMethod · 0.45

Tested by

no test coverage detected