Add functions to identify devices in more ways
authorrcombs <rcombs@rcombs.me>
Tue, 9 May 2023 10:11:20 +0000 (12:11 +0200)
committerTimo Rothenpieler <timo@rothenpieler.org>
Tue, 9 May 2023 10:50:40 +0000 (12:50 +0200)
- cuDeviceGetUuid_v2, giving distinct IDs for different MIG instances
- cuDeviceGetLuid, giving a Win32 LUID to match with DXGI and other APIs
- cuDeviceGetByPCIBusId, retrieving a device that matches a PCI bus ID string
- cuDeviceGetPCIBusId, giving a PCI bus ID string for a device

Closes #11

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
include/ffnvcodec/dynlink_cuda.h
include/ffnvcodec/dynlink_loader.h

index 6ad088f352f864daa0335b75bb3fd5c6dc7093f1..79ff6d6a8b06e45439aed430cc8012c5fd7536ac 100644 (file)
@@ -414,6 +414,10 @@ typedef CUresult CUDAAPI tcuDeviceGet(CUdevice *device, int ordinal);
 typedef CUresult CUDAAPI tcuDeviceGetAttribute(int *pi, CUdevice_attribute attrib, CUdevice dev);
 typedef CUresult CUDAAPI tcuDeviceGetName(char *name, int len, CUdevice dev);
 typedef CUresult CUDAAPI tcuDeviceGetUuid(CUuuid *uuid, CUdevice dev);
+typedef CUresult CUDAAPI tcuDeviceGetUuid_v2(CUuuid *uuid, CUdevice dev);
+typedef CUresult CUDAAPI tcuDeviceGetLuid(char* luid, unsigned int* deviceNodeMask, CUdevice dev);
+typedef CUresult CUDAAPI tcuDeviceGetByPCIBusId(CUdevice* dev, const char* pciBusId);
+typedef CUresult CUDAAPI tcuDeviceGetPCIBusId(char* pciBusId, int len, CUdevice dev);
 typedef CUresult CUDAAPI tcuDeviceComputeCapability(int *major, int *minor, CUdevice dev);
 typedef CUresult CUDAAPI tcuCtxCreate_v2(CUcontext *pctx, unsigned int flags, CUdevice dev);
 typedef CUresult CUDAAPI tcuCtxSetLimit(CUlimit limit, size_t value);
index ea8bef43e5762c5a9058fd7d2578c2683b2e412b..5e4971c4722028771ecf4d5a00358c34a0cffff8 100644 (file)
@@ -142,6 +142,10 @@ typedef struct CudaFunctions {
     tcuDeviceGetAttribute *cuDeviceGetAttribute;
     tcuDeviceGetName *cuDeviceGetName;
     tcuDeviceGetUuid *cuDeviceGetUuid;
+    tcuDeviceGetUuid_v2 *cuDeviceGetUuid_v2;
+    tcuDeviceGetLuid *cuDeviceGetLuid;
+    tcuDeviceGetByPCIBusId *cuDeviceGetByPCIBusId;
+    tcuDeviceGetPCIBusId *cuDeviceGetPCIBusId;
     tcuDeviceComputeCapability *cuDeviceComputeCapability;
     tcuCtxCreate_v2 *cuCtxCreate;
     tcuCtxSetLimit *cuCtxSetLimit;
@@ -369,6 +373,10 @@ static inline int cuda_load_functions(CudaFunctions **functions, void *logctx)
     LOAD_SYMBOL(cuGraphicsResourceGetMappedPointer, tcuGraphicsResourceGetMappedPointer, "cuGraphicsResourceGetMappedPointer_v2");
 
     LOAD_SYMBOL_OPT(cuDeviceGetUuid, tcuDeviceGetUuid, "cuDeviceGetUuid");
+    LOAD_SYMBOL_OPT(cuDeviceGetUuid_v2, tcuDeviceGetUuid_v2, "cuDeviceGetUuid_v2");
+    LOAD_SYMBOL_OPT(cuDeviceGetLuid, tcuDeviceGetLuid, "cuDeviceGetLuid");
+    LOAD_SYMBOL_OPT(cuDeviceGetByPCIBusId, tcuDeviceGetByPCIBusId, "cuDeviceGetByPCIBusId");
+    LOAD_SYMBOL_OPT(cuDeviceGetPCIBusId, tcuDeviceGetPCIBusId, "cuDeviceGetPCIBusId");
     LOAD_SYMBOL_OPT(cuImportExternalMemory, tcuImportExternalMemory, "cuImportExternalMemory");
     LOAD_SYMBOL_OPT(cuDestroyExternalMemory, tcuDestroyExternalMemory, "cuDestroyExternalMemory");
     LOAD_SYMBOL_OPT(cuExternalMemoryGetMappedBuffer, tcuExternalMemoryGetMappedBuffer, "cuExternalMemoryGetMappedBuffer");