cuda.bindings._v2.driver.ctx_set_limit#
- cuda.bindings._v2.driver.ctx_set_limit(int limit, size_t value)#
Set resource limits.
Setting
limittovalueis a request by the application to update the current limit maintained by the context. The driver is free to modify the requested value to meet h/w requirements (this could be clamping to minimum or maximum values, rounding up to nearest element size, etc). The application can usectx_get_limit()to find out exactly what the limit has been set to. Setting eachCUlimithas its own specific restrictions, so each is discussed here.CU_LIMIT_STACK_SIZEcontrols the stack size in bytes of each GPU thread. The driver automatically increases the per-thread stack size for each kernel launch as needed. This size isn’t reset back to the original value after each launch. Setting this value will take effect immediately, and if necessary, the device will block until all preceding requested tasks are complete.CU_LIMIT_PRINTF_FIFO_SIZEcontrols the size in bytes of the FIFO used by theprintf()device system call. SettingCU_LIMIT_PRINTF_FIFO_SIZEmust be performed before launching any kernel that uses theprintf()device system call, otherwiseCUDA_ERROR_INVALID_VALUEwill be returned.CU_LIMIT_MALLOC_HEAP_SIZEcontrols the size in bytes of the heap used by themalloc()andfree()device system calls. SettingCU_LIMIT_MALLOC_HEAP_SIZEmust be performed before launching any kernel that uses themalloc()orfree()device system calls, otherwiseCUDA_ERROR_INVALID_VALUEwill be returned.CU_LIMIT_DEV_RUNTIME_SYNC_DEPTHcontrols the maximum nesting depth of a grid at which a thread can safely callcudaDeviceSynchronize(). Setting this limit must be performed before any launch of a kernel that uses the device runtime and callscudaDeviceSynchronize()above the default sync depth, two levels of grids. Calls tocudaDeviceSynchronize()will fail with error codecudaErrorSyncDepthExceededif the limitation is violated. This limit can be set smaller than the default or up the maximum launch depth of 24. When setting this limit, keep in mind that additional levels of sync depth require the driver to reserve large amounts of device memory which can no longer be used for user allocations. If these reservations of device memory fail,ctx_set_limit()will returnCUDA_ERROR_OUT_OF_MEMORY, and the limit can be reset to a lower value. This limit is only applicable to devices of compute capability < 9.0. Attempting to set this limit on devices of other compute capability versions will result in the errorCUDA_ERROR_UNSUPPORTED_LIMITbeing returned.CU_LIMIT_DEV_RUNTIME_PENDING_LAUNCH_COUNTcontrols the maximum number of outstanding device runtime launches that can be made from the current context. A grid is outstanding from the point of launch up until the grid is known to have been completed. Device runtime launches which violate this limitation fail and returncudaErrorLaunchPendingCountExceededwhencudaGetLastError()is called after launch. If more pending launches than the default (2048 launches) are needed for a module using the device runtime, this limit can be increased. Keep in mind that being able to sustain additional pending launches will require the driver to reserve larger amounts of device memory upfront which can no longer be used for allocations. If these reservations fail,ctx_set_limit()will returnCUDA_ERROR_OUT_OF_MEMORY, and the limit can be reset to a lower value. This limit is only applicable to devices of compute capability 3.5 and higher. Attempting to set this limit on devices of compute capability less than 3.5 will result in the errorCUDA_ERROR_UNSUPPORTED_LIMITbeing returned.CU_LIMIT_MAX_L2_FETCH_GRANULARITYcontrols the L2 cache fetch granularity. Values can range from 0B to 128B. This is purely a performance hint and it can be ignored or clamped depending on the platform.CU_LIMIT_PERSISTING_L2_CACHE_SIZEcontrols size in bytes available for persisting L2 cache. This is purely a performance hint and it can be ignored or clamped depending on the platform.CU_LIMIT_PER_BLOCK_MEMORY_SIZEconstrols size in bytes of per-block memory.
- Parameters:
limit (Limit) – Limit to set.
value (size_t) – Size of limit.
See also
cuCtxSetLimit