Skip to content
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

feat(gnovm): add software floating point package #3185

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

omarsy
Copy link
Member

@omarsy omarsy commented Nov 23, 2024

Closes: #312

The idea to use softfloat and work originates from this PR: #2863

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Nov 23, 2024
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Nov 28, 2024

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 The pull request was created from a fork (head branch repo: omarsy/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

@github-actions github-actions bot added the 📦 ⛰️ gno.land Issues or PRs gno.land package related label Nov 28, 2024
@omarsy omarsy force-pushed the feat/312 branch 7 times, most recently from 34120ef to d4eecff Compare December 1, 2024 23:46
@omarsy omarsy force-pushed the feat/312 branch 2 times, most recently from afe2028 to 182cde0 Compare December 2, 2024 23:28
@omarsy omarsy marked this pull request as ready for review December 3, 2024 21:22
@omarsy omarsy requested a review from thehowl December 3, 2024 21:56
@Kouteki Kouteki added the in focus Core team is prioritizing this work label Dec 5, 2024
@Kouteki Kouteki added this to the 🚀 Mainnet launch milestone Dec 5, 2024
Copy link
Contributor

@petar-dambovaliev petar-dambovaliev left a comment

Choose a reason for hiding this comment

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

Good job!

Copy link
Member

Choose a reason for hiding this comment

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

don't create specific types with methods; just make GetFloat32 and GetFloat64 return uint32 and uint64 and make the operations, for instance the ones in op_binary.go, directly use the softfloat package.

the custom type doesn't add much aside from wrapping the calls to the internal package, while having op_binary.go use softfloat.Lte makes very explicit what's going on.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I introduced the custom types with methods to improve readability, as I felt it made the code clearer and more explicit about the software floating-point operations. However, I understand your point about avoiding unnecessary abstraction. I will follow the Gno code standards and adjust the implementation if you guys think this approach doesn’t align with the preferred style.

Copy link
Member Author

Choose a reason for hiding this comment

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

done here 7f7b888

tv.T = t
tv.SetInt(x)
case Int8Kind:
validate(Float32Kind, Int8Kind, func() bool {
val := float64(tv.GetFloat32())
trunc := math.Trunc(val)
trunc := tv.GetFloat32().Trunc()
Copy link
Member

Choose a reason for hiding this comment

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

Can we not use something like F32toint32 here, and all other places?

This would also avoid us having to use Trunc and Mod

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't know how you will remove the float part without a trunc ? Maybe you think about a new approach ?

Copy link
Member

Choose a reason for hiding this comment

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

apologies, I see now this is only used for constants.

Looks good then

@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 📦 🌐 tendermint v2 Issues or PRs tm2 related labels Dec 18, 2024
@omarsy omarsy force-pushed the feat/312 branch 8 times, most recently from b09a2c2 to 9426d5c Compare December 20, 2024 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in focus Core team is prioritizing this work 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

Test and document floating point determinsm
5 participants