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

BUG, SIMD: Fix 64-bit/8-bit integer division by a scalar #20297

Merged
merged 3 commits into from Nov 4, 2021

Conversation

charris
Copy link
Member

@charris charris commented Nov 3, 2021

Backport of #20153.

This pull request fixes two bugs:

  1. 64-bit integer division by a scalar for both unsigned and signed division,
    which was discovered by BUG: Bad SIMD integer // on windows in numpy 1.21.2 #20025.
    It's only limited to old versions of msvc <= 2017, due to inaccurate
    implementation of the emulated version for intrinsic _udiv128,
    which leads to producing an inaccurate multiplier.

  2. 8-bit unsigned integer division, similar to the above except it is not limited to a certain compiler
    and the inaccurate multiplier was caused due to wrong casting leads to perform quad division.
    it can be triggered if the ceil(log2(divisor)) == 8.

closes #20025, #20168

  The multiplier factor that used for integer division wasn't correctly
  calculated due inaccurate implementation of the emulated version
  of intrinsic `_udiv128`.
  Same as 64-bit divistion, except quad wide divison leads
  to inaccurate multiplier in certain cases when the log2 of
  the divisor overflow to zero.
@charris charris added 00 - Bug component: SIMD Issues in SIMD (fast instruction sets) code or machinery labels Nov 3, 2021
@charris charris added this to the 1.21.4 release milestone Nov 3, 2021
@charris charris added the 08 - Backport Used to tag backport PRs label Nov 3, 2021
@charris charris merged commit 3d1487b into numpy:maintenance/1.21.x Nov 4, 2021
@charris charris deleted the backport-20153 branch November 4, 2021 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 08 - Backport Used to tag backport PRs component: SIMD Issues in SIMD (fast instruction sets) code or machinery
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants