Skip to content

[SYCL][libdevice] Fix rounding issue in __imf_vavgs #8777

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 4 commits into from
May 8, 2023

Conversation

jinge90
Copy link
Contributor

@jinge90 jinge90 commented Mar 27, 2023

__imf_vavgs2/4 correspond to CUDA math function __vavgs2/4. CUDA __vavgs2/4 rounds to nearest, ties away from zero, so we need to apply the same rounding mode.
Signed-off-by: jinge90 [email protected]

@jinge90 jinge90 requested a review from a team as a code owner March 27, 2023 03:26
__imf_vavgs2/4  correspond to CUDA math function __vavgs2/4.
CUDA __vavgs2/4 rounds to nearest, ties away from zero, so we
need to apply the same rounding mode.
Signed-off-by: jinge90 <[email protected]>
@jinge90
Copy link
Contributor Author

jinge90 commented Mar 27, 2023

Hi, @akolesov-intel and @zettai-reido
As we discussed before, CUDA math __vavgs2/4 doesn't round to nearest even. CUDA document doesn't mention anything about rounding mode but based on experiments on real NV platform, these functions round to nearest, away from zero. Following are some simple inputs and results on NV platform:
__vavgs2(1, 2)------>2 // (1 + 2)/2 ------>2
__vavgs2(2, 3)------>3 // (2 + 3)/2------->3
__vavgs2(1, 3)------>2 // (1 + 3)/2------->2
__vavgs2(0xFFFF, 0xFFFE)------>0xFFFE // ((-1) + (-2))/2 -------> -2
__vavgs2(0xFFFE, 0xFFFD)------>0xFFFD // ((-2) + (-3))/2--------> -3
Thanks very much.

@jinge90 jinge90 temporarily deployed to aws March 27, 2023 04:24 — with GitHub Actions Inactive
@jinge90 jinge90 temporarily deployed to aws March 27, 2023 04:57 — with GitHub Actions Inactive
@jinge90 jinge90 temporarily deployed to aws April 26, 2023 04:55 — with GitHub Actions Inactive
@jinge90 jinge90 temporarily deployed to aws April 26, 2023 07:56 — with GitHub Actions Inactive
@jinge90 jinge90 temporarily deployed to aws May 4, 2023 08:42 — with GitHub Actions Inactive
@jinge90 jinge90 temporarily deployed to aws May 4, 2023 09:55 — with GitHub Actions Inactive
Copy link

@akolesov-nv akolesov-nv left a comment

Choose a reason for hiding this comment

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

Looks good to me

@aelovikov-intel aelovikov-intel merged commit 38d0536 into intel:sycl May 8, 2023
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