msokolov commented on code in PR #913:
URL: https://github.com/apache/lucene/pull/913#discussion_r878686983
##########
lucene/core/src/java/org/apache/lucene/util/VectorUtil.java:
##########
@@ -213,4 +213,21 @@ public static void add(float[] u, float[] v) {
u[i] += v[i];
}
}
+
+ public static float dotProduct(BytesRef a, int aOffset, BytesRef b, int
bOffset, int len) {
+ // fixme -- move to codec? What if later we want to access the bytes some
other way?
+ int total = 0;
+ for (int i = 0; i < len; i++) {
+ total += a.bytes[aOffset++] * b.bytes[bOffset++];
Review Comment:
> i wonder if we can coerce autovectorization of this loop somehow too.
That would be cool. Continuing down the Vector track, I ran some JMH
benchmarks. I don't want to get too deep into it here, but it does seem that
`Vector<Short>.castShape()` followed by `reduceLanesToLong` produces the
correct result, is quite a bit faster than the equivalent operation over
`FloatVector`, and is nearly as fast as adding up and accumulating Bytes (which
produces the wrong result).`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]