cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
ipc.hpp File Reference

wrappers for CUDA's facilities for sharing on-device memory addresses and CUDA events between host processes (Inter- Process Communication) More...

#include "context.hpp"
#include "types.hpp"
#include "error.hpp"
#include <string>
Include dependency graph for ipc.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  cuda::memory::ipc::imported_ptr_t
 A smart-pointer-like class for memory obtained via inter-process communication. More...
 

Namespaces

 cuda
 Definitions and functionality wrapping CUDA APIs.
 
 cuda::memory
 Representation, allocation and manipulation of CUDA-related memory, of different.
 
 cuda::event
 CUDA timing functionality, via events and their related code (not including the event wrapper type event_t itself)
 
 cuda::event::ipc
 Definitions and functionality related to CUDA events (not including the event wrapper type event_t itself)
 

Typedefs

using cuda::memory::ipc::ptr_handle_t = CUipcMemHandle
 The concrete value passed between processes, used to tell the CUDA Runtime API which memory area is desired.
 
using cuda::event::ipc::handle_t = CUipcEventHandle
 The concrete value passed between processes, used to tell the CUDA Runtime API which event is desired. More...
 

Functions

imported_ptr_t cuda::memory::ipc::wrap (void *ptr, bool owning) noexcept
 Construct an instance of our wrapper class for IPC-imported memory from a raw pointer to the mapping.
 
ptr_handle_t cuda::memory::ipc::export_ (void *device_ptr)
 Obtain a handle for a region of on-device memory which can be transmitted for use in another operating system process. More...
 
imported_ptr_t cuda::memory::ipc::import (const ptr_handle_t &ptr_handle)
 Import memory from another process, given the appropriate handle.
 
handle_t cuda::event::ipc::export_ (const event_t &event)
 Enable use of an event which this process created by other processes. More...
 
event_t cuda::event::ipc::import (const device_t &device, const handle_t &event_ipc_handle)
 Obtain a proper CUDA event, corresponding to an event created by another process, using a handle communicated via operating-system inter-process communications. More...
 
event_t cuda::event::ipc::import (const context_t &context, const handle_t &event_ipc_handle)
 

Detailed Description

wrappers for CUDA's facilities for sharing on-device memory addresses and CUDA events between host processes (Inter- Process Communication)

CUDA addresses into device memory are not valid across different host processes - somewhat, but not entirely, similarly to the case of host memory addresses. Still, there is no reason why different processes should not be able to interact with the same on-device memory region. The same is also true for other entities, such as streams and events.

CUDA provides several functions to enable different processes to share at least memory addresses and events, which are wrapped here. In addition to the free-standing functions, the class cuda::memory::ipc::imported_ptr_t is defined, usable by receiving processes as an 'adapter' to incoming handles which may be passed as-is to code requiring a proper pointer.

Function Documentation

◆ export_()

ptr_handle_t cuda::memory::ipc::export_ ( void *  device_ptr)
inline

Obtain a handle for a region of on-device memory which can be transmitted for use in another operating system process.

Note
The name contains an underscore so as not to clash with the C++ reserved word export
Parameters
device_ptrbeginning of the region of memory to be shared with other processes
Returns
a handle which another process can call detail_::import() on to obtain a device pointer it can use