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

[WebGPU] Support crosscompiling on windows platform #22777

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

Conversation

shaoboyan
Copy link

Compile onnxruntime with --use_webgpu triggers dawn's compilation. Dawn build dxc from sources in third_party folders. However, dxc has poor support for crosscompilation (e.g. build arm64 on x64 platform).
See details: microsoft/DirectXShaderCompiler#7000

This PR support crosscompilation through:

  • Build llvm-tblgen and clang-tblgen in configuration step with host cpu arch.
  • Use the built tool do build dxc and dawn
  • Copy dxil.dll from correct target arch folder (e.g. target is arm64 and copy from arm64/ folder instead of x64 folder always)

Using local patch to host these changes for Dawn.

Description

Motivation and Context

Compile onnxruntime with --use_webgpu triggers dawn's compilation.
Dawn build dxc from sources in third_party folders. However, dxc
has poor support for crosscompilation (e.g. build arm64 on x64
platform).
See details: microsoft/DirectXShaderCompiler#7000

This PR support crosscompilation through:
- Build llvm-tblgen and clang-tblgen in configuration step with host cpu
  arch.
- Use the built tool do build dxc and dawn
- Copy dxil.dll from correct target arch folder (e.g. target is arm64
  and copy from arm64/ folder instead of x64 folder always)

Using local patch to host these changes for Dawn.
@guschmue guschmue added the ep:WebGPU ort-web webgpu provider label Nov 12, 2024

+# Disable CMAKE_CROSSCOMPING because we don't have full support
+if(CMAKE_CROSSCOMPILING)
+ set(CMAKE_CROSSCOMPILING OFF)
Copy link
Member

Choose a reason for hiding this comment

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

But we are doing cross-compiling? Usually the var is set to ON when the CMAKE_SYSTEM_NAME variable has been set manually. And usually we only read from this var, we do not set it. I worry a lot of other cmake functions/modules may rely on this var.

Copy link
Author

@shaoboyan shaoboyan Nov 13, 2024

Choose a reason for hiding this comment

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

I think we can remove this. Let me have a try locally.

+ file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/native-tools)
+ endif()
+
+ if (NOT CLANG_TBLGEN OR NOT LLVM_TBLGEN)
Copy link
Member

Choose a reason for hiding this comment

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

This part is complicated. I think we may ask the user to provide a prebuilt binary instead. Like what we do now for protoc.exe .

Copy link
Member

Choose a reason for hiding this comment

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

When we build onnxruntime on Windows, we also pass in a lot of other cmake parameters like "-A Win32 --toolset 14.40". These flags cannot be handled here.

Copy link
Author

Choose a reason for hiding this comment

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

This part is complicated. I think we may ask the user to provide a prebuilt binary instead. Like what we do now for protoc.exe

It would be ideal that user could provided the pre-baked tool for this.

When we build onnxruntime on Windows, we also pass in a lot of other cmake parameters like "-A Win32 --toolset 14.40". These flags cannot be handled here.
My understanding is that in crosscompilation situation, the llvm-talgen and clang-tblgen are built in default behaviour? (Because we don't have extra params to define the behaviour)

@guschmue
Copy link
Contributor

fix is working for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ep:WebGPU ort-web webgpu provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants