[vector] Prototype of apply() method on Vector
Vladimir Ivanov
vladimir.x.ivanov at oracle.com
Thu Feb 21 00:55:36 UTC 2019
> - It promises a way out of the "tail loop" problem;
While it tremendously reduces the API scope, I don't see how it helps
with "tail loop" problem per se.
It still misses important pieces which are needed to describe iteration
over data source(s).
Just introducing wider operations on VectorOp doesn't help -
VectorOp.apply(int[] src, int[] op2) won't compose. There's still a need
in a higher-order operation which accepts a kernel description.
And when it comes to composing multiple operations, VectorOp.apply()
looks almost identical to XxxVector + lambdas:
void IntVector.map(UnaryOperator<IntVector> op,
int[] src, int[] dst)
void IntVector.map(BinaryOperator<IntVector> op,
int[] src1, int[] src2, int[] dst)
IntVector.map((v,w) -> v.add(w.mul(2)), src, dst)
vs
IntVector.map((v,w) -> ADD.apply(v, MUL.apply(2, v)), src, dst);
or even (equivalent using MHs[1]):
IntVector.map(ADD.bind(2, MUL.bind(1, 2)), src, dst);
// UOp op1 = BOp.MUL.bind(1, 2); // x1*x2, x1=2 => 2*x2
// BOp op2 = BOp.ADD.bind(2,op1); // x1+x2, x2=op1(y1) => x1+(2*x2)
Best regards,
Vladimir Ivanov
[1] MethodHandle ADD = ... <MethodHandle(IV,IV)IV> ...
MethodHandle MUL = ... <MethodHandle(IV,IV)IV> ...
MethodHandle BRT = ... <MethodHandle(I)IV>
IV vc2 = BRT.invoke(2);
MH op1 = MethodHandles.insertArguments(MUL, 0, vc2); // 2*x2
MH op2 = MethodHandles.filterArguments(ADD, 1, op1); // x1+(2*x2)
More information about the panama-dev
mailing list