-
Notifications
You must be signed in to change notification settings - Fork 107
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
Implement optimized decoded square distance #89
Conversation
@@ -128,8 +128,6 @@ static float dotProduct64(float[] v1, int v1offset, float[] v2, int v2offset, in | |||
if (length == FloatVector.SPECIES_64.length()) | |||
return dot64(v1, v1offset, v2, v2offset); | |||
|
|||
assert length == 3; // or we should be calling dot 128 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: this is removed because it's not quite right. You could be down this code path with a one-dimensional vector, which is valid everywhere else in the codebase
return diff.mul(diff).reduceLanes(VectorOperators.ADD); | ||
} | ||
|
||
static float squareDistance512(float[] v1, int offset1, float[] v2, int offset2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be squareDistancePreferred
, will fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but please update decodedSquareDistance to use vectorized sum like I updated decodedDP to do
Pushed update to use VectorUtil.sum. Thank you for the review! |
This also implements the necessary SimdOps backing methods, mirroring the dotProduct implementation.
As a side benefit, PQ encoding is about twice as fast.