kaivalnp commented on code in PR #17013:
URL: https://github.com/apache/lucene/pull/17013#discussion_r4605233807


##########
lucene/core/src/java25/org/apache/lucene/internal/vectorization/MemorySegmentQuantizedVectorOps.java:
##########
@@ -0,0 +1,397 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.internal.vectorization;
+
+import static java.lang.foreign.ValueLayout.JAVA_BYTE;
+import static java.lang.foreign.ValueLayout.JAVA_LONG_UNALIGNED;
+import static java.nio.ByteOrder.LITTLE_ENDIAN;
+import static jdk.incubator.vector.VectorOperators.ADD;
+import static jdk.incubator.vector.VectorOperators.BIT_COUNT;
+import static jdk.incubator.vector.VectorOperators.LSHL;
+import static jdk.incubator.vector.VectorOperators.LSHR;
+import static jdk.incubator.vector.VectorOperators.ZERO_EXTEND_B2I;
+import static jdk.incubator.vector.VectorOperators.ZERO_EXTEND_B2S;
+import static jdk.incubator.vector.VectorOperators.ZERO_EXTEND_S2I;
+import static 
org.apache.lucene.internal.vectorization.PanamaVectorConstants.PRERERRED_INT_SPECIES;
+import static 
org.apache.lucene.internal.vectorization.PanamaVectorUtilSupport.BYTE_SPECIES;
+import static 
org.apache.lucene.internal.vectorization.PanamaVectorUtilSupport.BYTE_SPECIES_FULL;
+import static 
org.apache.lucene.internal.vectorization.PanamaVectorUtilSupport.SHORT_SPECIES;
+import static 
org.apache.lucene.internal.vectorization.PanamaVectorUtilSupport.VECTOR_BITSIZE;
+
+import java.lang.foreign.MemorySegment;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.VarHandle;
+import java.nio.ByteOrder;
+import jdk.incubator.vector.ByteVector;
+import jdk.incubator.vector.IntVector;
+import jdk.incubator.vector.LongVector;
+import jdk.incubator.vector.ShortVector;
+import jdk.incubator.vector.Vector;
+import jdk.incubator.vector.VectorShape;
+import jdk.incubator.vector.VectorSpecies;
+
+/**
+ * Dot products of a quantized query on heap with quantized vectors read in 
place from a {@link
+ * MemorySegment}, several vectors per pass so that the CPU overlaps their 
cache misses instead of
+ * waiting for the misses of one vector after the other. The 8 bit kernels 
read four vectors per
+ * pass; the 4, 2 and 1 bit kernels read two, because a pass over four would 
exceed the budget C2

Review Comment:
   This was pointed out to me by the AI, I don't think I would've found this by 
myself!
   
   Though I'm not sure if it missed something, I can try local workarounds like 
increasing `FreqInlineSize` or forcing inlining using `CompileCommand` 
directives.
   
   Perhaps another solution is to bypass C2 and rely on native functions for 
the most performant version 
(https://github.com/apache/lucene/pull/17013#issuecomment-6923257595).



-- 
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]

Reply via email to