Update on generalized intrinsics experiment

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Fri Dec 22 22:00:44 UTC 2017


> This is looking very promising. It’s pleasing to see code gen approach held up without modification.
> 
>  From a code bloat perspective do you think it worth pushing op impls, where amenable, up to the abstract *Vector<S> types?

It's doable, but moving them up in hierarchy plays against JIT-compiler. 
When the code resides in leaf classes, JIT enjoys working with constants 
and exact types. If the code becomes shared, those vector shape-specific 
parameters should be fetched first which becomes a hurdle for the compiler.

It's not a big deal when everything is inlined, but if it's not we end 
up with multiple calls instead of 1.

And the same applies to default implementation. It's much harder for the 
compiler to specialize the code for particular vector shape when crucial 
pieces are abstracted away.

Best regards,
Vladimir Ivanov

>> I tried to keep intrinsics separate and accompany each with relevant code (as deleted):
>>
>> (0) Vector.length()
>> http://cr.openjdk.java.net/~vlivanov/panama/vector.generalized_intrinsics.03/length/
>>
>>   Replaced length() with pure Java implementation. Static final fields are treated as constants, so not much benefit in keeping it as an intrinsic.
>>
>>
>> (1) VI.binaryOp()
>> http://cr.openjdk.java.net/~vlivanov/panama/vector.generalized_intrinsics.03/binary/
>>
>>   Implemented add(), sub(), mul(), div(), and(), or(), xor().
>>
>>
>> (2) VI.broadcastCoerced()
>> http://cr.openjdk.java.net/~vlivanov/panama/vector.generalized_intrinsics.03/broadcast
>>
>>   Chose coerced (to long) version (though boxed version works fine as well [1]). Implemented zero() & broadcast().
>>
>>
>> (3) VI.load()/store()
>> http://cr.openjdk.java.net/~vlivanov/panama/vector.generalized_intrinsics.03/memory/
>>
>>   Implemented fromArray()/intoArray().
>>
>>
>> (4) VI.reductionCoerced()
>> http://cr.openjdk.java.net/~vlivanov/panama/vector.generalized_intrinsics.03/reduction/
>>
>>   Result value is coerced to long bits. Implemented addAll(), mulAll().
>>
>> Test results look fine, but from code quality perspective, absence of rematerialization support at safepoints keep many allocations alive.
>>
>>
>> Also, started experimenting with masks:
>> http://cr.openjdk.java.net/~vlivanov/panama/vector.generalized_intrinsics.03/mask/
>>
>> It's not complete yet, but nice thing is that existing intrinsics can be extended to masks as well.
>>
>> Let me know what do you think about that. Thanks!
>>
>> Best regards,
>> Vladimir Ivanov
>>
>> [1] http://cr.openjdk.java.net/~vlivanov/panama/vector.generalized_intrinsics.broadcast/
> 


More information about the panama-dev mailing list