-
Notifications
You must be signed in to change notification settings - Fork 15.4k
AMDGPU: Preliminary documentation for named barriers #165502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ee4eb7a
0681f1f
43377d8
4732753
5897052
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1179,6 +1179,51 @@ 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 fixed function hardware barrier objects that are available | ||
| in gfx12.5+ in addition to the traditional default barriers. | ||
|
|
||
| In LLVM IR, named barriers are represented by global variables of type | ||
| ``target("amdgcn.named.barrier", 0)`` in the LDS address space. Named barrier | ||
| global variables do not occupy actual LDS memory, but their lifetime and | ||
| allocation scope matches that of global variables in LDS. Programs in LLVM IR | ||
| refer to named barriers using pointers. | ||
|
|
||
| The following named barrier types are supported in global variables, defined | ||
| recursively: | ||
|
|
||
| * a single, standalone ``target("amdgcn.named.barrier", 0)`` | ||
| * an array of supported types | ||
| * a struct containing a single element of supported type | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Presumably an array of supported types is recursively itself a supported type that can occur as the single element in a struct type? Also, what stops us from allowing two fields which are both arrays in a struct?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes to the first question. To the second question: We could do that, it just didn't seem important and would be additional effort. The reason for allowing a struct is to allow wrapping types in C++ structs/classes. |
||
|
|
||
| .. 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 | ||
|
|
||
| ... | ||
|
|
||
| %foo.i = getelementptr [2 x target("amdgcn.named.barrier", 0)], ptr addrspace(3) @foo, i32 0, i32 %i | ||
| call void @llvm.amdgcn.s.barrier.signal.var(ptr addrspace(3) %foo.i, i32 0) | ||
|
|
||
| Named barrier types may not be used in ``alloca``. | ||
|
|
||
| Named barriers do not have an underlying byte representation. | ||
| It is undefined behavior to use a pointer to any part of a named barrier object | ||
| as the pointer operand of a regular memory access instruction or intrinsic. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we need to add something to say the pointer has to be used directly, so cannot be offset (gep) or undergo any kind of manipulation such as inttoptr/ptrtoint?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It actually can undergo that kind of manipulation. That was a goal of the design.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you can offset within a contiguous span of objects of the same type, but taking a difference of two such pointers results in an unspecified integer value.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
| Pointers to named barrier objects are intended to be used with dedicated | ||
| intrinsics. Reading from or writing to such pointers is undefined behavior. | ||
|
|
||
| LLVM IR Intrinsics | ||
| ------------------ | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.