Skip to content

Conversation

@fs-eire
Copy link
Contributor

@fs-eire fs-eire commented Jan 14, 2025

Description

This PR allows WebGPU EP to be built with Emscripten for WebAssembly, Including:

  • cmake build files update to support correct setup for Emscripten.
  • code changes to fix build breaks for wasm
  • change in Web CI pipeline to add a build-only target for wasm with --use_webgpu.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

You can commit the suggested changes from lintrunner.

@fs-eire
Copy link
Contributor Author

fs-eire commented Jan 16, 2025

Detailed explanation of why this PR contains a patch_3.1.74.tgz file:

Ideally, Emscripten should be able to compile C++ code that uses webgpu, only by appending -sUSE_WEBGPU=1 in link flag. What are supposed to be done under this flag is as below:

  • add a webgpu.cc implementation to source list for compiling. This file includes a few inter-op code that implemented specifically for Emscripten.
  • add a few JS library, including the library_webgpu.js and a few of its dependencies.

However, the actual WebGPU support in Emscripten is still ongoing, and the existing implementation in Emscripten is fall behind. Dawn maintains a newer implementation of webgpu.cc and library_webgpu.js mentioned above, and it uses a CMake target emwebgpu_c to allow C++ library to link on. So, instead of using -sUSE_WEBGPU=1, emwebgpu_c uses -sUSE_WEBGPU=0 with a few other link flags to import the newer version of library_webgpu.js and its dependencies.

The build process will generate the dependencies of library_webgpu.js, using the script in ${EMSCRIPTEN_TOOLCHAIN}/tools/maint/gen_struct_info.py. However, from Emscripten considers this script as an internal script, so it's missing from emsdk's installation.

In this PR, I include the file gen_struct_info.py inside folder cmake/patches/emscripten. If I put the original file, our Linter will be unhappy and the build is blocked, so I need to make a tar file and use cmake to extract during the build process.

@fs-eire fs-eire merged commit 080c67e into main Jan 16, 2025
98 checks passed
@fs-eire fs-eire deleted the fs-eire/w59 branch January 16, 2025 18:52
carzh pushed a commit that referenced this pull request Jan 16, 2025
### Description

This PR allows WebGPU EP to be built with Emscripten for WebAssembly,
Including:


- cmake build files update to support correct setup for Emscripten.
- code changes to fix build breaks for wasm
- change in Web CI pipeline to add a build-only target for wasm with
`--use_webgpu`.
carzh pushed a commit that referenced this pull request Jan 31, 2025
This PR allows WebGPU EP to be built with Emscripten for WebAssembly,
Including:

- cmake build files update to support correct setup for Emscripten.
- code changes to fix build breaks for wasm
- change in Web CI pipeline to add a build-only target for wasm with
`--use_webgpu`.
guschmue pushed a commit that referenced this pull request Mar 6, 2025
### Description

This PR allows WebGPU EP to be built with Emscripten for WebAssembly,
Including:


- cmake build files update to support correct setup for Emscripten.
- code changes to fix build breaks for wasm
- change in Web CI pipeline to add a build-only target for wasm with
`--use_webgpu`.
ashrit-ms pushed a commit that referenced this pull request Mar 17, 2025
### Description

This PR allows WebGPU EP to be built with Emscripten for WebAssembly,
Including:


- cmake build files update to support correct setup for Emscripten.
- code changes to fix build breaks for wasm
- change in Web CI pipeline to add a build-only target for wasm with
`--use_webgpu`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants