[llvm] AMDGPU: Preliminary documentation for named barriers (PR #165502)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 29 03:12:46 PDT 2025
================
@@ -1179,6 +1179,53 @@ is conservatively correct for OpenCL.
other operations within the same address space.
======================= ===================================================
+Target Types
+------------
+
+The AMDGPU backend implements some target extension types.
+
+.. _amdgpu-types-named-barriers:
+
+Named Barriers
+~~~~~~~~~~~~~~
+
+Named barriers are represented as memory objects of type
+``target("amdgcn.named.barrier", 0)``. They are allocated as global variables
+in the LDS address space. They do not occupy regular LDS memory, but their
+lifetime and allocation granularity matches that of global variables in LDS.
+
+The following types built from named barriers are supported in global variables,
+defined recursively:
+
+* a standalone ``target("amdgcn.named.barrier", 0)``
+* an array of supported types
+* a struct containing a single element of supported type
+
+.. code-block:: llvm
+
+ @bar = addrspace(3) global target("amdgcn.named.barrier", 0) undef
+ @foo = addrspace(3) global [2 x target("amdgcn.named.barrier", 0)] undef
+ @baz = addrspace(3) global { target("amdgcn.named.barrier", 0) } undef
+
+Barrier types may not be used in ``alloca``.
+
+The integral representation of a pointer to a valid named barrier is in the
+range ``0x0080'0010`` to ``0x0080'0100`` (inclusive). The representation is
+formed by the expression ``0x0080'0000 | (id << 4)``, where ``id`` is the
+hardware barrier ID. The integral representation of the null named barrier is
+``0x0080'0000``.
+
+It is not legal to attempt to form a pointer to any non-named barrier objects.
----------------
jayfoad wrote:
For me this just raised more questions than it answered. What is a non-named barrier object and how would I even attempt to form a pointer to one?
https://github.com/llvm/llvm-project/pull/165502
More information about the llvm-commits
mailing list