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

[aot] Support multi-target builds for Apple M1 #6083

Merged
merged 5 commits into from
Sep 19, 2022

Conversation

PENGUINLIONG
Copy link
Member

This PR enables Taichi to be built into multi-target libraries. Recent releases of macOS supports dynamically linking against x86_64 or arm64 of the same .dylib on demand, depending on the arch of the parent process. Previously this was not possible because the CMake script forced a -march=nehalem that is not a kind of arm64; and CMAKE_OSX_ARCHITECTURES is forced arm64.

The multi-target feature is only enabled with -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64". Python builds will select one of the archs, based on the arch of the skbuild Python process.

图片

@netlify
Copy link

netlify bot commented Sep 16, 2022

Deploy Preview for docsite-preview ready!

Name Link
🔨 Latest commit 939d8f0
🔍 Latest deploy log https://app.netlify.com/sites/docsite-preview/deploys/632556b644cb620009da5ea9
😎 Deploy Preview https://deploy-preview-6083--docsite-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@bobcao3
Copy link
Collaborator

bobcao3 commented Sep 16, 2022

What about MoltenVK? Do we need to start building and linking to it statically?

@PENGUINLIONG
Copy link
Member Author

What about MoltenVK? Do we need to start building and linking to it statically?

@bobcao3 MoltenVK in VulkanSDK is already multitargeting.

@bobcao3
Copy link
Collaborator

bobcao3 commented Sep 17, 2022

What about MoltenVK? Do we need to start building and linking to it statically?

@bobcao3 MoltenVK in VulkanSDK is already multitargeting.

What about the version from homebrew, which is the one we are using?

@PENGUINLIONG
Copy link
Member Author

What about MoltenVK? Do we need to start building and linking to it statically?

@bobcao3 MoltenVK in VulkanSDK is already multitargeting.

What about the version from homebrew, which is the one we are using?

Ah, yes. Homebrew serves on a per-arch basis, and our test runs install MoltenVK from homebrew. It could be an issue if someone installed homebrew molten-vk and a x86_64 Anaconda 3 (like me). We can resolve this issue in a future PR I think. And we can then get rid of the annoying TI_LIB_DIR.

@bobcao3
Copy link
Collaborator

bobcao3 commented Sep 17, 2022

What about MoltenVK? Do we need to start building and linking to it statically?

@bobcao3 MoltenVK in VulkanSDK is already multitargeting.

What about the version from homebrew, which is the one we are using?

Ah, yes. Homebrew serves on a per-arch basis, and our test runs install MoltenVK from homebrew. It could be an issue if someone installed homebrew molten-vk and a x86_64 Anaconda 3 (like me). We can resolve this issue in a future PR I think. And we can then get rid of the annoying TI_LIB_DIR.

Currently we ship a molten dylib, so it will not work

@PENGUINLIONG
Copy link
Member Author

What about MoltenVK? Do we need to start building and linking to it statically?

@bobcao3 MoltenVK in VulkanSDK is already multitargeting.

What about the version from homebrew, which is the one we are using?

Ah, yes. Homebrew serves on a per-arch basis, and our test runs install MoltenVK from homebrew. It could be an issue if someone installed homebrew molten-vk and a x86_64 Anaconda 3 (like me). We can resolve this issue in a future PR I think. And we can then get rid of the annoying TI_LIB_DIR.

Currently we ship a molten dylib, so it will not work

Shouldn't be a problem atm? As mentioned before the Python wheels are built per-arch so it won't break the existing release pipeline (as the tests do). The multi-target lib can only be built if the user explicitly specify -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" in the cmake args. We still have a buffer of time to clean things up yet I somehow prefer to keep the PRs small enough to be legible.

Copy link
Contributor

@ailzhang ailzhang left a comment

Choose a reason for hiding this comment

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

LGTM!

@PENGUINLIONG PENGUINLIONG merged commit 88f030e into taichi-dev:master Sep 19, 2022
@PENGUINLIONG PENGUINLIONG deleted the m1-multi-target1 branch September 19, 2022 09:05
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