Rebracketing and Reshaping
Vladimir Ivanov
vladimir.x.ivanov at oracle.com
Mon Mar 25 18:42:51 UTC 2019
Hi Richard,
> I have noticed that Vector.rebracket has disappeared recently, and I can't find a way to concatenate bytes into wider integral types any more. Is there a new API, or will this be no longer possible?
The API points were renamed some time ago [1].
Here's the list of methods which can be used to change Vector instance
shape:
<F> Vector<F> cast(Species<F> s);
<F> Vector<F> reinterpret(Species<F> s);
Vector<E> reshape(Species<E> s);
> If the latter, I think that would amount to a significant loss of functionality. Its demise would also have an impact on performance. For instance, the implementation of ByteVector.shiftR is much slower than rebracketing to IntVector, shifting right, masking out the high bits, and rebracketing back to ByteVector was.
> Why would a user want to reshape a ByteVector to a ByteVector? To reduce the number of lanes?
Yes, either to reduce or increase number of lanes.
Since all the operations on vectors are strongly typed on vector shape
(element type + number of lanes), it becomes useful to to adjust number
of lanes in a vector to make it composable with vectors of different
widths (but with the same element type).
Though it looks like 'reshape' duplicates 'cast'/'reinterpret', one of
the motivations to have a dedicated API point for it is the operation
may be implemented more efficiently than cast/reinterpret in a general
case (when Species instance is not a compile-time constant).
Of course, the decision may be reconsidered in the future.
Best regards,
Vladimir Ivanov
[1]
http://mail.openjdk.java.net/pipermail/panama-dev/2019-January/003772.html
More information about the panama-dev
mailing list