gsmiller commented on a change in pull request #69:
URL: https://github.com/apache/lucene/pull/69#discussion_r609733110
##########
File path: lucene/core/src/java/org/apache/lucene/codecs/lucene90/PForUtil.java
##########
@@ -121,4 +167,146 @@ void skip(DataInput in) throws IOException {
in.skipBytes(forUtil.numBytes(bitsPerValue) + (numExceptions << 1));
}
}
+
+ /**
+ * Fill {@code longs} with the final values for the case of all deltas being
1. Note this assumes
+ * there are no exceptions to apply.
+ */
+ private static void prefixSumOfOnes(long[] longs, long base) {
+ System.arraycopy(IDENTITY_PLUS_ONE, 0, longs, 0, ForUtil.BLOCK_SIZE);
+ // This loop gets auto-vectorized
+ for (int i = 0; i < ForUtil.BLOCK_SIZE; ++i) {
+ longs[i] += base;
+ }
+ }
+
+ /**
+ * Fill {@code longs} with the final values for the case of all deltas being
{@code val}. Note
+ * this assumes there are no exceptions to apply.
+ */
+ private static void prefixSumOf(long[] longs, long base, long val) {
+ for (int i = 0; i < ForUtil.BLOCK_SIZE; i++) {
+ longs[i] = (i + 1) * val + base;
Review comment:
Interesting thought @rmuir. I'll tweak this to see what kind of
difference it makes, but we can't replace `ForUtil.BLOCK_SIZE` with
`array.length` in the production code. The array length is actually one more
than `ForUtil.BLOCK_SIZE` (as used in `Lucene90PostingsReader`). (See
[L317](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90PostingsReader.java#L317)
for example). It populates that 129th value with `NO_MORE_DOCS` (i.e.,
`MAX_INT`) as a end-of-block marker. This was the source of a very frustrating
debugging effort on my part while working on this, since early on I was
actually using `array.length` instead :)
UPDATE: I tried with both `array.length - 1` (which we'd need to actually
use in production) as well as `array.length` (just to see if it mattered) and
didn't get any auto-vectorization. The assembly looked the same to my eye.
Thanks for the suggestion though!
--
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]