-
Notifications
You must be signed in to change notification settings - Fork 22.6k
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
Add information on packed_4x8_integer_dot_product extension #36898
Add information on packed_4x8_integer_dot_product extension #36898
Conversation
Preview URLs External URLs (1)URL:
(comment last updated: 2024-11-23 17:28:29) |
@@ -21,6 +21,11 @@ The `WGSLLanguageFeatures` object is accessed via the {{domxref("GPU.wgslLanguag | |||
## Available features | |||
|
|||
The available WGSL language extensions can vary across implementations and physical devices and may also change over time; we have therefore not listed them here. For a complete list, refer to [WGSL language extensions](https://gpuweb.github.io/gpuweb/wgsl/#language-extension) in the WGSL specification. | |||
The following WGSL language extensions are defined at [WGSL language extensions](https://gpuweb.github.io/gpuweb/wgsl/#language-extension) in the WGSL specification. Bear in mind that the exact set of features available will vary across implementations and physical devices, and may change over time. | |||
|
|||
| Feature name | Description | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the reasoning for this format is.
- It's much harder to edit or read the source than a Markdown
<dl>
or just headings. - It means you have to embed HTML in the source to get paragraphs
- We have something that looks to users like a link, that doesn't go anywhere if you click it
- The
<a>
element usesname
which is deprecated according to our docs. - You only get about 2/3 of the page width for the description text.
Why not use a Markdown <dl>
, or just headings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We used tables on the other similar WebGPU pages, so I decided to follow suit here. The link-looking things are anchors (<a name="foo">
) that I inserted so I would be able to link to link to those exact row. Thinking about it now, I should have used <span id="foo">
instead. Old habits die hard ;-)
So, this table has already been put live by other PRs. At this point I would suggest getting it merged, and then we can convert to a <dl>
in a fresh PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried to use <span id="foo">
. It works, but spans are disallowed by the linter, so <a name="foo">
it is for now. sigh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link-looking things are anchors (<a name="foo">) that I inserted so I would be able to link to link to those exact row.
I did understand what they are for, but to normal readers they look like navigable links. If this was a <dt>
or a heading you would get an anchor automatically inserted by the platform.
So, this table has already been put live by other PRs. At this point I would suggest getting it merged, and then we can convert to a
in a fresh PR?
I think it would be easier to do it here but it's fine if you want to do it in a new PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, thinking it over, I would like it fixed in this PR, unless there's doubt that a standard mechanism would be better or there's some other reason to delay. I do understand that this page with this formatting choice is already live on the site, but I don't see that this is a compelling reason not to fix it in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair call. In my last commit, I have changed it to a dl.
This pull request has merge conflicts that must be resolved before it can be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure these are very helpful comments. I didn't find this addition comprehensible, but maybe it is to someone working on WebGPU.
| <a name="unrestricted_pointer_parameters">`unrestricted_pointer_parameters`</a> | <p>Loosens restrictions on pointers being passed to WGSL functions. When available, the following are allowed:</p><ul><li>Parameter pointers to storage, uniform, and workgroup address spaces being passed to user-declared functions.</li><li>Pointers to structure members and array elements being passed to user-declared functions.</li></ul><p>See [Pointers As Function Parameters](https://google.github.io/tour-of-wgsl/types/pointers/passing_pointers/) for more details.</p> | | ||
| Feature name | Description | | ||
| ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| <a name="packed_4x8_integer_dot_product">`packed_4x8_integer_dot_product`</a> | <p>Allows **DP4a** (Dot Product of 4 Elements and Accumulate) GPU instructions to be used via your WGSL code. These efficiently perform 8-bit integer dot products to accelerate computation, saving memory (up to 75%) and network bandwidth and improving performance compared with the equivalent `f32` versions. They are commonly used in machine learning models in inferencing, within AI frameworks.</p><p>Specifically, when `packed_4x8_integer_dot_product` is available, WGSL code can use 32-bit integer scalars packing 4-component vectors of 8-bit integers to be used as inputs to dot product instructions (via the `dot4U8Packed()` and `dot4I8Packed()` built-in functions), and use packing and unpacking instructions with packed 4-component vectors of 8-bit integers (via built-in functions such as `pack4xI8()` and `pack4xI8Clamp()`).</p> | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this at all, and especially the last sentence:
Specifically, when packed_4x8_integer_dot_product is available, WGSL code can use 32-bit integer scalars packing 4-component vectors of 8-bit integers to be used as inputs to dot product instructions (via the dot4U8Packed() and dot4I8Packed() built-in functions), and use packing and unpacking instructions with packed 4-component vectors of 8-bit integers (via built-in functions such as pack4xI8() and pack4xI8Clamp()).
...is very complex both technically and syntactically. I think it is not grammatical: "WGSL code can use...to be used as inputs..." should probably be "WGSL code can use... as inputs..." but honestly it's such a complex sentence that it's hard for me to say.
I don't know if this is because I'm unfamiliar with WebGPU though and this would be clear to someone using this API. But I don't think this would mean anything to anyone who's not already deep in this area.
Are there any cross-links to help people understand things? i.e. terms like dp4a, f32, not to mention the functions referenced are there links for these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "(up to 75%)" sounds like marketing. Where's this number from? Under what conditions is 75% reached? And is the AI reference necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the idea that dot4U8Packed()
and dot4I8Packed()
become available to you, when this feature is on? Sorry if I'm sounding ignorant here. Maybe I should just assume that this is going to make sense to someone who's looking at this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pffft. I have tried. I am unsure how to make this less confusing, without starting to explain the whole of WGSL on MDN, which we don't really want to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Chris! I like the DL change.
Description
Chrome 123 supports the
readonly_and_readwrite_storage_textures
language extension (seeWGSLLanguageFeatures
), which allows:In your WGSL shader code.
This PR adds an entry to the "Available features" table on the
WGSLLanguageFeatures
ref page for this feature. I'm copying the same structure as I used in #36880, and will deal with merging them as they start to get published.See https://developer.chrome.com/blog/new-in-webgpu-123#dp4a_built-in_functions_support_in_wgsl for the data source.
Motivation
Additional details
Related issues and pull requests
Project issue: #36349