Skip to content

Commit eaa6204

Browse files
kjetilkjekaKjetil
andauthored
Feat: Add memcpy_dtoh to cust (#47)
to allow users of cust to also copy memory from device to host Co-authored-by: Kjetil <[email protected]>
1 parent 6bd2d84 commit eaa6204

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

crates/cust/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Notable changes to this project will be documented in this file.
44

5+
## Unreleased
6+
7+
- Add `memory::memcpy_dtoh` to allow copying from device to host.
8+
59
## 0.3.2 - 2/16/22
610

711
- Fixed `ModuleJitOptions` not working (due to cursed reasons).

crates/cust/src/memory/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,17 @@ pub unsafe fn memcpy_htod(
214214
Ok(())
215215
}
216216

217+
/// Simple wrapper over cuMemcpyDtoH_v2
218+
#[allow(clippy::missing_safety_doc)]
219+
pub unsafe fn memcpy_dtoh(
220+
d_ptr: *mut c_void,
221+
src_ptr: cust_raw::CUdeviceptr,
222+
size: usize,
223+
) -> CudaResult<()> {
224+
crate::sys::cuMemcpyDtoH_v2(d_ptr, src_ptr, size).to_result()?;
225+
Ok(())
226+
}
227+
217228
/// Get the current free and total memory.
218229
///
219230
/// Returns in `.1` the total amount of memory available to the the current context.

0 commit comments

Comments
 (0)