Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chrisdavidmills
Copy link
Contributor

@chrisdavidmills chrisdavidmills commented Nov 21, 2024

Description

Chrome 123 supports the readonly_and_readwrite_storage_textures language extension (see WGSLLanguageFeatures), which allows:

  • 32-bit integer scalars packing 4-component vectors of 8-bit integers to be used as inputs to dot product instructions
  • and packing and unpacking instructions with packed 4-component vectors of 8-bit integers to be used

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

@chrisdavidmills chrisdavidmills requested a review from a team as a code owner November 21, 2024 12:22
@chrisdavidmills chrisdavidmills requested review from wbamberg and removed request for a team November 21, 2024 12:22
@github-actions github-actions bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Nov 21, 2024
Copy link
Contributor

github-actions bot commented Nov 21, 2024

Preview URLs

External URLs (2)

URL: /en-US/docs/Web/API/WGSLLanguageFeatures
Title: WGSLLanguageFeatures

(comment last updated: 2024-11-22 09:31:15)

@@ -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 |
Copy link
Collaborator

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 uses name 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?

Copy link
Contributor Author

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?

@github-actions github-actions bot added the merge conflicts 🚧 [PR only] label Nov 22, 2024
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot removed the merge conflicts 🚧 [PR only] label Nov 22, 2024
Comment on lines +26 to +27
| Feature name | Description |
| ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
| Feature name | Description |
| ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Feature name | Description |
| --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| <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 |
| ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <span id="packed_4x8_integer_dot_product">`packed_4x8_integer_dot_product`</span> | <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> |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
MD033/no-inline-html Inline HTML [Element: span]

| Feature name | Description |
| ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <span id="packed_4x8_integer_dot_product">`packed_4x8_integer_dot_product`</span> | <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> |
| <span id="readonly_and_readwrite_storage_textures">`readonly_and_readwrite_storage_textures`</span> | When available, allows the `"read-only"` and `"read-write"` [`storageTexture.access`](/en-US/docs/Web/API/GPUDevice/createBindGroupLayout#access) values to be set when specifying storage texture bind group entry types in a bind group layout. These enable WSGL code to read storage textures, and read/write storage textures, respectively. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
MD033/no-inline-html Inline HTML [Element: span]

| ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <span id="packed_4x8_integer_dot_product">`packed_4x8_integer_dot_product`</span> | <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> |
| <span id="readonly_and_readwrite_storage_textures">`readonly_and_readwrite_storage_textures`</span> | When available, allows the `"read-only"` and `"read-write"` [`storageTexture.access`](/en-US/docs/Web/API/GPUDevice/createBindGroupLayout#access) values to be set when specifying storage texture bind group entry types in a bind group layout. These enable WSGL code to read storage textures, and read/write storage textures, respectively. |
| <span id="unrestricted_pointer_parameters">`unrestricted_pointer_parameters`</span> | <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> |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[markdownlint] reported by reviewdog 🐶
MD033/no-inline-html Inline HTML [Element: span]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants