diff --git a/crates/cust/CHANGELOG.md b/crates/cust/CHANGELOG.md index 540182a8..af5aa2b9 100644 --- a/crates/cust/CHANGELOG.md +++ b/crates/cust/CHANGELOG.md @@ -2,6 +2,10 @@ Notable changes to this project will be documented in this file. +## Unreleased + + - Add `memory::memcpy_dtoh` to allow copying from device to host. + ## 0.3.2 - 2/16/22 - Fixed `ModuleJitOptions` not working (due to cursed reasons). diff --git a/crates/cust/src/memory/mod.rs b/crates/cust/src/memory/mod.rs index 43fa2dd7..c0639e13 100644 --- a/crates/cust/src/memory/mod.rs +++ b/crates/cust/src/memory/mod.rs @@ -214,6 +214,17 @@ pub unsafe fn memcpy_htod( Ok(()) } +/// Simple wrapper over cuMemcpyDtoH_v2 +#[allow(clippy::missing_safety_doc)] +pub unsafe fn memcpy_dtoh( + d_ptr: *mut c_void, + src_ptr: cust_raw::CUdeviceptr, + size: usize, +) -> CudaResult<()> { + crate::sys::cuMemcpyDtoH_v2(d_ptr, src_ptr, size).to_result()?; + Ok(()) +} + /// Get the current free and total memory. /// /// Returns in `.1` the total amount of memory available to the the current context.