-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Optimize pre-v6 ARM load/store on single-core systems #36
Conversation
This file contains 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
Yeah this basically sounds like what i was fighting with earlier today. |
Hmm, in release mode it is fine, but in debug mode it fails to compile due to the compiler cannot remove dead code: https://github.com/taiki-e/portable-atomic/runs/8173770404?check_suite_focus=true I should use inline asm for load/store as well like #18. |
taiki-e
force-pushed
the
armv4t
branch
2 times, most recently
from
September 4, 2022 04:17
77f1bf4
to
a958639
Compare
taiki-e
added
the
O-arm
Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state
label
Sep 4, 2022
bors r+ |
bors bot
added a commit
that referenced
this pull request
Sep 4, 2022
36: Optimize pre-v6 ARM load/store on single-core systems r=taiki-e a=taiki-e Since pre-v6[^v6] ARM has no Data Memory Barrier and cannot implement atomic in a way compatible with v6 and later multicore CPUs without OS helpers, LLVM generates libcalls for atomic operations that require synchronization, such as Acquire/Release and SeqCst. Currently, (when `portable_atomic_unsafe_assume_single_core` cfg is used) we consider this as "atomic load/store are not available on pre-v6 ARM" and always disable interrupts. However, relaxed load+compiler fence can do this more efficiently since we know it is single-core. https://github.com/taiki-e/portable-atomic/blob/e6e1500f440e6a79d87f4471924c5e6613594b51/src/imp/interrupt/mod.rs#L34-L35 https://github.com/taiki-e/portable-atomic/blob/e6e1500f440e6a79d87f4471924c5e6613594b51/src/imp/interrupt/mod.rs#L23-L29 FYI `@Lokathor` [^v6]: ARMv6 except for ARMv6-M also does not have the DMB instruction, but there is [a special instruction equivalent to DMB](https://developer.arm.com/documentation/ddi0360/e/control-coprocessor-cp15/register-descriptions/c7--cache-operations-register?lang=en). Co-authored-by: Taiki Endo <te316e89@gmail.com>
Build failed: |
bors retry |
bors bot
added a commit
that referenced
this pull request
Sep 4, 2022
36: Optimize pre-v6 ARM load/store on single-core systems r=taiki-e a=taiki-e Since pre-v6[^v6] ARM has no Data Memory Barrier and cannot implement atomic in a way compatible with v6 and later multicore CPUs without OS helpers, LLVM generates libcalls for atomic operations that require synchronization, such as Acquire/Release and SeqCst. Currently, (when `portable_atomic_unsafe_assume_single_core` cfg is used) we consider this as "atomic load/store are not available on pre-v6 ARM" and always disable interrupts. However, relaxed load+compiler fence can do this more efficiently since we know it is single-core. https://github.com/taiki-e/portable-atomic/blob/e6e1500f440e6a79d87f4471924c5e6613594b51/src/imp/interrupt/mod.rs#L34-L35 https://github.com/taiki-e/portable-atomic/blob/e6e1500f440e6a79d87f4471924c5e6613594b51/src/imp/interrupt/mod.rs#L23-L29 FYI `@Lokathor` [^v6]: ARMv6 except for ARMv6-M also does not have the DMB instruction, but there is [a special instruction equivalent to DMB](https://developer.arm.com/documentation/ddi0360/e/control-coprocessor-cp15/register-descriptions/c7--cache-operations-register?lang=en). Co-authored-by: Taiki Endo <te316e89@gmail.com>
Build failed: |
bors retry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
O-arm
Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state
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.
Since pre-v61 ARM has no Data Memory Barrier and cannot implement atomic in a way compatible with v6 and later multicore CPUs without OS helpers, LLVM generates libcalls for atomic operations that require synchronization, such as Acquire/Release and SeqCst.
Currently, (when
portable_atomic_unsafe_assume_single_core
cfg is used) we consider this as "atomic load/store are not available on pre-v6 ARM" and always disable interrupts. However, relaxed load+compiler fence can do this more efficiently since we know it is single-core.portable-atomic/src/imp/interrupt/mod.rs
Lines 34 to 35 in e6e1500
portable-atomic/src/imp/interrupt/mod.rs
Lines 23 to 29 in e6e1500
FYI @Lokathor
Footnotes
ARMv6 except for ARMv6-M also does not have the DMB instruction, but there is a special instruction equivalent to DMB. ↩