cuda.core.pack_host_copy_args#
- cuda.core.pack_host_copy_args( ) bytes#
Pack the arguments of
HOST_COPY_FNintouser_databytes.The result is a record of three native-width fields in this order:
uintptr_t dst,uintptr_t src,size_t nbytes, with no padding.struct.pack("@PPN", dst, src, nbytes)builds the same record, andstruct.unpack("@PPN", data)reads one back. A caller that keeps such a record in memory of its own can pass its address as anintuser_datainstead.dstandsrcare not retained. The caller must keep both alive, and must not resize them (abytearray, for example), until the copy has run.- Parameters:
dst (int |
Buffer|collections.abc.Buffer) – The destination. Only anintis a host address. A buffer-protocol object must be contiguous and writable.src (int |
Buffer|collections.abc.Buffer) – The source. Only anintis a host address. A buffer-protocol object must be contiguous.nbytes (int) – The number of bytes to copy. Zero packs a copy that does nothing.
- Returns:
The packed record, to pass as
user_data.- Return type:
- Raises:
TypeError – If
dstorsrcis not anint, aBuffer, or a buffer-protocol object, or is abool, a NumPy integer scalar, or a ctypes scalar such asctypes.c_void_p. A buffer-protocol object that cannot export a contiguous view, or a writable one fordst, raises its own error.ValueError – If
nbytesexceeds the size ofdstorsrc, if aBuffercomes from a memory resource that is not host-accessible, if an address is null, or if the ranges overlap.OverflowError – If
nbytesor anintaddress is negative or does not fit in a native-width field.RuntimeError – If
dstorsrcis a closedBuffer.
Notes
This function makes no CUDA calls, so a Python host callback can call it, for example to fill a record that a later
HOST_COPY_FNreads through anintuser_data. It checks host accessibility only for aBufferwith a memory resource. For anintor aBufferwithout one, the caller must ensure that the memory is host-accessible.