Skip to content

EnsureLargeEnoughWave: Fix it when requesting powers of two#2604

Merged
t-b merged 2 commits intomainfrom
bugfix/2604-ensure-large-enough-wave
Jan 22, 2026
Merged

EnsureLargeEnoughWave: Fix it when requesting powers of two#2604
t-b merged 2 commits intomainfrom
bugfix/2604-ensure-large-enough-wave

Conversation

@t-b
Copy link
Collaborator

@t-b t-b commented Jan 21, 2026

Will merge once CI passes.

t-b added 2 commits January 21, 2026 17:02
max is a function with up to 100 optional arguments so let's use this.
When we request a power of two index which is larger than double the
wave size and MINIMUM_WAVE_SIZE we would calculate an indexShouldExist
which is exactly the same as the requested value.

So let's add one before finding the next power of two.

Bug introduced in 602d37c (EnsureLargeEnoughWave: Avoid resizing when not needed, 2025-04-16).
@t-b t-b self-assigned this Jan 21, 2026
Copilot AI review requested due to automatic review settings January 21, 2026 16:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a bug in EnsureLargeEnoughWave where requesting an index that is a power of two would result in insufficient wave size allocation. The issue occurred because FindNextPower returns the same power when given an exact power of two, rather than the next power.

Changes:

  • Fixed the power-of-two bug by adding 1 to the index before calling FindNextPower
  • Simplified nested max() calls into a single call with three arguments
  • Added a comprehensive test case to verify the fix

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Packages/MIES/MIES_Utilities_WaveHandling.ipf Fixed the calculation in EnsureLargeEnoughWave to handle power-of-two indices correctly and simplified the max() expression
Packages/tests/Basic/UTF_Utils_WaveHandling.ipf Added test ELE_WorksWithPowerOfTwoValue to verify the fix handles power-of-two indices correctly

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@t-b t-b merged commit a90507e into main Jan 22, 2026
40 of 42 checks passed
@t-b t-b deleted the bugfix/2604-ensure-large-enough-wave branch January 22, 2026 14:16
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.

1 participant

Comments