api/transport_registry.cpp¶
Namespaces¶
| Name |
|---|
| cvedia |
| cvedia::rt API for controlling the server and lifecycle management of runtime instances. |
| cvedia::rt::api |
| cvedia::rt::api::transport |
Functions¶
| Name | |
|---|---|
| void | registerTransportPlugin(std::unique_ptr< TransportPlugin > plugin) |
| void | declareSupportForUri(std::string const & pluginId, std::string const & transportUri, std::string const & pluginDescription ="", bool isZeroCopy =true, PluginKind kind =PluginKind::Other) |
| std::optional< std::string > | identifyDevice(void * handle, NativeHandleType type) |
| bool | isSamePhysicalDevice(std::string const & uri1, std::string const & uri2) Check if two transport URIs refer to the same physical device. |
| std::vector< std::string > | getTransportUrisForDevice(std::string const & anyUri) Get all transport URIs for a physical device. |
| std::vector< std::string > | getAvailableSchemes() Get all available transport schemes. |
| std::vector< TransportInfo > | getAllTransports() Get all registered transports. |
| std::vector< TransportInfo > | getTransportsForScheme(std::string const & scheme, std::string const & targetInteropScheme ="") Get transports for a specific scheme. |
| std::vector< std::string > | getPluginsSupportingUri(std::string const & uri) Get plugins supporting a transport URI. |
| std::vector< PluginSupport > | getPluginSupportForUri(std::string const & uri) Get full plugin-support entries (id + kind + description + zeroCopy) for a URI. |
| std::string | getPluginDescription(std::string const & pluginId) Get description for a plugin ID. |
| bool | isZeroCopySupport(std::string const & uri, std::string const & pluginId) Check if a plugin supports a transport URI with zero-copy. |
| void | declareBackendHandlesScheme(std::string const & backendName, std::string const & scheme) Declare buffer backend handles a transport scheme. |
| void | declareSchemeInterop(std::string const & backendName, std::string const & sourceScheme, std::string const & targetScheme, bool requiresSameDevice) Declare interop capability between two transport schemes. |
| bool | isValidTransportUri(std::string const & transportUri) Check if transport URI is valid and registered. |
| std::optional< std::string > | getUriScheme(std::string const & transportUri) Extract scheme from transport URI. |
| std::optional< std::string > | getBackendForUri(std::string const & transportUri) Get buffer backend for a transport URI. |
| std::vector< std::pair< std::string, std::string > > | getInteropPaths(std::string const & sourceUri) Get interop paths available from a transport URI. |
| std::shared_ptr< void > | createNativeContext(std::string const & transportUri, NativeHandleType type) |
| void | setNativeContext(std::string const & transportUri, NativeHandleType type, std::shared_ptr< void > handle) |
| void | clearNativeContext(std::string const & transportUri, NativeHandleType type) |
| std::recursive_mutex & | nativeContextMutex(std::string const & transportUri) Serialize all access to the single shared native context for a URI. |
| std::mutex & | nativeSubmissionMutex(std::string const & transportUri) Serialize native API command submission across plugin modules. |
Functions Documentation¶
function registerTransportPlugin¶
void registerTransportPlugin(
std::unique_ptr< TransportPlugin > plugin
)
function declareSupportForUri¶
void declareSupportForUri(
std::string const & pluginId,
std::string const & transportUri,
std::string const & pluginDescription ="",
bool isZeroCopy =true,
PluginKind kind =PluginKind::Other
)
function identifyDevice¶
std::optional< std::string > identifyDevice(
void * handle,
NativeHandleType type
)
function isSamePhysicalDevice¶
bool isSamePhysicalDevice(
std::string const & uri1,
std::string const & uri2
)
Check if two transport URIs refer to the same physical device.
Parameters:
- uri1 First transport URI
- uri2 Second transport URI
Return: true if both URIs refer to the same physical device, false otherwise
Uses physical device identifiers to match devices across different APIs. Matching priority: UUID > PCI Address > LUID > Vendor+Device ID
Example:
bool sameDevice = api::transport::isSamePhysicalDevice("cuda://0",
"opencl://0-0");
// Returns true if both are NVIDIA GPU on PCI bus 0000:01:00.0
Used for:
- Detecting zero-copy opportunities between plugins
- Buffer interop capability checking
- Device topology visualization Thread-safe.
function getTransportUrisForDevice¶
std::vector< std::string > getTransportUrisForDevice(
std::string const & anyUri
)
Get all transport URIs for a physical device.
Parameters:
- anyUri Any transport URI for the device
Return: Vector of all transport URIs referring to the same physical device
Example:
auto uris = api::transport::getTransportUrisForDevice("cuda://0");
// Might return: ["cuda://0", "opencl://0-0", "d3d11://0"]
Used for visualizing multi-API access to same device.
Thread-safe.
function getAvailableSchemes¶
std::vector< std::string > getAvailableSchemes()
Get all available transport schemes.
Return: Vector of scheme names (e.g., ["cpu", "cuda", "opencl"])
Used by rtcmd for tab-completion and filtering.
Thread-safe.
function getAllTransports¶
std::vector< TransportInfo > getAllTransports()
Get all registered transports.
Return: Vector of TransportInfo for all registered transport URIs
Used by rtcmd transport command to display all available transports.
Thread-safe.
function getTransportsForScheme¶
std::vector< TransportInfo > getTransportsForScheme(
std::string const & scheme,
std::string const & targetInteropScheme =""
)
Get transports for a specific scheme.
Parameters:
- scheme Scheme name (e.g., "cuda", "opencl")
- targetInteropScheme Optional: only return transports capable of interop with this target scheme
Return: Vector of TransportInfo for the specified scheme
Used by rtcmd transport command with scheme filter.
Thread-safe.
function getPluginsSupportingUri¶
std::vector< std::string > getPluginsSupportingUri(
std::string const & uri
)
Get plugins supporting a transport URI.
Parameters:
- uri Transport URI
Return: Vector of plugin IDs that declared support for this URI
Example:
auto plugins = api::transport::getPluginsSupportingUri("cuda://0");
// Might return: ["nvidia.nvdec", "tensorrt", "opencv.cuda"]
Used by rtcmd to visualize plugin compatibility and zero-copy opportunities.
Thread-safe.
function getPluginSupportForUri¶
std::vector< PluginSupport > getPluginSupportForUri(
std::string const & uri
)
Get full plugin-support entries (id + kind + description + zeroCopy) for a URI.
Prefer this over the tuple of getPluginsSupportingUri/getPluginDescription/ isZeroCopySupport when rendering the transport ledger: it preserves the (pluginId, kind) distinction so two subplugins sharing a pluginId don't collide into a single row.
function getPluginDescription¶
std::string getPluginDescription(
std::string const & pluginId
)
Get description for a plugin ID.
Parameters:
- pluginId Plugin identifier
Return: Plugin description if available, empty string otherwise
Used by rtcmd to display plugin info like "nvidia.1 (NVIDIA Decoder)"
Thread-safe.
function isZeroCopySupport¶
bool isZeroCopySupport(
std::string const & uri,
std::string const & pluginId
)
Check if a plugin supports a transport URI with zero-copy.
Parameters:
- uri Transport URI
- pluginId Plugin identifier
Return: true if plugin supports URI with zero-copy, false if copy required or not supported
Thread-safe.
function declareBackendHandlesScheme¶
void declareBackendHandlesScheme(
std::string const & backendName,
std::string const & scheme
)
Declare buffer backend handles a transport scheme.
Parameters:
- backendName Buffer backend name (e.g., "BufferCpu", "BufferCuda")
- scheme Transport scheme (e.g., "cpu", "cuda", "opencl")
Example: declareBackendHandlesScheme("BufferCuda", "cuda") This declares BufferCuda handles all cuda:// URIs (cuda://0, cuda://1, etc.)
Thread-safe.
function declareSchemeInterop¶
void declareSchemeInterop(
std::string const & backendName,
std::string const & sourceScheme,
std::string const & targetScheme,
bool requiresSameDevice
)
Declare interop capability between two transport schemes.
Parameters:
- backendName Backend providing interop (e.g., "BufferOpenCL")
- sourceScheme Source transport scheme (e.g., "d3d11")
- targetScheme Target transport scheme (e.g., "opencl")
- requiresSameDevice Whether interop requires same physical device
Example: declareSchemeInterop("BufferOpenCL", "d3d11", "opencl", true) This declares BufferOpenCL can convert d3d11://N ↔ opencl://M when both on same device.
Thread-safe.
function isValidTransportUri¶
bool isValidTransportUri(
std::string const & transportUri
)
Check if transport URI is valid and registered.
Parameters:
- transportUri Transport URI to validate
Return: true if URI is registered in transport registry, false otherwise
Example:
if (api::transport::isValidTransportUri("cuda://0")) {
// URI is available on this system
}
Thread-safe.
function getUriScheme¶
std::optional< std::string > getUriScheme(
std::string const & transportUri
)
Extract scheme from transport URI.
Parameters:
- transportUri Transport URI (e.g., "cuda://0", "opencl://0-0")
Return: Scheme string if valid URI format, nullopt otherwise
Example: "cuda://0" → "cuda", "opencl://0-0" → "opencl"
This is a pure parsing function that does NOT check if the scheme is registered. Use isValidTransportUri() to validate URI existence.
Thread-safe (no registry access).
function getBackendForUri¶
std::optional< std::string > getBackendForUri(
std::string const & transportUri
)
Get buffer backend for a transport URI.
Parameters:
- transportUri Transport URI (e.g., "cuda://0", "cpu://")
Return: Backend name if found, nullopt otherwise
Matches by URI scheme. Example: "cuda://0" → "BufferCuda"
Thread-safe.
function getInteropPaths¶
std::vector< std::pair< std::string, std::string > > getInteropPaths(
std::string const & sourceUri
)
Get interop paths available from a transport URI.
Parameters:
- sourceUri Source transport URI
Return: Vector of (target URI, backend name) pairs
Example: "d3d11://0" → [("opencl://1-0", "BufferOpenCL")] if on same Intel GPU
Applies requiresSameDevice rules automatically.
Thread-safe.
function createNativeContext¶
std::shared_ptr< void > createNativeContext(
std::string const & transportUri,
NativeHandleType type
)
function setNativeContext¶
void setNativeContext(
std::string const & transportUri,
NativeHandleType type,
std::shared_ptr< void > handle
)
function clearNativeContext¶
void clearNativeContext(
std::string const & transportUri,
NativeHandleType type
)
function nativeContextMutex¶
std::recursive_mutex & nativeContextMutex(
std::string const & transportUri
)
Serialize all access to the single shared native context for a URI.
Some accelerators (e.g. the Blaize GSP) permit exactly one native context per device, so the decode buffer plugin and the inference engine share a single context published under "vx://
The mutex is owned by the core (not by a plugin module) so a single instance is visible across the separately loaded plugin modules that share the context. Recursive, so a thread already holding it may re-enter helpers that re-acquire it. Thread-safe.
function nativeSubmissionMutex¶
std::mutex & nativeSubmissionMutex(
std::string const & transportUri
)
Serialize native API command submission across plugin modules.
This mutex is owned by the core so separately loaded buffer and inference plugins can coordinate short command-submission sections for the same transport without holding the lock while device work completes.