1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//! Zero-copy (host-mapped) memory.
//!
//! Allows GPU kernels to directly access host memory without explicit
//! transfers. Useful for small, frequently-updated data or when PCIe
//! bandwidth is acceptable.
//!
//! # How it works
//!
//! Zero-copy memory is allocated on the host with the
//! `CU_MEMHOSTALLOC_DEVICEMAP` flag, which makes it accessible from GPU
//! kernels via a device pointer obtained from `cuMemHostGetDevicePointer`.
//! The GPU reads/writes traverse the PCIe bus on each access, so this is
//! best suited for data that is accessed infrequently or streamed
//! sequentially.
//!
//! # Status
//!
//! This module is a placeholder. Full implementation is planned for a
//! future release once the `cuMemHostAlloc` and
//! `cuMemHostGetDevicePointer` function pointers are added to
//! `oxicuda-driver`.
use PhantomData;
use ;
use CUdeviceptr;
// ---------------------------------------------------------------------------
// MappedBuffer<T>
// ---------------------------------------------------------------------------
/// A host-allocated, device-mapped (zero-copy) memory buffer.
///
/// The host memory is accessible from both CPU code and GPU kernels.
/// GPU accesses traverse the PCIe bus, making this suitable for small
/// or infrequently-accessed data where the overhead of explicit transfers
/// is not justified.
///
/// # Status
///
/// This type is a placeholder. The allocation method currently returns
/// [`CudaError::NotSupported`].
///
/// TODO: Add `cu_mem_host_alloc` (with `CU_MEMHOSTALLOC_DEVICEMAP`) and
/// `cu_mem_host_get_device_pointer` to `DriverApi`.
// SAFETY: The mapped host memory is not thread-local.
unsafe
unsafe