Re: RFR: 8267969: Add vectorized implementation for VectorMask.eq() [v2]
On Wed, 2 Jun 2021 07:48:47 GMT, Nils Eliasson wrote: > Please wait until you have two reviewers before integrating. Sure! Thanks so much for looking at this PR! - PR: https://git.openjdk.java.net/jdk/pull/4272
Re: RFR: 8267969: Add vectorized implementation for VectorMask.eq() [v2]
On Wed, 2 Jun 2021 01:56:00 GMT, Xiaohong Gong wrote: >> Currently `"VectorMask.eq()" `is not vectorized: >> >> public VectorMask eq(VectorMask 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 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() Looks good. Please wait until you have two reviewers before integrating. - Marked as reviewed by neliasso (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/4272
Re: RFR: 8267969: Add vectorized implementation for VectorMask.eq() [v2]
> Currently `"VectorMask.eq()" `is not vectorized: > > public VectorMask eq(VectorMask 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 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=4272=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk=4272=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
Re: RFR: 8267969: Add vectorized implementation for VectorMask.eq()
On Tue, 1 Jun 2021 16:29:58 GMT, Paul Sandoz wrote: > Looks. Later we may want to consider pushing this down as an intrinsic, > perhaps reusing `VectorSupport.compare`. Thanks for your review @PaulSandoz ! Yes, reusing `VectorSupport.compare` is an alternative way to do the vectorization. - PR: https://git.openjdk.java.net/jdk/pull/4272
Re: RFR: 8267969: Add vectorized implementation for VectorMask.eq()
On Mon, 31 May 2021 10:25:26 GMT, Xiaohong Gong wrote: > Currently `"VectorMask.eq()" `is not vectorized: > > public VectorMask eq(VectorMask 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 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; > } Looks. Later we may want to consider pushing this down as an intrinsic, perhaps reusing `VectorSupport.compare`. - Marked as reviewed by psandoz (Reviewer). PR: https://git.openjdk.java.net/jdk/pull/4272
RFR: 8267969: Add vectorized implementation for VectorMask.eq()
Currently `"VectorMask.eq()" `is not vectorized: public VectorMask eq(VectorMask 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 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; } - Commit messages: - 8267969: Add vectorized implementation for VectorMask.eq() Changes: https://git.openjdk.java.net/jdk/pull/4272/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk=4272=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8267969 Stats: 254 lines in 32 files changed: 248 ins; 6 del; 0 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