cuda: add CuGet/SetCtxLimit()
authorMatthew Waters <matthew@centricular.com>
Mon, 16 Dec 2024 06:31:17 +0000 (17:31 +1100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 19 Dec 2024 00:33:03 +0000 (00:33 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8158>

girs/CudaGst-1.0.gir
subprojects/gst-plugins-bad/gst-libs/gst/cuda/cuda-gst.h
subprojects/gst-plugins-bad/gst-libs/gst/cuda/gstcudaloader.cpp
subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cuda.h

index 618a75650f86177c5c133bc9aecbf4321947a71b..1618180087580992847d39726eb91e7f43aaf33b 100644 (file)
@@ -621,6 +621,29 @@ and/or use gtk-doc annotations.  -->
       <member name="ipc_mem_lazy_enable_peer_access" value="1" c:identifier="CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS">
       </member>
     </enumeration>
+    <enumeration name="limit" c:type="CUlimit">
+      <source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cuda.h"/>
+      <member name="stack_size" value="0" c:identifier="CU_LIMIT_STACK_SIZE">
+      </member>
+      <member name="printf_fifo_size" value="1" c:identifier="CU_LIMIT_PRINTF_FIFO_SIZE">
+      </member>
+      <member name="malloc_heap_size" value="2" c:identifier="CU_LIMIT_MALLOC_HEAP_SIZE">
+      </member>
+      <member name="dev_runtime_sync_depth" value="3" c:identifier="CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH">
+      </member>
+      <member name="dev_runtime_pending_launch_count" value="4" c:identifier="CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT">
+      </member>
+      <member name="max_l2_fetch_granularity" value="5" c:identifier="CU_LIMIT_MAX_L2_FETCH_GRANULARITY">
+      </member>
+      <member name="persisting_l2_cache_size" value="6" c:identifier="CU_LIMIT_PERSISTING_L2_CACHE_SIZE">
+      </member>
+      <member name="shmem_size" value="7" c:identifier="CU_LIMIT_SHMEM_SIZE">
+      </member>
+      <member name="cig_enabled" value="8" c:identifier="CU_LIMIT_CIG_ENABLED">
+      </member>
+      <member name="cig_shmem_fallback_enabled" value="9" c:identifier="CU_LIMIT_CIG_SHMEM_FALLBACK_ENABLED">
+      </member>
+    </enumeration>
     <record name="memAccessDesc" c:type="CUmemAccessDesc">
       <source-position filename="../subprojects/gst-plugins-bad/gst-libs/gst/cuda/stub/cuda.h"/>
       <field name="location" writable="1">
index 9d295b4acc2f8336b1274b14fd65b1ec35e9d80c..0b60da275b9ddbec0240e2d514c1c5e79706a317 100644 (file)
@@ -45,6 +45,12 @@ CUresult CUDAAPI CuCtxPushCurrent   (CUcontext ctx);
 GST_CUDA_API
 CUresult CUDAAPI CuCtxSynchronize   (void);
 
+GST_CUDA_API
+CUresult CUDAAPI CuCtxGetLimit      (size_t *plimit, CUlimit limit);
+
+GST_CUDA_API
+CUresult CUDAAPI CuCtxSetLimit      (CUlimit limit, size_t value);
+
 GST_CUDA_API
 CUresult CUDAAPI CuCtxEnablePeerAccess (CUcontext peerContext,
                                              unsigned int Flags);
index 711792b7f1d0081ba81870a3be6c1fc1a16ead32..39b0f711f20ed3b3fba4ab29ef1ceae47612fd2f 100644 (file)
@@ -76,6 +76,8 @@ typedef struct _GstNvCodecCudaVTable
   CUresult (CUDAAPI * CuCtxPopCurrent) (CUcontext * pctx);
   CUresult (CUDAAPI * CuCtxPushCurrent) (CUcontext ctx);
   CUresult (CUDAAPI * CuCtxSynchronize) (void);
+  CUresult (CUDAAPI * CuCtxGetLimit) (size_t * plimit, CUlimit limit);
+  CUresult (CUDAAPI * CuCtxSetLimit) (CUlimit limit, size_t value);
 
   CUresult (CUDAAPI * CuCtxEnablePeerAccess) (CUcontext peerContext,
       unsigned int Flags);
@@ -354,6 +356,8 @@ gst_cuda_load_library_once_func (void)
   LOAD_SYMBOL (cuCtxPushCurrent, CuCtxPushCurrent);
   LOAD_SYMBOL (cuCtxEnablePeerAccess, CuCtxEnablePeerAccess);
   LOAD_SYMBOL (cuCtxDisablePeerAccess, CuCtxDisablePeerAccess);
+  LOAD_SYMBOL (cuCtxGetLimit, CuCtxGetLimit);
+  LOAD_SYMBOL (cuCtxSetLimit, CuCtxSetLimit);
 
   LOAD_SYMBOL (cuGraphicsMapResources, CuGraphicsMapResources);
   LOAD_SYMBOL (cuGraphicsUnmapResources, CuGraphicsUnmapResources);
@@ -560,6 +564,22 @@ CuCtxDisablePeerAccess (CUcontext peerContext)
   return gst_cuda_vtable.CuCtxDisablePeerAccess (peerContext);
 }
 
+CUresult CUDAAPI
+CuCtxGetLimit (size_t *plimit, CUlimit limit)
+{
+  g_assert (gst_cuda_vtable.CuCtxGetLimit != nullptr);
+
+  return gst_cuda_vtable.CuCtxGetLimit (plimit, limit);
+}
+
+CUresult CUDAAPI
+CuCtxSetLimit (CUlimit limit, size_t value)
+{
+  g_assert (gst_cuda_vtable.CuCtxSetLimit != nullptr);
+
+  return gst_cuda_vtable.CuCtxSetLimit (limit, value);
+}
+
 CUresult CUDAAPI
 CuGraphicsMapResources (unsigned int count, CUgraphicsResource * resources,
     CUstream hStream)
index 290963286dd9089d0902a6806a5cfb4e7659d639..658147c3e2b78a6f5df73d3625f869389510e8fe 100644 (file)
@@ -131,6 +131,20 @@ typedef enum
   CU_EVENT_INTERPROCESS = 0x4,
 } CUevent_flags;
 
+typedef enum
+{
+  CU_LIMIT_STACK_SIZE = 0x0,
+  CU_LIMIT_PRINTF_FIFO_SIZE = 0x1,
+  CU_LIMIT_MALLOC_HEAP_SIZE = 0x2,
+  CU_LIMIT_DEV_RUNTIME_SYNC_DEPTH = 0x3,
+  CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNT = 0x4,
+  CU_LIMIT_MAX_L2_FETCH_GRANULARITY = 0x5,
+  CU_LIMIT_PERSISTING_L2_CACHE_SIZE = 0x6,
+  CU_LIMIT_SHMEM_SIZE = 0x7,
+  CU_LIMIT_CIG_ENABLED = 0x8,
+  CU_LIMIT_CIG_SHMEM_FALLBACK_ENABLED = 0x9,
+} CUlimit;
+
 typedef struct
 {
   gsize srcXInBytes;