Skip to content

Conversation

@enum-class
Copy link
Contributor

use highway for SquaredL2 calculation.

Copy link
Member

@jan-wassenberg jan-wassenberg left a comment

Choose a reason for hiding this comment

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

Nice, thanks for vectorizing :)

ops.h Outdated
total += a[i] * a[i];
const hn::ScalableTag<float> d;
const size_t N = hn::Lanes(d);
HWY_DASSERT(size >= N);
Copy link
Member

Choose a reason for hiding this comment

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

Let's check >= 2*N, the loop step size.

ops.h Outdated

auto sum0 = hn::Zero(d);
auto sum1 = hn::Zero(d);
for (size_t i = 0; i + 2 * N <= size; i += 2 * N) {
Copy link
Member

Choose a reason for hiding this comment

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

I used to like this loop structure but GCC raises static analysis warnings about it due to overflow if (theoretically) i gets huge.
The safer alternative is to check if (size >= 2*N) (or assert, as you are already doing), then for (i = 0; i <= size - 2*N; i += 2*N). Does that make sense?

Copy link
Member

@jan-wassenberg jan-wassenberg left a comment

Choose a reason for hiding this comment

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

Thanks for making the change!

@jan-wassenberg jan-wassenberg added the copybara-import Trigger Copybara for merging pull requests label Mar 6, 2024
@enum-class
Copy link
Contributor Author

Same issue with copybara here, I think it needs a restart too:)

@jan-wassenberg jan-wassenberg added copybara-import Trigger Copybara for merging pull requests and removed copybara-import Trigger Copybara for merging pull requests labels Mar 8, 2024
@austinvhuang
Copy link
Contributor

Since #78 was merged this may need to merge the updated dev into this branch to be able to finalize the merge. May take a stab tomorrow if nobody else gets to it.

@austinvhuang austinvhuang added copybara-import Trigger Copybara for merging pull requests and removed copybara-import Trigger Copybara for merging pull requests labels Mar 11, 2024
@copybara-service copybara-service bot merged commit a9be065 into google:dev Mar 11, 2024
@austinvhuang
Copy link
Contributor

Thanks, merged now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copybara-import Trigger Copybara for merging pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants