-
Notifications
You must be signed in to change notification settings - Fork 3k
Force inline Timer::attach() to get rid of floating-point instructions #11236
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
Force inline Timer::attach() to get rid of floating-point instructions #11236
Conversation
@hugueskamba, thank you for your changes. |
Personally I'm not that strongly opposed to the I'm a bit wary about making changes to any time-related APIs at this point, because we have just shifted to C++14. That opens the door to doing all time-related APIs better using
That could work now, with ARMC6, GCC and IAR, but we don't have chrono for ARMC5 yet, and I don't want to totally break it. But if we are making a change, I'd want the change to be to that, rather than some intermediate. But given that
|
Build the example project I'll let @evedon comment on the rest of your comment. |
Which toolchain(s) and profiles were you looking at for the ELF? |
GCC_ARM |
We are trying to remove usage of floats In mbed-os where it is not necessary. I think that this attach |
Removing unnecessary usage is good, but I'm a bit wary about outright yanking APIs. In this case, the problem does seem to be arising due to reluctance of the compiler to inline But if you add I'd be happy with something like that as an interim measure (pending a For other non-time-related unnecessarily-float driver APIs, like ADC, I'd be a bit less reticent to make changes - it's just that time is an overall system, and I'm not keen on seeing piecemeal changes that are not in the direction I ultimately expect it to go in ( |
Still, I can live with (But I would like to deprecate all non-chrono C++ time APIs, including But do consider whether just adding the |
If indeed |
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.
Nice solution indeed !
It is possible this has a negative effect of inlining an extra call to the A possible alternative would be to turn it into perfect-forwarding template:
(That's the C++11 for "forward any F, preserving type/lifetime info by using an appropriate reference"). That version then might not actually need a
|
In light of the last comment, I would rather go back to the previous solution i.e. introduce a new |
Actually, just realised there is no binary compatibility issue - this is C++ inlining, so anyone using the old version non-inlined would have generated their own common out-of-line definition in their object file, they wouldn't be relying on us giving them one. I was thinking in C99. |
@evedon @kjbracey-arm |
Did you observe a size difference between those last two versions, at least? |
* Restore previous implementation as deprecated * Ensure method call is unambiguous
Calls to Timer::attach() are inlined in order not to use floating-point library functions calls given Timer::attach_us() expects an integer for the callback interval.
This prevents a possible heavy callback copy.
Also fix code style to please style checker
1f5b4db
to
3373d78
Compare
Force pushed after rebasing from master because of intermittent CI failure. |
Test run: FAILEDSummary: 2 of 4 test jobs failed Failed test jobs:
|
CI re-started |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Add release notes, will be merged afterwards |
I would say this isn't actually a functionality change - it's a refactor. |
@0xc0170 Indeed it is a refactor (description updated). |
Description
Calls to Timer::attach() are inlined in order not to use floating-point
library functions calls given Timer::attach_us() expects an integer
for the callback interval.
Pull request type
Reviewers
@evedon @gpsimenos @jamesbeyond
Release Notes