
    biG
                         S SK Js  Js  Js  Jr  S SKJr  S SK JrJ	r	  / SQr
 " S S\5      r\SS j5       r\SS j5       r\S	SS
.S j5       rg)    N)SwizzledSharedLayout)builtin_unwrap_if_constexpr)MBarrierLayoutinitwaitarrivec                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )r      zq
Layout for mbarrier synchronization.

Args:
    cga_layout (List[List[int]]): CTA layout bases. Defaults to [].
c                 <   > [         TU ]  SSSS/U=(       d    / S9  g )N   r   )vec	per_phase	max_phaseorder
cga_layout)super__init__)selfr   	__class__s     q/home/james-whalen/.local/lib/python3.13/site-packages/triton/experimental/gluon/language/amd/gfx1250/mbarrier.pyr   MBarrierLayout.__init__   s$    Q!qPZP`^`a     N)__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classcell__)r   s   @r   r   r      s    b br   r   c                 f    [        U5      nUR                  R                  U R                  U5        g)a  
Initialize an mbarrier with a specified count. An mbarrier consists of an init count, a pending count and a phase.
At initialization, the init count and pending count are initialized with the given 'count' and the phase is initialized to 0.

Args:
    mbarrier (shared_memory_descriptor): The barrier object to initialize.
    count (int): The initial count for the barrier. Must be a positive integer.
N)r   buildercreate_lds_barrier_inithandle)mbarriercount	_semantics      r   r   r      s(     !'E--hoouEr   c                     UR                  U5      nUR                  R                  U R                  UR                  5        g)aP  
Wait until the mbarrier's phase differs from the provided phase value.
This means that the given 'phase' has completed.

Args:
    mbarrier (shared_memory_descriptor): The barrier object to wait on.
    phase (int): The phase value to compare against. The wait completes when
    the barrier's phase becomes different from this value.
N)	to_tensorr$   create_lds_barrier_waitr&   )r'   phaser)   s      r   r   r   "   s2     &E--hoou||Lr   r   )r(   r)   c                    [        U5      nUR                  R                  U R                  U5      n[        R
                  " U[        R                  5      $ )a`  
Arrive at an mbarrier with a specified count. The operation requires a `count` attribute
of at least 1, and decreases the pending arrival count of the mbarrier by the specific count.
If the pending count reaches zero, the phase changes (is decremented in a wraparound manner) and the
pending count is reloaded with the init count value. Returns the mbarrier's phase prior to the "arrive" operation.

Args:
    mbarrier (shared_memory_descriptor): Barrier to be signalled.
    count (int): Count to arrive with. Defaults to 1.

Returns:
    prior phase (int): phase of mbarrier, prior to "arrive" operation.
)r   r$   create_lds_barrier_arriver&   ttgltensorint32)r'   r(   r)   r&   s       r   r	   r	   2   s?     !'E88%PF;;vtzz**r   r   )(triton.experimental.gluon.language._coreexperimentalgluonlanguage_corer0   +triton.experimental.gluon.language._layoutsr   r   r   __all__r   r   r   r	   r   r   r   <module>r:      sj    7 7 L R
6	b) 	b 	
F 	
F 	M 	M 	4 + 	+r   