[vector] time for 2-D memory addressing?
Joshua Zhu (Arm Technology China)
Joshua.Zhu at arm.com
Wed Jun 26 12:54:12 UTC 2019
Hi John,
For masked memory writes, I think 2D memory addressing would only target platforms which don't support masked operations natively.
For wild reads in masked memory reads [1], when reading an array at the very end of a mapped memory,
random segfault caused by an excessively positive offset with unset mask seems more confused than exception thrown in index check.
[1] https://bugs.openjdk.java.net/browse/JDK-8223367
Best Regards,
Joshua
> I think it’s almost time to implement 2-D address modes on `ETYPE[][] a;
> a[i][j]` where `i` and `j` are vector values and the 2-D array base `a` is a
> broadcast constant.
>
> As documented in https://bugs.openjdk.java.net/browse/JDK-8223367 it
> would give a portable way to implement masked scatter (using a fake bit-
> bucket target).
>
> Of course it’s also generally useful in its own right. And it's a "sweet spot",
> since you can emulate multi-dimensional Java arrays using a 2-D primitive, as
> long as you are willing to set up the first array `a` in Java code, collecting all
> last-dimension base addresses in some organized fashion.
>
> The reason I think the time is near is that I think we need a solution to
> masked gather and scatter on platforms which don't support that natively,
> and this is the best way I know to do it:
>
> void maskedStore1D(ETYPE[] target, EVector indexes, VectorMask<E> m) {
> ETYPE[] bitBucket = new ETYPE[indexes.length()];
> ETYPE[][] temp = new ETYPE[][]{ target, bitBucket };
> EVector i = indexes.broadcast(1).blend(0, m);
> EVector j = indexes.broadcast(0).addIndex(1).blend(indexes, m);
> maskedStore2D(temp, i, j);
> }
>
> I suppose the actual method signature for 2D addressing is similar to 1D
> addressing, except (a) the scalar array is 2D, and (b) there is an extra vector
> argument providing the `j` index.
>
More information about the panama-dev
mailing list