Skip to content

Audit for truncf* - #1250

Merged
adpaco merged 9 commits into
model-checking:mainfrom
adpaco:audit-trunc
Jun 8, 2022
Merged

adpaco merged 9 commits into
model-checking:mainfrom
adpaco:audit-trunc

Conversation

@adpaco

@adpaco adpaco commented Jun 3, 2022

Copy link
Copy Markdown
Contributor

Description of changes:

Restores and completes the audit for the truncf32 (truncf) and truncf64 (trunc) intrinsics.

Resolved issues:

Part of #1163
Part of #1025

Call-outs:

Testing:

  • How is this change tested? Adds 2 tests.

  • Is this a refactor change? No.

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@adpaco
adpaco requested a review from a team as a code owner June 3, 2022 21:32
@adpaco adpaco changed the title Audit trunc Audit for truncf* Jun 3, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does fract use trunc under the hood?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is that a problem for the test, if it's just running (x - f) == (x - f)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's probably better to avoid it altogether.

It's quite hard to test these functions with symbolic values. Because of that, I've broken the truncf32 test into a three harnesses: One that tests a property for all values and two other for concrete values.

Please let me know what you think! Any suggestions on other tests are welcome.

@tedinski tedinski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure how to do better either, so LGTM

@danielsn

danielsn commented Jun 8, 2022 •

Copy link
Copy Markdown
Contributor

Can you test 0 <= x - trunc(x) < 1

@adpaco

adpaco commented Jun 8, 2022

Copy link
Copy Markdown
Contributor Author

Thanks @danielsn , this is now testing that property and a few more concrete cases.

@adpaco
adpaco merged commit dcb2992 into model-checking:main Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants