IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Mojo function

named_barrier

def named_barrier[num_threads: Int32](id: Int32 = Int32(0))

Performs a named synchronization barrier at the block level.

This function creates a synchronization point using a specific barrier ID, allowing for multiple independent barriers within a thread block. All threads in the block must execute this function with the same barrier ID and thread count before any thread can proceed past the barrier.

Notes:

  • Only supported on NVIDIA GPUs.
  • Maps directly to the nvvm.barrier instruction.
  • Useful for fine-grained synchronization when different subsets of threads need to synchronize independently.
  • The barrier ID must not exceed 16.
  • All threads participating in the barrier must specify the same num_threads value.
  • The number of threads value must be a multiple of the warp size.

Parameters:

  • num_threads (Int32): The number of threads that must reach the barrier before any can proceed.

Args:

  • id (Int32): The barrier identifier (0-16). Default is 0.

Was this page helpful?