o
    j9:j&                     @   sB   d dl Z dgZeZdZee jdre jjZdZG dd deZdS )    NGreenContextF_CUDAGreenContextTc                       s   e Zd ZdZeddddddedB dedB dedB dedB def
d	d
ZeddedB defddZ	d fddZ
d fddZd fddZ  ZS )r   zyWrapper around a CUDA green context.

    .. warning::
       This API is in beta and may change in future releases.
    Nnum_smsworkqueue_scopeworkqueue_concurrency_limit	device_idr   r   r   r   returnc                 C   s   t stdtj|| ||dS )a+  Create a CUDA green context.

        At least one of ``num_sms`` or ``workqueue_scope`` must be specified.
        Both can be combined to partition SMs and configure workqueues in the
        same green context.

        Arguments:
            num_sms (int, optional): The number of SMs to use in the green
                context. When ``None``, SMs are not partitioned.
            workqueue_scope (str, optional): Workqueue sharing scope. One of
                ``"device_ctx"`` (shared across all contexts, default driver
                behaviour) or ``"balanced"`` (non-overlapping workqueues with
                other balanced green contexts). When ``None``, no workqueue
                configuration is applied.
            workqueue_concurrency_limit (int, optional): Maximum number of
                concurrent stream-ordered workloads for the workqueue. Requires
                ``workqueue_scope`` to be set.
            device_id (int, optional): The device index of green context.
                When ``None``, the current device is used.
        1PyTorch was not built with Green Context support!)r   r   r   r   )	SUPPORTEDRuntimeError_GreenContextcreater    r   `/home/nk/hobo-godmode/plappi-mvp/.venv/lib/python3.10/site-packages/torch/cuda/green_contexts.pyr      s   zGreenContext.createc                 C   s   t stdtj| dS )aw  Return the maximum workqueue concurrency limit for the device.

        This queries the device for the default number of concurrent
        stream-ordered workloads supported by workqueue configuration
        resources.

        Arguments:
            device_id (int, optional): The device index to query. When
                ``None``, the current device is used.
        r
   r   )r   r   r   max_workqueue_concurrencyr   r   r   r   r   >   s   z&GreenContext.max_workqueue_concurrencyc                    
   t   S )z+Make the green context the current context.)superset_contextself	__class__r   r   r   P      
zGreenContext.set_contextc                    r   )zAssuming the green context is the current context, pop it from the
        context stack and restore the previous context.
        )r   pop_contextr   r   r   r   r   T   s   
zGreenContext.pop_contexttorch.cuda.Streamc                    r   )z1Return the CUDA Stream used by the green context.)r   Streamr   r   r   r   r   Z   r   zGreenContext.Stream)N)r	   N)r	   r   )__name__
__module____qualname____doc__staticmethodintstrr   r   r   r   r   r   __classcell__r   r   r   r   r      s.    $)	torch__all__objectr   r   hasattr_Cr   r   r   r   r   r   <module>   s    