msokolov commented on a change in pull request #2047: URL: https://github.com/apache/lucene-solr/pull/2047#discussion_r518030964
########## File path: lucene/core/src/java/org/apache/lucene/util/VectorUtil.java ########## @@ -25,47 +25,22 @@ private VectorUtil() { } - public static float dotProduct(float[] a, float[] b) { - float res = 0f; - /* - * If length of vector is larger than 8, we use unrolled dot product to accelerate the - * calculation. - */ - int i; - for (i = 0; i < a.length % 8; i++) { - res += b[i] * a[i]; - } - if (a.length < 8) { - return res; - } - float s0 = 0f; - float s1 = 0f; - float s2 = 0f; - float s3 = 0f; - float s4 = 0f; - float s5 = 0f; - float s6 = 0f; - float s7 = 0f; - for (; i + 7 < a.length; i += 8) { - s0 += b[i] * a[i]; - s1 += b[i + 1] * a[i + 1]; - s2 += b[i + 2] * a[i + 2]; - s3 += b[i + 3] * a[i + 3]; - s4 += b[i + 4] * a[i + 4]; - s5 += b[i + 5] * a[i + 5]; - s6 += b[i + 6] * a[i + 6]; - s7 += b[i + 7] * a[i + 7]; + public static double dotProduct(float[] a, float[] b) { Review comment: That's a fair comment. I put this in because we had someone do some extensive work on trying to optimize this code loop, and he found that unrolling like this made it more amenable to being expressed as AVX instructions, leading to some speedup, but it wasn't huge. Still - would you mind running some microbenchmark to see if there is any measurable change in performance with this? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org