CUDA 10 adds a set of new APIs for External Resource Interoperability.
The documentation says:
cuImportExternalMemory() imports an external memory object.
If CUDA_EXTERNAL_MEMORY_HANDLE_DESC::type is CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD, then CUDA_EXTERNAL_MEMORY_HANDLE_DESC::handle::fd must be a valid file descriptor referencing a memory object. Ownership of the file descriptor is transferred to the CUDA driver when the handle is imported successfully. Performing any operations on the file descriptor after it is imported results in undefined behavior.
Maps a buffer onto an imported memory object and returns a device pointer in devPtr.
The properties of the buffer being mapped must be described in bufferDesc.
It looked to me these APIs enables to map shared-memory object in operating system,
and expected the mapped device memory can be referenced by multiple processes.
cuImportExternalMemory() gets succeeded to return CUexternalMemory towards POSIX shared-
memory built on /dev/shm, however, cuExternalMemoryGetMappedBuffer() raised cudaErrorInvalidValue
error. It is reproducible even if I used SysV shared memory.
So, I cannot map the device memory which is associated with file-descriptors.
I wonder what a valid file descriptor referencing a memory object means.
Is it a special file built on a particular file-system, not a common purpose interface?
The test program is here: