Skip to content

Remove float symbols from apps that use the NFCController class #12401

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

Merged
merged 1 commit into from
Feb 12, 2020

Conversation

hugueskamba
Copy link
Collaborator

@hugueskamba hugueskamba commented Feb 10, 2020

Summary of changes

Use the Ticker API that does not use floating point types and literal.
Also pass timeout in seconds instead of incorrectly passing milliseconds.

Impact of changes

Migration actions required

Documentation


Pull request type

[X] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[X] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers

@kjbracey-arm @evedon


@hugueskamba hugueskamba force-pushed the hk-remove-float-in-ticker branch from 9636fca to 4ba9e9c Compare February 10, 2020 13:49
drivers/Ticker.h Outdated
#else
template <typename F> MBED_FORCEINLINE
#endif
void attach(F &&func, float t)
Copy link
Contributor

@kjbracey kjbracey Feb 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the forwarding being dropped? It reduced code size (by avoiding a relatively-expensive Callback->Callback copy). Does it have any bearing on the float elimination?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it does not. I was checking if float elimination needed that. I will put it back for code size reduction.

drivers/Ticker.h Outdated
{
attach_us(std::forward<F>(func), t * 1000000.0f);
attach_us(func, (int)(t * 1000000));
Copy link
Contributor

@kjbracey kjbracey Feb 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the API for anything >2000s. Is it the limiting to 32-bit that is making the difference for your test?

And that test is a non-constant use, I gather? Someone passing a non-constant integer to this?

If trying to avoid float use, you should fix the calling code to not use floats, not break this API.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the calling code as follows without making any changes to Ticker.h does not remove float symbols.

void NFCController::scheduler_process(bool hw_interrupt)
{
    _timeout.detach(); // Cancel timeout - if it triggers, it's ok as we'll have an "early" iteration which will likely be a no-op

    // Process stack events
    uint32_t timeout_ms = nfc_scheduler_iteration(_scheduler, hw_interrupt ? EVENT_HW_INTERRUPT : EVENT_NONE);

    _timeout.attach(
        callback(this, &NFCController::on_timeout),
        timeout_ms/1000 // convert milliseconds to seconds <=====
    );
}

Copy link
Contributor

@kjbracey kjbracey Feb 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, no, because you're still using the attach(float).

That should be

_timeout.attach_us(cb(blah), timeout_ms * (us_timestamp_t) 1000);

(Cast needed to ensure it's a 64-bit multiply, not a 32-bit one).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@mergify mergify bot added the needs: work label Feb 10, 2020
@hugueskamba hugueskamba force-pushed the hk-remove-float-in-ticker branch from 4ba9e9c to 42bf813 Compare February 10, 2020 14:00
@mergify mergify bot dismissed kjbracey’s stale review February 10, 2020 14:01

Pull request has been modified.

Use the `Ticker` API that does not use floating point types and literal.
Also pass timeout in seconds instead of incorrectly passing milliseconds.
@hugueskamba hugueskamba force-pushed the hk-remove-float-in-ticker branch from 42bf813 to ec2c341 Compare February 10, 2020 15:00
@hugueskamba hugueskamba changed the title Removed float symbols from Ticker module Remove float symbols from apps that use the NFCController class Feb 10, 2020
@ciarmcom ciarmcom requested review from evedon, kjbracey and a team February 10, 2020 16:00
@ciarmcom
Copy link
Member

@hugueskamba, thank you for your changes.
@kjbracey-arm @evedon @ARMmbed/mbed-os-pan @ARMmbed/mbed-os-maintainers please review.

Copy link
Contributor

@evedon evedon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple change at the end :-)

You might want to repeat the title in the Impact of change section.

@mergify mergify bot added needs: CI and removed needs: review labels Feb 10, 2020
@kjbracey
Copy link
Contributor

The description is a bit backwards - the main change is now the 1000 times scheduling speed-up, not the removal of float use, even if it's not the reason you approached it in the first place.

As such, it should be reviewed by @donatieng or @pan- or someone in NFC area. I can only assume there was a lack of test coverage here - nothing actually needing to trigger any retries?

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 11, 2020

CI started meanwhile

@mbed-ci
Copy link

mbed-ci commented Feb 11, 2020

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 11, 2020

As such, it should be reviewed by @donatieng or @pan- or someone in NFC area. I can only assume there was a lack of test coverage here - nothing actually needing to trigger any retries?

Set this one for review stage

Copy link
Member

@pan- pan- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@0xc0170 0xc0170 added release-version: 6.0.0-alpha-2 Second pre-release version of 6.0.0 and removed needs: review labels Feb 12, 2020
@0xc0170 0xc0170 merged commit 69a2803 into ARMmbed:master Feb 12, 2020
@hugueskamba hugueskamba deleted the hk-remove-float-in-ticker branch February 13, 2020 18:02
This was referenced Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-version: 6.0.0-alpha-2 Second pre-release version of 6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants