From de83fd95a82177496068c426438b38b4a59d24b3 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Mon, 9 Dec 2024 17:38:08 +0530 Subject: [PATCH] 8345798: Update VectorAPI Benchmarks --- .../templates/Perf-Scalar-header.template | 1 + .../vector/operation/Byte128Vector.java | 237 +++++++++++++++++- .../vector/operation/Byte256Vector.java | 237 +++++++++++++++++- .../vector/operation/Byte512Vector.java | 237 +++++++++++++++++- .../vector/operation/Byte64Vector.java | 237 +++++++++++++++++- .../vector/operation/ByteMaxVector.java | 237 +++++++++++++++++- .../vector/operation/ByteScalar.java | 85 ++++++- .../vector/operation/Double128Vector.java | 5 +- .../vector/operation/Double256Vector.java | 5 +- .../vector/operation/Double512Vector.java | 5 +- .../vector/operation/Double64Vector.java | 5 +- .../vector/operation/DoubleMaxVector.java | 5 +- .../vector/operation/DoubleScalar.java | 1 + .../vector/operation/Float128Vector.java | 5 +- .../vector/operation/Float256Vector.java | 5 +- .../vector/operation/Float512Vector.java | 5 +- .../vector/operation/Float64Vector.java | 5 +- .../vector/operation/FloatMaxVector.java | 5 +- .../vector/operation/FloatScalar.java | 1 + .../vector/operation/Int128Vector.java | 237 +++++++++++++++++- .../vector/operation/Int256Vector.java | 237 +++++++++++++++++- .../vector/operation/Int512Vector.java | 237 +++++++++++++++++- .../vector/operation/Int64Vector.java | 237 +++++++++++++++++- .../vector/operation/IntMaxVector.java | 237 +++++++++++++++++- .../incubator/vector/operation/IntScalar.java | 85 ++++++- .../vector/operation/Long128Vector.java | 237 +++++++++++++++++- .../vector/operation/Long256Vector.java | 237 +++++++++++++++++- .../vector/operation/Long512Vector.java | 237 +++++++++++++++++- .../vector/operation/Long64Vector.java | 237 +++++++++++++++++- .../vector/operation/LongMaxVector.java | 237 +++++++++++++++++- .../vector/operation/LongScalar.java | 85 ++++++- .../vector/operation/Short128Vector.java | 237 +++++++++++++++++- .../vector/operation/Short256Vector.java | 237 +++++++++++++++++- .../vector/operation/Short512Vector.java | 237 +++++++++++++++++- .../vector/operation/Short64Vector.java | 237 +++++++++++++++++- .../vector/operation/ShortMaxVector.java | 237 +++++++++++++++++- .../vector/operation/ShortScalar.java | 85 ++++++- 37 files changed, 4927 insertions(+), 206 deletions(-) diff --git a/test/jdk/jdk/incubator/vector/templates/Perf-Scalar-header.template b/test/jdk/jdk/incubator/vector/templates/Perf-Scalar-header.template index ef0e254017a..27a3c3c74bd 100644 --- a/test/jdk/jdk/incubator/vector/templates/Perf-Scalar-header.template +++ b/test/jdk/jdk/incubator/vector/templates/Perf-Scalar-header.template @@ -27,6 +27,7 @@ package org.openjdk.bench.jdk.incubator.vector.operation; import java.util.concurrent.TimeUnit; import java.util.function.IntFunction; +import jdk.incubator.vector.VectorMath; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte128Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte128Vector.java index f5705fceab6..626c1c97648 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte128Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte128Vector.java @@ -986,6 +986,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); @@ -1275,12 +1491,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1437,7 +1656,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1449,14 +1668,14 @@ public Object UNSIGNED_LT() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1468,14 +1687,14 @@ public Object UNSIGNED_GT() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1487,14 +1706,14 @@ public Object UNSIGNED_LE() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1506,7 +1725,7 @@ public Object UNSIGNED_GE() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte256Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte256Vector.java index 7e388154789..c84eceedec4 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte256Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte256Vector.java @@ -986,6 +986,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); @@ -1275,12 +1491,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1437,7 +1656,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1449,14 +1668,14 @@ public Object UNSIGNED_LT() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1468,14 +1687,14 @@ public Object UNSIGNED_GT() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1487,14 +1706,14 @@ public Object UNSIGNED_LE() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1506,7 +1725,7 @@ public Object UNSIGNED_GE() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte512Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte512Vector.java index 37919e02739..4c624fae4cb 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte512Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte512Vector.java @@ -986,6 +986,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); @@ -1275,12 +1491,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1437,7 +1656,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1449,14 +1668,14 @@ public Object UNSIGNED_LT() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1468,14 +1687,14 @@ public Object UNSIGNED_GT() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1487,14 +1706,14 @@ public Object UNSIGNED_LE() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1506,7 +1725,7 @@ public Object UNSIGNED_GE() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte64Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte64Vector.java index 1608518bc74..2be789c7a42 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte64Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Byte64Vector.java @@ -986,6 +986,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); @@ -1275,12 +1491,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1437,7 +1656,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1449,14 +1668,14 @@ public Object UNSIGNED_LT() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1468,14 +1687,14 @@ public Object UNSIGNED_GT() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1487,14 +1706,14 @@ public Object UNSIGNED_LE() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1506,7 +1725,7 @@ public Object UNSIGNED_GE() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ByteMaxVector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ByteMaxVector.java index fff4f190553..bf6fc82151c 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ByteMaxVector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ByteMaxVector.java @@ -986,6 +986,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); @@ -1275,12 +1491,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); byte[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1437,7 +1656,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1449,14 +1668,14 @@ public Object UNSIGNED_LT() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1468,14 +1687,14 @@ public Object UNSIGNED_GT() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1487,14 +1706,14 @@ public Object UNSIGNED_LE() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { byte[] a = fa.apply(size); byte[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1506,7 +1725,7 @@ public Object UNSIGNED_GE() { ByteVector bv = ByteVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ByteScalar.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ByteScalar.java index 6451fc13e58..b34a83b95e4 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ByteScalar.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ByteScalar.java @@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.IntFunction; +import jdk.incubator.vector.VectorMath; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; @@ -1034,6 +1035,82 @@ public void MAX(Blackhole bh) { bh.consume(rs); } + @Benchmark + public void UMIN(Blackhole bh) { + byte[] as = fa.apply(size); + byte[] bs = fb.apply(size); + byte[] rs = fr.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + byte a = as[i]; + byte b = bs[i]; + rs[i] = (byte)(VectorMath.minUnsigned(a, b)); + } + } + + bh.consume(rs); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + byte[] as = fa.apply(size); + byte[] bs = fb.apply(size); + byte[] rs = fr.apply(size); + boolean[] ms = fm.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + byte a = as[i]; + byte b = bs[i]; + if (ms[i % ms.length]) { + rs[i] = (byte)(VectorMath.minUnsigned(a, b)); + } else { + rs[i] = a; + } + } + } + bh.consume(rs); + } + + @Benchmark + public void UMAX(Blackhole bh) { + byte[] as = fa.apply(size); + byte[] bs = fb.apply(size); + byte[] rs = fr.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + byte a = as[i]; + byte b = bs[i]; + rs[i] = (byte)(VectorMath.maxUnsigned(a, b)); + } + } + + bh.consume(rs); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + byte[] as = fa.apply(size); + byte[] bs = fb.apply(size); + byte[] rs = fr.apply(size); + boolean[] ms = fm.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + byte a = as[i]; + byte b = bs[i]; + if (ms[i % ms.length]) { + rs[i] = (byte)(VectorMath.maxUnsigned(a, b)); + } else { + rs[i] = a; + } + } + } + bh.consume(rs); + } + @Benchmark public void ANDLanes(Blackhole bh) { byte[] as = fa.apply(size); @@ -1321,7 +1398,7 @@ public void GE(Blackhole bh) { } @Benchmark - public void UNSIGNED_LT(Blackhole bh) { + public void ULT(Blackhole bh) { byte[] as = fa.apply(size); byte[] bs = fb.apply(size); boolean r = true; @@ -1336,7 +1413,7 @@ public void UNSIGNED_LT(Blackhole bh) { } @Benchmark - public void UNSIGNED_GT(Blackhole bh) { + public void UGT(Blackhole bh) { byte[] as = fa.apply(size); byte[] bs = fb.apply(size); boolean r = true; @@ -1351,7 +1428,7 @@ public void UNSIGNED_GT(Blackhole bh) { } @Benchmark - public void UNSIGNED_LE(Blackhole bh) { + public void ULE(Blackhole bh) { byte[] as = fa.apply(size); byte[] bs = fb.apply(size); boolean r = true; @@ -1366,7 +1443,7 @@ public void UNSIGNED_LE(Blackhole bh) { } @Benchmark - public void UNSIGNED_GE(Blackhole bh) { + public void UGE(Blackhole bh) { byte[] as = fa.apply(size); byte[] bs = fb.apply(size); boolean r = true; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double128Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double128Vector.java index 702e71a1b4b..98aa9398fa6 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double128Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double128Vector.java @@ -475,12 +475,15 @@ public void FIRST_NONZEROMaskedLanes(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double256Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double256Vector.java index cc2ff9ba73b..743ee7be764 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double256Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double256Vector.java @@ -475,12 +475,15 @@ public void FIRST_NONZEROMaskedLanes(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double512Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double512Vector.java index f127400283e..f2c70eed7c2 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double512Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double512Vector.java @@ -475,12 +475,15 @@ public void FIRST_NONZEROMaskedLanes(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double64Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double64Vector.java index b400eff2dec..a5243aa762a 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double64Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Double64Vector.java @@ -475,12 +475,15 @@ public void FIRST_NONZEROMaskedLanes(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/DoubleMaxVector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/DoubleMaxVector.java index baadcc2451c..37012ec098d 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/DoubleMaxVector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/DoubleMaxVector.java @@ -475,12 +475,15 @@ public void FIRST_NONZEROMaskedLanes(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { double[] a = fa.apply(SPECIES.length()); + double[] b = fb.apply(SPECIES.length()); double[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { DoubleVector av = DoubleVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (double)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/DoubleScalar.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/DoubleScalar.java index 140e58f9375..136101fc29b 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/DoubleScalar.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/DoubleScalar.java @@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.IntFunction; +import jdk.incubator.vector.VectorMath; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float128Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float128Vector.java index b3d584751e0..179a7b83ce5 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float128Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float128Vector.java @@ -475,12 +475,15 @@ public void FIRST_NONZEROMaskedLanes(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (float)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float256Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float256Vector.java index aebe088449b..177956f5422 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float256Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float256Vector.java @@ -475,12 +475,15 @@ public void FIRST_NONZEROMaskedLanes(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (float)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float512Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float512Vector.java index e9ff3b35b08..7135da1f877 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float512Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float512Vector.java @@ -475,12 +475,15 @@ public void FIRST_NONZEROMaskedLanes(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (float)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float64Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float64Vector.java index 24b7923b668..ce74c74b43d 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float64Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Float64Vector.java @@ -475,12 +475,15 @@ public void FIRST_NONZEROMaskedLanes(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (float)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/FloatMaxVector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/FloatMaxVector.java index a00bc333bef..251cd9e7828 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/FloatMaxVector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/FloatMaxVector.java @@ -475,12 +475,15 @@ public void FIRST_NONZEROMaskedLanes(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { float[] a = fa.apply(SPECIES.length()); + float[] b = fb.apply(SPECIES.length()); float[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { FloatVector av = FloatVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (float)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/FloatScalar.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/FloatScalar.java index 49b380c19fd..60d3a166556 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/FloatScalar.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/FloatScalar.java @@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.IntFunction; +import jdk.incubator.vector.VectorMath; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int128Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int128Vector.java index 04204dba5f9..9801d6ea9ca 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int128Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int128Vector.java @@ -1058,6 +1058,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); @@ -1347,12 +1563,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (int)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1509,7 +1728,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1521,14 +1740,14 @@ public Object UNSIGNED_LT() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1540,14 +1759,14 @@ public Object UNSIGNED_GT() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1559,14 +1778,14 @@ public Object UNSIGNED_LE() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1578,7 +1797,7 @@ public Object UNSIGNED_GE() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int256Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int256Vector.java index 6c9dbedf9be..23aa9d12621 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int256Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int256Vector.java @@ -1058,6 +1058,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); @@ -1347,12 +1563,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (int)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1509,7 +1728,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1521,14 +1740,14 @@ public Object UNSIGNED_LT() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1540,14 +1759,14 @@ public Object UNSIGNED_GT() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1559,14 +1778,14 @@ public Object UNSIGNED_LE() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1578,7 +1797,7 @@ public Object UNSIGNED_GE() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int512Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int512Vector.java index 8e23fbf64cb..08e7e8193d7 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int512Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int512Vector.java @@ -1058,6 +1058,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); @@ -1347,12 +1563,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (int)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1509,7 +1728,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1521,14 +1740,14 @@ public Object UNSIGNED_LT() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1540,14 +1759,14 @@ public Object UNSIGNED_GT() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1559,14 +1778,14 @@ public Object UNSIGNED_LE() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1578,7 +1797,7 @@ public Object UNSIGNED_GE() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int64Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int64Vector.java index adf1e4da35b..c689fc14f62 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int64Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Int64Vector.java @@ -1058,6 +1058,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); @@ -1347,12 +1563,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (int)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1509,7 +1728,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1521,14 +1740,14 @@ public Object UNSIGNED_LT() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1540,14 +1759,14 @@ public Object UNSIGNED_GT() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1559,14 +1778,14 @@ public Object UNSIGNED_LE() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1578,7 +1797,7 @@ public Object UNSIGNED_GE() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/IntMaxVector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/IntMaxVector.java index 2798e5d66a4..47da0c9dbc1 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/IntMaxVector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/IntMaxVector.java @@ -1058,6 +1058,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); @@ -1347,12 +1563,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); int[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (int)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1509,7 +1728,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1521,14 +1740,14 @@ public Object UNSIGNED_LT() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1540,14 +1759,14 @@ public Object UNSIGNED_GT() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1559,14 +1778,14 @@ public Object UNSIGNED_LE() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { int[] a = fa.apply(size); int[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1578,7 +1797,7 @@ public Object UNSIGNED_GE() { IntVector bv = IntVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/IntScalar.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/IntScalar.java index ebaef422b89..c499d3e88ac 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/IntScalar.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/IntScalar.java @@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.IntFunction; +import jdk.incubator.vector.VectorMath; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; @@ -1107,6 +1108,82 @@ public void MAX(Blackhole bh) { bh.consume(rs); } + @Benchmark + public void UMIN(Blackhole bh) { + int[] as = fa.apply(size); + int[] bs = fb.apply(size); + int[] rs = fr.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + int a = as[i]; + int b = bs[i]; + rs[i] = (int)(VectorMath.minUnsigned(a, b)); + } + } + + bh.consume(rs); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + int[] as = fa.apply(size); + int[] bs = fb.apply(size); + int[] rs = fr.apply(size); + boolean[] ms = fm.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + int a = as[i]; + int b = bs[i]; + if (ms[i % ms.length]) { + rs[i] = (int)(VectorMath.minUnsigned(a, b)); + } else { + rs[i] = a; + } + } + } + bh.consume(rs); + } + + @Benchmark + public void UMAX(Blackhole bh) { + int[] as = fa.apply(size); + int[] bs = fb.apply(size); + int[] rs = fr.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + int a = as[i]; + int b = bs[i]; + rs[i] = (int)(VectorMath.maxUnsigned(a, b)); + } + } + + bh.consume(rs); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + int[] as = fa.apply(size); + int[] bs = fb.apply(size); + int[] rs = fr.apply(size); + boolean[] ms = fm.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + int a = as[i]; + int b = bs[i]; + if (ms[i % ms.length]) { + rs[i] = (int)(VectorMath.maxUnsigned(a, b)); + } else { + rs[i] = a; + } + } + } + bh.consume(rs); + } + @Benchmark public void ANDLanes(Blackhole bh) { int[] as = fa.apply(size); @@ -1394,7 +1471,7 @@ public void GE(Blackhole bh) { } @Benchmark - public void UNSIGNED_LT(Blackhole bh) { + public void ULT(Blackhole bh) { int[] as = fa.apply(size); int[] bs = fb.apply(size); boolean r = true; @@ -1409,7 +1486,7 @@ public void UNSIGNED_LT(Blackhole bh) { } @Benchmark - public void UNSIGNED_GT(Blackhole bh) { + public void UGT(Blackhole bh) { int[] as = fa.apply(size); int[] bs = fb.apply(size); boolean r = true; @@ -1424,7 +1501,7 @@ public void UNSIGNED_GT(Blackhole bh) { } @Benchmark - public void UNSIGNED_LE(Blackhole bh) { + public void ULE(Blackhole bh) { int[] as = fa.apply(size); int[] bs = fb.apply(size); boolean r = true; @@ -1439,7 +1516,7 @@ public void UNSIGNED_LE(Blackhole bh) { } @Benchmark - public void UNSIGNED_GE(Blackhole bh) { + public void UGE(Blackhole bh) { int[] as = fa.apply(size); int[] bs = fb.apply(size); boolean r = true; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long128Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long128Vector.java index 5332b6a4ef2..157f6975381 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long128Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long128Vector.java @@ -1058,6 +1058,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); @@ -1347,12 +1563,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1509,7 +1728,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1521,14 +1740,14 @@ public Object UNSIGNED_LT() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1540,14 +1759,14 @@ public Object UNSIGNED_GT() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1559,14 +1778,14 @@ public Object UNSIGNED_LE() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1578,7 +1797,7 @@ public Object UNSIGNED_GE() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long256Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long256Vector.java index 91f80d9cd64..7e7a71ca43d 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long256Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long256Vector.java @@ -1058,6 +1058,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); @@ -1347,12 +1563,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1509,7 +1728,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1521,14 +1740,14 @@ public Object UNSIGNED_LT() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1540,14 +1759,14 @@ public Object UNSIGNED_GT() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1559,14 +1778,14 @@ public Object UNSIGNED_LE() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1578,7 +1797,7 @@ public Object UNSIGNED_GE() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long512Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long512Vector.java index ce80f0084d2..0e5776e97a7 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long512Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long512Vector.java @@ -1058,6 +1058,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); @@ -1347,12 +1563,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1509,7 +1728,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1521,14 +1740,14 @@ public Object UNSIGNED_LT() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1540,14 +1759,14 @@ public Object UNSIGNED_GT() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1559,14 +1778,14 @@ public Object UNSIGNED_LE() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1578,7 +1797,7 @@ public Object UNSIGNED_GE() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long64Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long64Vector.java index 0197e5acc07..334fa130d57 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long64Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Long64Vector.java @@ -1058,6 +1058,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); @@ -1347,12 +1563,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1509,7 +1728,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1521,14 +1740,14 @@ public Object UNSIGNED_LT() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1540,14 +1759,14 @@ public Object UNSIGNED_GT() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1559,14 +1778,14 @@ public Object UNSIGNED_LE() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1578,7 +1797,7 @@ public Object UNSIGNED_GE() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/LongMaxVector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/LongMaxVector.java index 72b8f72c578..4e3193ee76a 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/LongMaxVector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/LongMaxVector.java @@ -1058,6 +1058,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); @@ -1347,12 +1563,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); long[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (long)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1509,7 +1728,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1521,14 +1740,14 @@ public Object UNSIGNED_LT() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1540,14 +1759,14 @@ public Object UNSIGNED_GT() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1559,14 +1778,14 @@ public Object UNSIGNED_LE() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { long[] a = fa.apply(size); long[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1578,7 +1797,7 @@ public Object UNSIGNED_GE() { LongVector bv = LongVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/LongScalar.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/LongScalar.java index bcfc68f2d64..d9229baa61e 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/LongScalar.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/LongScalar.java @@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.IntFunction; +import jdk.incubator.vector.VectorMath; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; @@ -1107,6 +1108,82 @@ public void MAX(Blackhole bh) { bh.consume(rs); } + @Benchmark + public void UMIN(Blackhole bh) { + long[] as = fa.apply(size); + long[] bs = fb.apply(size); + long[] rs = fr.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + long a = as[i]; + long b = bs[i]; + rs[i] = (long)(VectorMath.minUnsigned(a, b)); + } + } + + bh.consume(rs); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + long[] as = fa.apply(size); + long[] bs = fb.apply(size); + long[] rs = fr.apply(size); + boolean[] ms = fm.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + long a = as[i]; + long b = bs[i]; + if (ms[i % ms.length]) { + rs[i] = (long)(VectorMath.minUnsigned(a, b)); + } else { + rs[i] = a; + } + } + } + bh.consume(rs); + } + + @Benchmark + public void UMAX(Blackhole bh) { + long[] as = fa.apply(size); + long[] bs = fb.apply(size); + long[] rs = fr.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + long a = as[i]; + long b = bs[i]; + rs[i] = (long)(VectorMath.maxUnsigned(a, b)); + } + } + + bh.consume(rs); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + long[] as = fa.apply(size); + long[] bs = fb.apply(size); + long[] rs = fr.apply(size); + boolean[] ms = fm.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + long a = as[i]; + long b = bs[i]; + if (ms[i % ms.length]) { + rs[i] = (long)(VectorMath.maxUnsigned(a, b)); + } else { + rs[i] = a; + } + } + } + bh.consume(rs); + } + @Benchmark public void ANDLanes(Blackhole bh) { long[] as = fa.apply(size); @@ -1394,7 +1471,7 @@ public void GE(Blackhole bh) { } @Benchmark - public void UNSIGNED_LT(Blackhole bh) { + public void ULT(Blackhole bh) { long[] as = fa.apply(size); long[] bs = fb.apply(size); boolean r = true; @@ -1409,7 +1486,7 @@ public void UNSIGNED_LT(Blackhole bh) { } @Benchmark - public void UNSIGNED_GT(Blackhole bh) { + public void UGT(Blackhole bh) { long[] as = fa.apply(size); long[] bs = fb.apply(size); boolean r = true; @@ -1424,7 +1501,7 @@ public void UNSIGNED_GT(Blackhole bh) { } @Benchmark - public void UNSIGNED_LE(Blackhole bh) { + public void ULE(Blackhole bh) { long[] as = fa.apply(size); long[] bs = fb.apply(size); boolean r = true; @@ -1439,7 +1516,7 @@ public void UNSIGNED_LE(Blackhole bh) { } @Benchmark - public void UNSIGNED_GE(Blackhole bh) { + public void UGE(Blackhole bh) { long[] as = fa.apply(size); long[] bs = fb.apply(size); boolean r = true; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short128Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short128Vector.java index 49bdf796d6a..3b617c92ec2 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short128Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short128Vector.java @@ -986,6 +986,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); @@ -1275,12 +1491,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (short)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1437,7 +1656,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1449,14 +1668,14 @@ public Object UNSIGNED_LT() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1468,14 +1687,14 @@ public Object UNSIGNED_GT() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1487,14 +1706,14 @@ public Object UNSIGNED_LE() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1506,7 +1725,7 @@ public Object UNSIGNED_GE() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short256Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short256Vector.java index 707523b1797..31d4330c96f 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short256Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short256Vector.java @@ -986,6 +986,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); @@ -1275,12 +1491,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (short)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1437,7 +1656,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1449,14 +1668,14 @@ public Object UNSIGNED_LT() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1468,14 +1687,14 @@ public Object UNSIGNED_GT() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1487,14 +1706,14 @@ public Object UNSIGNED_LE() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1506,7 +1725,7 @@ public Object UNSIGNED_GE() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short512Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short512Vector.java index 4d43e855134..e1e58366640 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short512Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short512Vector.java @@ -986,6 +986,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); @@ -1275,12 +1491,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (short)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1437,7 +1656,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1449,14 +1668,14 @@ public Object UNSIGNED_LT() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1468,14 +1687,14 @@ public Object UNSIGNED_GT() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1487,14 +1706,14 @@ public Object UNSIGNED_LE() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1506,7 +1725,7 @@ public Object UNSIGNED_GE() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short64Vector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short64Vector.java index 560e065f858..f9f99b2caf2 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short64Vector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/Short64Vector.java @@ -986,6 +986,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); @@ -1275,12 +1491,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (short)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1437,7 +1656,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1449,14 +1668,14 @@ public Object UNSIGNED_LT() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1468,14 +1687,14 @@ public Object UNSIGNED_GT() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1487,14 +1706,14 @@ public Object UNSIGNED_LE() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1506,7 +1725,7 @@ public Object UNSIGNED_GE() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ShortMaxVector.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ShortMaxVector.java index b4b01d1fe62..55357b46838 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ShortMaxVector.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ShortMaxVector.java @@ -986,6 +986,222 @@ public void MAX(Blackhole bh) { bh.consume(r); } + @Benchmark + public void UMIN(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAX(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADD(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SADDMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUB(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SSUBMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADD(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUADDMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUB(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + bh.consume(r); + } + + @Benchmark + public void SUSUBMasked(Blackhole bh) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + bh.consume(r); + } + @Benchmark public void ANDLanes(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); @@ -1275,12 +1491,15 @@ public void allTrue(Blackhole bh) { @Benchmark public void withLane(Blackhole bh) { short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); short[] r = fr.apply(SPECIES.length()); for (int ic = 0; ic < INVOC_COUNT; ic++) { for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); - av.withLane((j++ & (SPECIES.length()-1)), (short)(65535+i)).intoArray(r, i); + av.withLane(j, b[i + j]).intoArray(r, i); + a[i + j] = b[i + j]; + j = (j + 1) & (SPECIES.length() - 1); } } @@ -1437,7 +1656,7 @@ public Object GE() { return m; } @Benchmark - public Object UNSIGNED_LT() { + public Object ULT() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1449,14 +1668,14 @@ public Object UNSIGNED_LT() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LT, bv)); + m = m.and(av.compare(VectorOperators.ULT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GT() { + public Object UGT() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1468,14 +1687,14 @@ public Object UNSIGNED_GT() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GT, bv)); + m = m.and(av.compare(VectorOperators.UGT, bv)); } } return m; } @Benchmark - public Object UNSIGNED_LE() { + public Object ULE() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1487,14 +1706,14 @@ public Object UNSIGNED_LE() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_LE, bv)); + m = m.and(av.compare(VectorOperators.ULE, bv)); } } return m; } @Benchmark - public Object UNSIGNED_GE() { + public Object UGE() { short[] a = fa.apply(size); short[] b = fb.apply(size); boolean[] ms = fmt.apply(size); @@ -1506,7 +1725,7 @@ public Object UNSIGNED_GE() { ShortVector bv = ShortVector.fromArray(SPECIES, b, i); // accumulate results, so JIT can't eliminate relevant computations - m = m.and(av.compare(VectorOperators.UNSIGNED_GE, bv)); + m = m.and(av.compare(VectorOperators.UGE, bv)); } } diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ShortScalar.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ShortScalar.java index 946a3bb9cc1..0d482402cd8 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ShortScalar.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/operation/ShortScalar.java @@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.IntFunction; +import jdk.incubator.vector.VectorMath; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.infra.Blackhole; @@ -1035,6 +1036,82 @@ public void MAX(Blackhole bh) { bh.consume(rs); } + @Benchmark + public void UMIN(Blackhole bh) { + short[] as = fa.apply(size); + short[] bs = fb.apply(size); + short[] rs = fr.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + short a = as[i]; + short b = bs[i]; + rs[i] = (short)(VectorMath.minUnsigned(a, b)); + } + } + + bh.consume(rs); + } + + @Benchmark + public void UMINMasked(Blackhole bh) { + short[] as = fa.apply(size); + short[] bs = fb.apply(size); + short[] rs = fr.apply(size); + boolean[] ms = fm.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + short a = as[i]; + short b = bs[i]; + if (ms[i % ms.length]) { + rs[i] = (short)(VectorMath.minUnsigned(a, b)); + } else { + rs[i] = a; + } + } + } + bh.consume(rs); + } + + @Benchmark + public void UMAX(Blackhole bh) { + short[] as = fa.apply(size); + short[] bs = fb.apply(size); + short[] rs = fr.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + short a = as[i]; + short b = bs[i]; + rs[i] = (short)(VectorMath.maxUnsigned(a, b)); + } + } + + bh.consume(rs); + } + + @Benchmark + public void UMAXMasked(Blackhole bh) { + short[] as = fa.apply(size); + short[] bs = fb.apply(size); + short[] rs = fr.apply(size); + boolean[] ms = fm.apply(size); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < as.length; i++) { + short a = as[i]; + short b = bs[i]; + if (ms[i % ms.length]) { + rs[i] = (short)(VectorMath.maxUnsigned(a, b)); + } else { + rs[i] = a; + } + } + } + bh.consume(rs); + } + @Benchmark public void ANDLanes(Blackhole bh) { short[] as = fa.apply(size); @@ -1322,7 +1399,7 @@ public void GE(Blackhole bh) { } @Benchmark - public void UNSIGNED_LT(Blackhole bh) { + public void ULT(Blackhole bh) { short[] as = fa.apply(size); short[] bs = fb.apply(size); boolean r = true; @@ -1337,7 +1414,7 @@ public void UNSIGNED_LT(Blackhole bh) { } @Benchmark - public void UNSIGNED_GT(Blackhole bh) { + public void UGT(Blackhole bh) { short[] as = fa.apply(size); short[] bs = fb.apply(size); boolean r = true; @@ -1352,7 +1429,7 @@ public void UNSIGNED_GT(Blackhole bh) { } @Benchmark - public void UNSIGNED_LE(Blackhole bh) { + public void ULE(Blackhole bh) { short[] as = fa.apply(size); short[] bs = fb.apply(size); boolean r = true; @@ -1367,7 +1444,7 @@ public void UNSIGNED_LE(Blackhole bh) { } @Benchmark - public void UNSIGNED_GE(Blackhole bh) { + public void UGE(Blackhole bh) { short[] as = fa.apply(size); short[] bs = fb.apply(size); boolean r = true;