VectorAPI Scatter Gather Intrinsic Support

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Wed Dec 5 00:18:13 UTC 2018


> I updated the patch to remove the check for constant op. Please find the patch below:
> http://cr.openjdk.java.net/~srukmannagar/VectorAPI_ScatterGather/webrev.01/

Actually I meant the opposite: remove "Class<?> vectorIndexClass" 
argument from VectorIntrinsics.loadWithMap/storeWithMap and always use 
elem_klass in LibraryCallKit::inline_vector_gather_scatter() to 
construct vbox_idx_klass.

You already had a fallback case vector_idx_klass isn't available:

+  ciKlass* vbox_idx_klass = NULL;
+  if (vector_idx_klass->const_oop() == NULL) {
+    vbox_idx_klass = 
elem_klass->const_oop()->as_instance()->java_lang_Class_klass();
+  } else {
+    vbox_idx_klass = 
vector_idx_klass->const_oop()->as_instance()->java_lang_Class_klass();
+  }

And on Java side vecInd construction is quite complicated, so it's not 
guaranteed the JIT will see vecInd.getClass() as a compile-time constant:

+        IntVector.IntSpecies<Vector.Shape> intSpec = 
(IntVector.IntSpecies<Vector.Shape>) Vector.species(int.class, shape);
+
+       // Load index map into a vector
+#if[longOrDouble64]
+        IntVector<Vector.Shape> vecInd = intSpec.broadcast(b[iy]);
+#else[longOrDouble64]
+        IntVector<Vector.Shape> vecInd = intSpec.fromArray(b, iy);
+#end[longOrDouble64]
+        // Compute actual indices into the array taking into account 
initial index.
+        vecInd = vecInd.add(intSpec.broadcast(ix));
+
+        iy = VectorIntrinsics.checkIndex(iy, a.length, LENGTH);
+
+        VectorIntrinsics.storeWithMap($vectortype$.class, $type$.class, 
LENGTH,
+                               a, Unsafe.ARRAY_$TYPE$_BASE_OFFSET, 
vecInd, vecInd.getClass(),


Best regards,
Vladimir Ivanov

> -----Original Message-----
> From: Vladimir Ivanov [mailto:vladimir.x.ivanov at oracle.com]
> Sent: Monday, December 3, 2018 11:54 AM
> To: Rukmannagari, Shravya <shravya.rukmannagari at intel.com>; panama-dev at openjdk.java.net
> Cc: Aundhe, Shirish <shirish.aundhe at intel.com>; Raj, Guru <guru.raj at intel.com>
> Subject: Re: VectorAPI Scatter Gather Intrinsic Support
> 
> One more question:
> 
> src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template:
> 
> +        VectorIntrinsics.storeWithMap($vectortype$.class, $type$.class,
> LENGTH,
> +                               a, Unsafe.ARRAY_$TYPE$_BASE_OFFSET,
> vecInd, vecInd.getClass(),
> 
> Why do you need vecInd class in the intrinsic?
> 
> My main concern with proposed code shape is there are no guarantees it's
> a compile-time constant. And those special cases on Java side for
> Long64/Double64 only complicates the picture. Moreover, on C2 side it
> turns out it's optional:
> 
> src/hotspot/share/opto/library_call.cpp:
> 
> +bool LibraryCallKit::inline_vector_gather_scatter(bool is_scatter) {
> ...
> +  const TypeInstPtr* vector_idx_klass =
> gvn().type(argument(7))->is_instptr();
> ...
> +  ciKlass* vbox_idx_klass = NULL;
> +  if (vector_idx_klass->const_oop() == NULL) {
> +    vbox_idx_klass =
> elem_klass->const_oop()->as_instance()->java_lang_Class_klass();
> +  } else {
> +    vbox_idx_klass =
> vector_idx_klass->const_oop()->as_instance()->java_lang_Class_klass();
> +  }
> 
> So, why not simply get rid of it?
> 
> Best regards,
> Vladimir Ivanov
> 
> On 30/11/2018 18:19, Rukmannagari, Shravya wrote:
>> Hi All,
>>
>> I would like to contribute a patch that adds scatter and gather support in Java for int, float, long and double datatypes.
>>
>>
>>
>> Could you please review the patch here:
>>
>> http://cr.openjdk.java.net/~srukmannagar/VectorAPI_ScatterGather/webrev.00/
>>
>>
>>
>> Thanks,
>>
>> Shravya.
>>
>>


More information about the panama-dev mailing list