@@ -32,6 +32,7 @@ public final class JdkVectorLibrary implements VectorLibrary {
3232 static final Logger logger = LogManager .getLogger (JdkVectorLibrary .class );
3333
3434 static final MethodHandle dot7u$mh ;
35+ static final MethodHandle dot7uBulk$mh ;
3536 static final MethodHandle sqr7u$mh ;
3637 static final MethodHandle cosf32$mh ;
3738 static final MethodHandle dotf32$mh ;
@@ -53,6 +54,11 @@ public final class JdkVectorLibrary implements VectorLibrary {
5354 FunctionDescriptor .of (JAVA_INT , ADDRESS , ADDRESS , JAVA_INT ),
5455 LinkerHelperUtil .critical ()
5556 );
57+ dot7uBulk$mh = downcallHandle (
58+ "dot7u_bulk_2" ,
59+ FunctionDescriptor .ofVoid (ADDRESS , ADDRESS , JAVA_INT , JAVA_INT , ADDRESS ),
60+ LinkerHelperUtil .critical ()
61+ );
5662 sqr7u$mh = downcallHandle (
5763 "sqr7u_2" ,
5864 FunctionDescriptor .of (JAVA_INT , ADDRESS , ADDRESS , JAVA_INT ),
@@ -79,6 +85,11 @@ public final class JdkVectorLibrary implements VectorLibrary {
7985 FunctionDescriptor .of (JAVA_INT , ADDRESS , ADDRESS , JAVA_INT ),
8086 LinkerHelperUtil .critical ()
8187 );
88+ dot7uBulk$mh = downcallHandle (
89+ "dot7u_bulk" ,
90+ FunctionDescriptor .ofVoid (ADDRESS , ADDRESS , JAVA_INT , JAVA_INT , ADDRESS ),
91+ LinkerHelperUtil .critical ()
92+ );
8293 sqr7u$mh = downcallHandle (
8394 "sqr7u" ,
8495 FunctionDescriptor .of (JAVA_INT , ADDRESS , ADDRESS , JAVA_INT ),
@@ -108,6 +119,7 @@ public final class JdkVectorLibrary implements VectorLibrary {
108119 enable them in your OS/Hypervisor/VM/container""" );
109120 }
110121 dot7u$mh = null ;
122+ dot7uBulk$mh = null ;
111123 sqr7u$mh = null ;
112124 cosf32$mh = null ;
113125 dotf32$mh = null ;
@@ -142,6 +154,10 @@ static int dotProduct7u(MemorySegment a, MemorySegment b, int length) {
142154 return dot7u (a , b , length );
143155 }
144156
157+ static void dotProduct7uBulk (MemorySegment a , MemorySegment b , int length , int count , MemorySegment result ) {
158+ dot7uBulk (a , b , length , count , result );
159+ }
160+
145161 /**
146162 * Computes the square distance of given unsigned int7 byte vectors.
147163 *
@@ -210,6 +226,14 @@ private static int dot7u(MemorySegment a, MemorySegment b, int length) {
210226 }
211227 }
212228
229+ private static void dot7uBulk (MemorySegment a , MemorySegment b , int length , int count , MemorySegment result ) {
230+ try {
231+ JdkVectorLibrary .dot7uBulk$mh .invokeExact (a , b , length , count , result );
232+ } catch (Throwable t ) {
233+ throw new AssertionError (t );
234+ }
235+ }
236+
213237 private static int sqr7u (MemorySegment a , MemorySegment b , int length ) {
214238 try {
215239 return (int ) JdkVectorLibrary .sqr7u$mh .invokeExact (a , b , length );
@@ -243,6 +267,7 @@ private static float sqrf32(MemorySegment a, MemorySegment b, int length) {
243267 }
244268
245269 static final MethodHandle DOT_HANDLE_7U ;
270+ static final MethodHandle DOT_HANDLE_7U_BULK ;
246271 static final MethodHandle SQR_HANDLE_7U ;
247272 static final MethodHandle COS_HANDLE_FLOAT32 ;
248273 static final MethodHandle DOT_HANDLE_FLOAT32 ;
@@ -253,6 +278,11 @@ private static float sqrf32(MemorySegment a, MemorySegment b, int length) {
253278 var lookup = MethodHandles .lookup ();
254279 var mt = MethodType .methodType (int .class , MemorySegment .class , MemorySegment .class , int .class );
255280 DOT_HANDLE_7U = lookup .findStatic (JdkVectorSimilarityFunctions .class , "dotProduct7u" , mt );
281+ DOT_HANDLE_7U_BULK = lookup .findStatic (
282+ JdkVectorSimilarityFunctions .class ,
283+ "dotProduct7uBulk" ,
284+ MethodType .methodType (void .class , MemorySegment .class , MemorySegment .class , int .class , int .class , MemorySegment .class )
285+ );
256286 SQR_HANDLE_7U = lookup .findStatic (JdkVectorSimilarityFunctions .class , "squareDistance7u" , mt );
257287
258288 mt = MethodType .methodType (float .class , MemorySegment .class , MemorySegment .class , int .class );
@@ -269,6 +299,11 @@ public MethodHandle dotProductHandle7u() {
269299 return DOT_HANDLE_7U ;
270300 }
271301
302+ @ Override
303+ public MethodHandle dotProductHandle7uBulk () {
304+ return DOT_HANDLE_7U_BULK ;
305+ }
306+
272307 @ Override
273308 public MethodHandle squareDistanceHandle7u () {
274309 return SQR_HANDLE_7U ;
0 commit comments