membar GPU Virtual ISA NVIDIA

Memory Barrier / Fence Parallel Synchronization and Communication Instructions

membar.level;

Order this thread's prior memory accesses relative to later ones, visible to a given scope.

Encoding

PTX is a virtual instruction set. It has no single, stable native binary encoding - the compiler lowers this instruction to different native machine code depending on the selected NVIDIA target architecture (compute capability). This page intentionally shows no bit-diagram; see the target/version requirements below for what governs how this instruction compiles.
PTX ISA Version Introduced PTX ISA 1.4
Minimum Target sm_20

Syntax Forms

One mnemonic covers many type / state-space / scope / modifier combinations - each row below is an independently valid form.

Syntax Data Types State Space(s) Modifiers Min. Target Description
membar.level; cta, gl, sys sm_20 level selects the visibility scope: CTA, whole GPU, or system (including other GPUs/host).

Operands

At a Glance

Data Types -
Modifiers cta, gl, sys

Related AMDGPU Concepts

Memory Fence ↗
equivalent sequence

Reference

NVIDIA PTX ISA

Description

The membar instruction guarantees that prior memory accesses requested by this thread ( ld, st, atom and red instructions) are performed at the specified level, before later memory operations requested by this thread following the membar instruction. The level qualifier specifies the set of threads that may observe the ordering effect of this operation. A memory read (e.g., by ld or atom ) has been performed when the value read has been transmitted from memory and cannot be modified by another thread at the indicated level. (see the official PTX ISA docs for the full description)

Semantics

All memory operations issued by this thread before the fence become visible, in order, to other threads within the given scope before any operation issued after the fence.

Examples

membar.gl;
membar.cta;
membar.sys;
fence.sc.cta;
fence.sc.cluster;
fence.proxy.alias;
// (truncated - see the official PTX ISA docs for the full example)

Reproduced from NVIDIA's official PTX ISA documentation for technical accuracy.

Sources