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

Method prefetch_to_device

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

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

(&self, stream: &Stream, device: &Device)

Source from the content-addressed store, hash-verified

671 /// # }
672 /// ```
673 fn prefetch_to_device(&self, stream: &Stream, device: &Device) -> CudaResult<()> {
674 let slice = self.as_slice();
675 let mem_size = std::mem::size_of_val(slice);
676
677 unsafe {
678 cuda::cuMemPrefetchAsync(
679 slice.as_ptr() as cuda::CUdeviceptr,
680 mem_size,
681 device.as_raw(),
682 stream.as_inner(),
683 )
684 .to_result()?;
685 }
686 Ok(())
687 }
688
689 /// Advises the driver that this memory range is mostly going to be read to, and occasionally written to.
690 ///

Callers

nothing calls this directly

Implementers 1

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

Calls 5

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

Tested by

no test coverage detected