[vector] some notes on bitwise and reduction operations
Paul Sandoz
paul.sandoz at oracle.com
Tue May 15 00:56:11 UTC 2018
Hi,
While fleshing out the JavaDoc i made some notes on the bitwise and reduction operations:
Bit shifting:
- Will shifting byte and short vectors by a scalar be supported?
If so we need to be careful with the specification. In Java a byte or short is promoted to an int value before shifting. If we want to be equivalent in Java we may need to specify this as equivalent to casting to an int vector then down casting. But i am unsure what the vector hardware instructions do.
- In Java the int and long primitive shifting operations take the first 5 or 6 bits of the value to shift. What do the vector hardware instructions do? I hope/suspect the same but need to double check...
Bit rotating:
- Will these be made intrinsic? Currently i specified them for int and long (via the Integer/Long.rotateLeft/Right methods), and they are incorrect for byte and short, due to upcasting to int and then truncating on a downcast.
- Do we require mask variants?
Reduction:
- Do we require mask variants? The implementation can blend in the identity value for masked lanes.
v.blend(SPECIES.broadcast(identity), mask).addAll();
- I am still noodling on the best way to specify reductive operations for floating point vectors.
I am leaning towards specifying that the default be lane elements are processed in sequential order from left to right.
An option would be required to declare that order is not important and an undefined algorithm can be utilized that may leverage data parallelism but could produce different results to the default, and may not be stable over releases.
Paul.
More information about the panama-dev
mailing list