| 139 | class HostDeviceMem: |
| 140 | """Pair of host and device memory, where the host memory is wrapped in a numpy array""" |
| 141 | def __init__(self, size: int, dtype: np.dtype): |
| 142 | nbytes = size * dtype.itemsize |
| 143 | host_mem = cuda_call(cudart.cudaMallocHost(nbytes)) |
| 144 | pointer_type = ctypes.POINTER(np.ctypeslib.as_ctypes_type(dtype)) |
| 145 | |
| 146 | self._host = np.ctypeslib.as_array(ctypes.cast(host_mem, pointer_type), (size,)) |
| 147 | self._device = cuda_call(cudart.cudaMalloc(nbytes)) |
| 148 | self._nbytes = nbytes |
| 149 | |
| 150 | @property |
| 151 | def host(self) -> np.ndarray: |