
    ^j<                         d dl mZmZmZmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZ g dZe
dd       Ze
dd
d	dd       Ze
dd       Zed        Zy	)   )MBarrierLayoutallocate_mbarrierinit
invalidatewait    )jit   )_unwrap_if_constexprbuiltin   )cluster)	r   arriveexpectsync_cluster_initfence_init_release_clusterr   r   r   r   NTc                     |j                  |      }t        |      }|j                  j                  | j                  ||j                         y)a}  
    Expect a specific number of bytes being copied. When they are copied, the barrier is signaled.

    Args:
        mbarrier (shared_memory_descriptor): Barrier that will be signaled when the operation is complete.
        bytes_per_cta (int): Expected byte count per CTA.
        pred (bool): Scalar predicate. Operation is skipped if predicate is False. Defaults to True.
    N)	to_tensorr   buildercreate_mbarrier_expecthandle)mbarrierbytes_per_ctapred	_semantics       /var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/triton/experimental/gluon/language/nvidia/hopper/mbarrier.pyr   r      s>     t$D(7M,,X__mT[[Y    )countr   r   c                    t        |      }|j                  |      }|j                  j                  | j                  ||j                         y)a'  
    Arrive at an mbarrier with a specified count.

    Args:
        mbarrier (shared_memory_descriptor): Barrier to be signalled.
        count (int): Count to arrive with. Defaults to 1.
        pred (bool): Scalar predicate. Operation is skipped if predicate is False. Defaults to True.
    N)r   r   r   create_mbarrier_arriver   )r   r   r   r   s       r   r   r   "   s>     !'Et$D,,X__eT[[Qr   c                 8    | j                   j                          y)z
    Fence that makes prior mbarrier initialization visible across the CTA cluster.

    Needs to be called together with cluster.arrive(relaxed=True) and cluster.wait.
    N)r   *create_fence_mbarrier_init_release_cluster)r   s    r   r   r   1   s     @@Br   c                  l    t                t        j                  d       t        j                          y)zK
    Ensure mbarrier initialization is visible across the CTA cluster.
    T)relaxedN)r   r   r   r    r   r   r   r   ;   s    
  NN4 LLNr   )NTN)N)ampere.mbarrierr   r   r   r   r   "triton.experimental.gluon._runtimer	   _corer   r    r   __all__r   r   r   r   r%   r   r   <module>r+      sx    W W 2 2 
 	Z 	Z 	dd R 	R 	C 	C  r   