inducer/pycuda — pull request #43 by seibert (2014-02-18 04:19:26+00:00)
Title: Support for creating numpy arrays with CUDA 6 managed memory

This is basic support and documentation for the "Unified Memory" programming model added in CUDA 6.

New managed_{empty,zeros,empty_like,zeros_like}() methods allocate numpy arrays backed by managed memory allocations that can be directly used by GPU kernels without explicit memory copies and without the slow performance of zero-copy pagelocked host memory access.

The kernel launch interface is also updated to allow a numpy array backed by a ManagedAllocation to be passed directly as a kernel argument.

The major caveat with this feature is that the managed memory concurrency rules imposed by the CUDA driver are very unforgiving. Any host access to a managed array while it is visible to an actively executing CUDA stream/context results in a segmentation fault, just like any other access to forbidden host memory. This offers no opportunity to recover, throw a Python exception, etc. Given the already experimental nature of managed memory, I think this is acceptable.