Function rcudnn_sys::cudaImportExternalMemory[][src]

pub unsafe extern "C" fn cudaImportExternalMemory(
    extMem_out: *mut cudaExternalMemory_t,
    memHandleDesc: *const cudaExternalMemoryHandleDesc
) -> cudaError_t
Expand description

\brief Imports an external memory object

Imports an externally allocated memory object and returns a handle to that in \p extMem_out.

The properties of the handle being imported must be described in \p memHandleDesc. The ::cudaExternalMemoryHandleDesc structure is defined as follows:

\code typedef struct cudaExternalMemoryHandleDesc_st { cudaExternalMemoryHandleType type; union { int fd; struct { void *handle; const void *name; } win32; const void *nvSciBufObject; } handle; unsigned long long size; unsigned int flags; } cudaExternalMemoryHandleDesc; \endcode

where ::cudaExternalMemoryHandleDesc::type specifies the type of handle being imported. ::cudaExternalMemoryHandleType is defined as:

\code typedef enum cudaExternalMemoryHandleType_enum { cudaExternalMemoryHandleTypeOpaqueFd = 1, cudaExternalMemoryHandleTypeOpaqueWin32 = 2, cudaExternalMemoryHandleTypeOpaqueWin32Kmt = 3, cudaExternalMemoryHandleTypeD3D12Heap = 4, cudaExternalMemoryHandleTypeD3D12Resource = 5, cudaExternalMemoryHandleTypeD3D11Resource = 6, cudaExternalMemoryHandleTypeD3D11ResourceKmt = 7, cudaExternalMemoryHandleTypeNvSciBuf = 8 } cudaExternalMemoryHandleType; \endcode

If ::cudaExternalMemoryHandleDesc::type is ::cudaExternalMemoryHandleTypeOpaqueFd, then ::cudaExternalMemoryHandleDesc::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.

If ::cudaExternalMemoryHandleDesc::type is ::cudaExternalMemoryHandleTypeOpaqueWin32, then exactly one of ::cudaExternalMemoryHandleDesc::handle::win32::handle and ::cudaExternalMemoryHandleDesc::handle::win32::name must not be NULL. If ::cudaExternalMemoryHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared NT handle that references a memory object. Ownership of this handle is not transferred to CUDA after the import operation, so the application must release the handle using the appropriate system call. If ::cudaExternalMemoryHandleDesc::handle::win32::name is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a memory object.

If ::cudaExternalMemoryHandleDesc::type is ::cudaExternalMemoryHandleTypeOpaqueWin32Kmt, then ::cudaExternalMemoryHandleDesc::handle::win32::handle must be non-NULL and ::cudaExternalMemoryHandleDesc::handle::win32::name must be NULL. The handle specified must be a globally shared KMT handle. This handle does not hold a reference to the underlying object, and thus will be invalid when all references to the memory object are destroyed.

If ::cudaExternalMemoryHandleDesc::type is ::cudaExternalMemoryHandleTypeD3D12Heap, then exactly one of ::cudaExternalMemoryHandleDesc::handle::win32::handle and ::cudaExternalMemoryHandleDesc::handle::win32::name must not be NULL. If ::cudaExternalMemoryHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared NT handle that is returned by ID3D12Device::CreateSharedHandle when referring to a ID3D12Heap object. This handle holds a reference to the underlying object. If ::cudaExternalMemoryHandleDesc::handle::win32::name is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a ID3D12Heap object.

If ::cudaExternalMemoryHandleDesc::type is ::cudaExternalMemoryHandleTypeD3D12Resource, then exactly one of ::cudaExternalMemoryHandleDesc::handle::win32::handle and ::cudaExternalMemoryHandleDesc::handle::win32::name must not be NULL. If ::cudaExternalMemoryHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared NT handle that is returned by ID3D12Device::CreateSharedHandle when referring to a ID3D12Resource object. This handle holds a reference to the underlying object. If ::cudaExternalMemoryHandleDesc::handle::win32::name is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a ID3D12Resource object.

If ::cudaExternalMemoryHandleDesc::type is ::cudaExternalMemoryHandleTypeD3D11Resource,then exactly one of ::cudaExternalMemoryHandleDesc::handle::win32::handle and ::cudaExternalMemoryHandleDesc::handle::win32::name must not be NULL. If ::cudaExternalMemoryHandleDesc::handle::win32::handle is not NULL, then it must represent a valid shared NT handle that is returned by IDXGIResource1::CreateSharedHandle when referring to a ID3D11Resource object. If ::cudaExternalMemoryHandleDesc::handle::win32::name is not NULL, then it must point to a NULL-terminated array of UTF-16 characters that refers to a ID3D11Resource object.

If ::cudaExternalMemoryHandleDesc::type is ::cudaExternalMemoryHandleTypeD3D11ResourceKmt, then ::cudaExternalMemoryHandleDesc::handle::win32::handle must be non-NULL and ::cudaExternalMemoryHandleDesc::handle::win32::name must be NULL. The handle specified must be a valid shared KMT handle that is returned by IDXGIResource::GetSharedHandle when referring to a ID3D11Resource object.

If ::cudaExternalMemoryHandleDesc::type is ::cudaExternalMemoryHandleTypeNvSciBuf, then ::cudaExternalMemoryHandleDesc::handle::nvSciBufObject must be NON-NULL and reference a valid NvSciBuf object. If the NvSciBuf object imported into CUDA is also mapped by other drivers, then the application must use ::cudaWaitExternalSemaphoresAsync or ::cudaSignalExternalSemaphoresAsync as approprriate barriers to maintain coherence between CUDA and the other drivers.

The size of the memory object must be specified in ::cudaExternalMemoryHandleDesc::size.

Specifying the flag ::cudaExternalMemoryDedicated in ::cudaExternalMemoryHandleDesc::flags indicates that the resource is a dedicated resource. The definition of what a dedicated resource is outside the scope of this extension. This flag must be set if ::cudaExternalMemoryHandleDesc::type is one of the following: ::cudaExternalMemoryHandleTypeD3D12Resource ::cudaExternalMemoryHandleTypeD3D11Resource ::cudaExternalMemoryHandleTypeD3D11ResourceKmt

\param extMem_out - Returned handle to an external memory object \param memHandleDesc - Memory import handle descriptor

\return ::cudaSuccess, ::cudaErrorInvalidResourceHandle \notefnerr \note_init_rt \note_callback

\note If the Vulkan memory imported into CUDA is mapped on the CPU then the application must use vkInvalidateMappedMemoryRanges/vkFlushMappedMemoryRanges as well as appropriate Vulkan pipeline barriers to maintain coherence between CPU and GPU. For more information on these APIs, please refer to “Synchronization and Cache Control” chapter from Vulkan specification.

\sa ::cudaDestroyExternalMemory, ::cudaExternalMemoryGetMappedBuffer, ::cudaExternalMemoryGetMappedMipmappedArray