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

Fix a bug in format_float kernel #1676

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

thirtiseven
Copy link
Collaborator

format_number(0.485362439659, 13) will get 1.8536243965900 in the plugin. It's a kernel bug.

Current round_half_even will handle trailing zeros, but it's unnecessary because it will be handled later anyway, and it will confuse the following logic which checks the length of the rounded number.

Also add some minor refactoring and testing.

@thirtiseven
Copy link
Collaborator Author

build

bool const sign,
char* const result,
int digits)
__device__ inline int to_formated_double_chars(floating_decimal_64 const v,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Minor typo.

Suggested change
__device__ inline int to_formated_double_chars(floating_decimal_64 const v,
__device__ inline int to_formatted_double_chars(floating_decimal_64 const v,

bool const sign,
char* const result,
int digits)
__device__ inline int to_formated_float_chars(floating_decimal_32 const v,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit:

Suggested change
__device__ inline int to_formated_float_chars(floating_decimal_32 const v,
__device__ inline int to_formatted_float_chars(floating_decimal_32 const v,

Copy link
Collaborator

@mythrocks mythrocks left a comment

Choose a reason for hiding this comment

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

I'm ok with this change, but we're going to have to address some minor stuff in this source file, at some point.

  1. It would be good to add some function-level docs to to_formatted_float_chars, to_formatted_double_chars.
  2. Is there commonality between to_formatted_float_chars and to_formatted_double_chars? If we discount the difference of calling decimalLength17 and decimalLength9, they look like this could be a single function template. (I haven't looked closely enough, maybe?)
  3. Is actural_round supposed to be actual_round?

We can address this later, in a follow-on.

@thirtiseven
Copy link
Collaborator Author

Thanks for the review @mythrocks ! will address those later.

@thirtiseven thirtiseven merged commit e3fe415 into NVIDIA:branch-24.02 Jan 5, 2024
4 checks passed
@sameerz sameerz added the bug Something isn't working label Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants