Cleanup byte swapping utilities to generate optimal code on the platforms we care about.#11394
Closed
resistor wants to merge 1 commit intopytorch:masterfrom
Closed
Cleanup byte swapping utilities to generate optimal code on the platforms we care about.#11394resistor wants to merge 1 commit intopytorch:masterfrom
resistor wants to merge 1 commit intopytorch:masterfrom
Conversation
soumith
approved these changes
Sep 7, 2018
bc610a9 to
232402d
Compare
…orms we care about.
While the use of memcpy as part of the byte swapping sequence looks funky, all major
compilers recognize and optimize this pattern reliably, resulting in essentially
optimal code generation.
For example, decodeUInt32LE goes from this on iOS arm64:
ldrb w8, [x0, pytorch#3]
ldrb w9, [x0, pytorch#2]
bfi w8, w9, pytorch#8, pytorch#8
ldrb w9, [x0, pytorch#1]
bfi w8, w9, pytorch#16, pytorch#8
ldrb w9, [x0]
bfi w8, w9, pytorch#24, pytorch#8
mov x0, x8
ret
To this:
ldr w8, [x0]
rev w0, w8
ret
Contributor
facebook-github-bot
left a comment
There was a problem hiding this comment.
resistor has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Contributor
facebook-github-bot
left a comment
There was a problem hiding this comment.
resistor is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Contributor
facebook-github-bot
left a comment
There was a problem hiding this comment.
resistor has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
PenghuiCheng
pushed a commit
to PenghuiCheng/pytorch
that referenced
this pull request
Sep 11, 2018
…orms we care about. (pytorch#11394) Summary: While the use of memcpy as part of the byte swapping sequence looks funky, all major compilers recognize and optimize this pattern reliably, resulting in essentially optimal code generation. For example, decodeUInt32LE goes from this on iOS arm64: > ldrb w8, [x0, pytorch#3] > ldrb w9, [x0, pytorch#2] > bfi w8, w9, pytorch#8, pytorch#8 > ldrb w9, [x0, pytorch#1] > bfi w8, w9, pytorch#16, pytorch#8 > ldrb w9, [x0] > bfi w8, w9, pytorch#24, pytorch#8 > mov x0, x8 > ret To this: > ldr w8, [x0] > rev w0, w8 > ret Pull Request resolved: pytorch#11394 Reviewed By: SsnL Differential Revision: D9728659 Pulled By: resistor fbshipit-source-id: 9afbd4adfad1d1fb7b01f1179e6707ee21fa726f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While the use of memcpy as part of the byte swapping sequence looks funky, all major
compilers recognize and optimize this pattern reliably, resulting in essentially
optimal code generation.
For example, decodeUInt32LE goes from this on iOS arm64:
To this: