RFR: 8267969: Add vectorized implementation for VectorMask.eq() [v2]

Xiaohong Gong xgong at openjdk.java.net
Wed Jun 2 01:56:00 UTC 2021


> Currently `"VectorMask.eq()" `is not vectorized:
> 
>     public VectorMask<E> eq(VectorMask<E> m) {
>         // FIXME: Generate good code here.
>         return bOp(m, (i, a, b) -> a == b);
>     }
> 
> This can be implemented by calling `"xor(m.not())"` directly.
> 
> The performance improved about 1.4x ~ 1.9x for the following benchmark with different basic types:
> 
> @Benchmark
> public Object eq() {
>     boolean[] ma = fm.apply(size);
>     boolean[] mb = fmb.apply(size);
>     boolean[] mt = fmt.apply(size);
>     VectorMask<Byte> m = VectorMask.fromArray(SPECIES, mt, 0);
> 
>     for (int ic = 0; ic < INVOC_COUNT; ic++) {
>         for (int i = 0; i < ma.length; i += SPECIES.length()) {
>             var av = SPECIES.loadMask(ma, i);
>             var bv = SPECIES.loadMask(mb, i);
> 
>             // accumulate results, so JIT can't eliminate relevant computations
>             m = m.and(av.eq(bv));
>         }
>     }
> 
>     return m;
> }

Xiaohong Gong has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:

 - Merge branch 'jdk:master' into JDK-8267969
 - 8267969: Add vectorized implementation for VectorMask.eq()

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/4272/files
  - new: https://git.openjdk.java.net/jdk/pull/4272/files/0e8e0e84..f3a48026

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=4272&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=4272&range=00-01

  Stats: 22530 lines in 577 files changed: 2836 ins; 18744 del; 950 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4272.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4272/head:pull/4272

PR: https://git.openjdk.java.net/jdk/pull/4272


More information about the core-libs-dev mailing list