-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Concrete SIMD.init(repeating:) and SIMD.init(lowHalf:highHalf:) optimizations #81766
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
Concrete SIMD.init(repeating:) and SIMD.init(lowHalf:highHalf:) optimizations #81766
Conversation
@swift-ci test |
@swift-ci benchmark |
(I don't think that this will move much in the benchmark suite, but we have determined that it's a significant win via inspection of the generated assembly for newly added test cases) |
Split these out into separate files for Mask, Integer, Float, since each has a somewhat different set of operations.
Previously these were not transparent, and so were not generally inlined in debug; that's basically always a win because LLVM knows how to optimize them to single instructions + some debugging bookkeeping (which we should also figure out how to eliminate). Add FileCheck tests that ensure that we get optimal -O codegen and near-optimal -Onone codegen.
I had hoped that swiftlang#54445 would unblock these, but it doesn't seem to quite be the complete story yet (or at least, these were still failing as implemented).
0cf3d34
to
7a00619
Compare
@swift-ci test |
We drop the _ on Linux, so keep just the Swift mangling part.
@swift-ci smoke test |
@swift-ci smoke test |
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.
build system changes look good to me.
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.
Build changes LGTM too
The PR swiftlang#81766 introduced some concrete SIMD operations, but `init(repeating:)` was temporarily disabled due to differentiation testing break. See: stephentyrone@7a00619 This PR contains two changes: 1. Define custom derivatives for concrete `init(repeating:)` so we do not fall into non-differentiability error diagnostic. 2. Add a fix to SIL linker so differentiability witness lookup is done when the original function has both `@_alwaysEmitIntoClient` and `@_transparent`. Similar changes were introduced previously in swiftlang#78908, but they only handled `@_alwaysEmitIntoClient` without `@_transparent`.
The PR swiftlang#81766 introduced some concrete SIMD operations, but `init(repeating:)` was temporarily disabled due to differentiation testing break. See: stephentyrone@7a00619 This PR contains two changes: 1. Define custom derivatives for concrete `init(repeating:)` so we do not fall into non-differentiability error diagnostic. 2. Add a fix to SIL linker so differentiability witness lookup is done when the original function has both `@_alwaysEmitIntoClient` and `@_transparent`. Similar changes were introduced previously in swiftlang#78908, but they only handled `@_alwaysEmitIntoClient` without `@_transparent`.
The PR #81766 introduced some concrete SIMD operations, but `init(repeating:)` was temporarily disabled due to differentiation testing break. See: stephentyrone@7a00619 This PR contains two changes: 1. Define custom derivatives for concrete `init(repeating:)` so we do not fall into non-differentiability error diagnostic. 2. Add a fix to SIL linker so differentiability witness lookup is done when the original function has both `@_alwaysEmitIntoClient` and `@_transparent`. Similar changes were introduced previously in #78908, but they only handled `@_alwaysEmitIntoClient` without `@_transparent`. <!-- If this pull request is targeting a release branch, please fill out the following form: https://github.com/swiftlang/.github/blob/main/PULL_REQUEST_TEMPLATE/release.md?plain=1 Otherwise, replace this comment with a description of your changes and rationale. Provide links to external references/discussions if appropriate. If this pull request resolves any GitHub issues, link them like so: Resolves <link to issue>, resolves <link to another issue>. For more information about linking a pull request to an issue, see: https://docs.github.com/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue --> <!-- Before merging this pull request, you must run the Swift continuous integration tests. For information about triggering CI builds via @swift-ci, see: https://github.com/apple/swift/blob/main/docs/ContinuousIntegration.md#swift-ci Thank you for your contribution to Swift! -->
WIP to add more overloads to optimize SIMD codegen on concrete types. Here we do:
These are always inlined, even in debug, since LLVM knows how to lower them to one or two instructions on the targets that we care about.