nki.lnc
========

.. currentmodule:: nki.lnc

.. _nki-lnc:

LNC communication
-----------------

The ``nki.lnc`` module provides data exchange, reduction, and synchronization
between the paired physical NeuronCores that share an HBM stack.
``sendrecv`` and ``sendrecv_compute`` communicate within a Logical NeuronCore
and require LNC degree 2. ``core_barrier`` synchronizes the paired cores at
LNC degree 1 or 2. At LNC degree 1, each physical core forms a separate Logical
NeuronCore, but the pair can still access shared HBM and use the barrier to
wait for each other's writes.

``sendrecv`` and ``sendrecv_compute`` accept a ``priority`` from 0 (highest) to
3 (lowest) to control DMA quality of service on NeuronCore-v4 or newer.
``sendrecv`` requires ``priority=None`` when using
``nki.isa.dma_engine.gpsimd_dma``; explicit priorities are rejected.

The corresponding ``nki.isa`` entry points are deprecated compatibility wrappers.
They remain available for existing kernels and emit ``DeprecationWarning`` at
the call site. Use the ``nki.lnc`` APIs when migrating or writing new kernels.
``nki.lnc.sendrecv`` has no ``pipe_id`` argument; remove it when migrating from
``nki.isa.sendrecv``, where it remains ignored.

.. autosummary::
   :toctree: generated
   :nosignatures:

   core_barrier
   sendrecv
   sendrecv_compute
