def host_to_device(dst, src, size, stream=0):
 varargs = []
 if stream:
  assert isinstance(stream, Stream)
  fn = driver.cuMemcpyHtoDAsync
  varargs.append(stream.handle)
 else:
  fn = driver.cuMemcpyHtoD
 fn(device_pointer(dst), host_pointer(src), size, *varargs)

def host_to_device ( dst , src , size , stream = 0 ) : varargs = [ ] if stream : assert isinstance ( stream , Stream ) fn = driver . cuMemcpyHtoDAsync varargs . append ( stream . handle ) else : fn = driver . cuMemcpyHtoD fn ( device_pointer ( dst ) , host_pointer ( src ) , size , * varargs )
note: the underlying data pointer from the host data buffer is used and it should not be changed until the operation which can be asynchronous completes .