NVDEC - CUvideoctxlock questions (an authoritative explanation needed)

Hi all,

as CUvideoctxlock still appears in the latest SDK, I would finally like to understand if/how to use it. The cuviddec.h file states that cudaVideoCreate_PreferCUDA “requires valid vidLock object for multi-threading”. The header file also states “when using a floating context, all cuda calls should only be made within a cuvidCtxLock/cuvidCtxUnlock section”. To solve my ctxlock nightmare, my questions are:

  1. What do you mean by multi-threading? Are you talking about calling the methods of one decoder from different threads or creating multiple decoders each running a separate thread?

  2. The NVDEC samples create one lock per decoder. This way, running multiple decoders, no synchronization will occur at all. Is this correct?

  3. As noted above, you recommend to only do CUDA calls when the lock is applied. In your samples, you do some CUDA calls and never apply the lock. What am I missing?

  4. When using a floating context, we are advised to use the lock for all CUDA calls. But why? Using just one CUDA context means that all CUDA calls will be enqeued (i.e. serialized) with respect to the default CUDA stream of the context. So why should we bother locking the code when we do not make use of cuda streams?

Thank you very much.