-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Assembler atomics #10147
Assembler atomics #10147
Conversation
@kjbracey-arm, thank you for your changes. |
I'm now looking at a full rework here, which will reduce the source size and turn it into assembler, with the possibility of better code generation. |
Will close temporarily. |
b8bf0f7
to
cc1747a
Compare
cc1747a
to
a2a31ad
Compare
Hmm, this got nicked with the Astyle update bork. Incoming fix from: #10221 |
Hmm... The astyle fix is missing this fix: #10222 |
@kjbracey-arm please re-base when you have time, it should resolve the astyle issue |
827cc51
to
16eee15
Compare
53a3682
to
3c36dfe
Compare
Test run: FAILEDSummary: 3 of 7 test jobs failed Failed test jobs:
|
@kjbracey-arm Please look at test failures |
Reimplement atomic code in inline assembly. This can improve optimisation, and avoids potential architectural problems with using LDREX/STREX intrinsics. API further extended: * Bitwise operations (fetch_and/fetch_or/fetch_xor) * fetch_add and fetch_sub (like incr/decr, but returning old value - aligning with C++11) * compare_exchange_weak * Explicit memory order specification * Basic freestanding template overloads for C++ This gives our existing C implementation essentially all the functionality needed by C++11. An actual Atomic<T> template based upon these C functions could follow.
These are platform tests, but rely on the RTOS to run multiple threads to exercise it. (The atomics are still useful in non-RTOS, to protect against interrupt handlers, but testing versus other threads is easier. The implementation is the same either way, so doesn't seem worth testing non-RTOS specifically).
Get rid of a volatile, and use atomics to synchronise with the interrupt routine instead. Useful as a non-RTOS basic compilation check for the atomics - the fuller atomic test relies on the RTOS.
Volatile makes no real difference when we're using assembler, or locked functions, but leaving it off could be more efficient for the basic loads and stores. So add non-volatile overloads in C++ for them.
1632263
to
2bb4045
Compare
Thought I'd done enough fork tests to find all the glitches, but apparently not. Fixed the flash_api.c build failure there for LPC55S69_NS. Didn't see anything else. |
@ARMmbed/mbed-os-core Could somebody please review this ? |
@donatieng @bulislaw Can you help reviewing these? |
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.
Looks good, but to be fair I didn't dive into the implementation file.
CI started |
Test run: FAILEDSummary: 2 of 11 test jobs failed Failed test jobs:
|
CI restarted (py3 problem should be gone now) |
Test run: FAILEDSummary: 1 of 11 test jobs failed Failed test jobs:
|
Exporters restarted |
Build errors in mbed-os tests with ARMC5 toolchain started to come from 13th of May. Can you please check why this pull request is effecting the build? and they seem related too! [DEBUG] Output: "./mbed-os/platform/internal/mbed_atomic_impl.h", line 306: Error: #52: expected a macro parameter name The build was passing on May 13, 2019 2:06:40 AM but after that it failed on May 13, 2019 2:43 PM (UK time) |
@SanaMasood - thanks for notification, I've made a PR for the fix. |
Description
Reimplement atomic code in inline assembly. This can improve optimisation, and avoids potential architectural problems with using LDREX/STREX intrinsics.
API further extended:
fetch_and
/fetch_or
/fetch_xor
)fetch_add
andfetch_sub
(likeincr
/decr
, but returning old value - aligning with C++11)compare_exchange_weak
This gives our existing C implementation essentially all the functionality needed by C++11.
An actual
Atomic<T>
template based upon these C functions could follow.Preliminary work for #10104.
Pull request type
Release Notes
mbed_atomic.h
frommbed_critical.h
. Code not includingmbed.h
may need to to check their includes.fetch_add
,fetch_sub
,fetch_and
,fetch_or
,fetch_xor
andcompare_exchange_weak
operations added.