< prev index next >
test/jdk/jdk/incubator/vector/FloatMaxVectorTests.java
Print this page
rev 54658 : refactored mask and shuffle creation methods, moved classes to top-level
*** 25,36 ****
* @test
* @modules jdk.incubator.vector
* @run testng/othervm -ea -esa FloatMaxVectorTests
*/
! import jdk.incubator.vector.Vector.Shape;
! import jdk.incubator.vector.Vector.Species;
import jdk.incubator.vector.Vector;
import jdk.incubator.vector.FloatVector;
import org.testng.Assert;
--- 25,38 ----
* @test
* @modules jdk.incubator.vector
* @run testng/othervm -ea -esa FloatMaxVectorTests
*/
! import jdk.incubator.vector.VectorShape;
! import jdk.incubator.vector.VectorSpecies;
! import jdk.incubator.vector.VectorShuffle;
! import jdk.incubator.vector.VectorMask;
import jdk.incubator.vector.Vector;
import jdk.incubator.vector.FloatVector;
import org.testng.Assert;
*** 46,62 ****
import java.util.stream.Stream;
@Test
public class FloatMaxVectorTests extends AbstractVectorTest {
! static final Species<Float> SPECIES =
FloatVector.SPECIES_MAX;
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
! static Shape getMaxBit() {
! return Shape.S_Max_BIT;
}
interface FUnOp {
float apply(float a);
}
--- 48,64 ----
import java.util.stream.Stream;
@Test
public class FloatMaxVectorTests extends AbstractVectorTest {
! static final VectorSpecies<Float> SPECIES =
FloatVector.SPECIES_MAX;
static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);
! static VectorShape getMaxBit() {
! return VectorShape.S_Max_BIT;
}
interface FUnOp {
float apply(float a);
}
*** 564,574 ****
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
--- 566,576 ----
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
*** 604,614 ****
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
--- 606,616 ----
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
*** 647,657 ****
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
--- 649,659 ----
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
*** 688,698 ****
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
--- 690,700 ----
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
*** 973,983 ****
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
! Vector.Mask<Float> mv = av.lessThan(bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.getElement(j), a[i + j] < b[i + j]);
}
--- 975,985 ----
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
! VectorMask<Float> mv = av.lessThan(bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.getElement(j), a[i + j] < b[i + j]);
}
*** 993,1003 ****
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
! Vector.Mask<Float> mv = av.greaterThan(bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.getElement(j), a[i + j] > b[i + j]);
}
--- 995,1005 ----
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
! VectorMask<Float> mv = av.greaterThan(bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.getElement(j), a[i + j] > b[i + j]);
}
*** 1013,1023 ****
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
! Vector.Mask<Float> mv = av.equal(bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.getElement(j), a[i + j] == b[i + j]);
}
--- 1015,1025 ----
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
! VectorMask<Float> mv = av.equal(bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.getElement(j), a[i + j] == b[i + j]);
}
*** 1033,1043 ****
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
! Vector.Mask<Float> mv = av.notEqual(bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.getElement(j), a[i + j] != b[i + j]);
}
--- 1035,1045 ----
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
! VectorMask<Float> mv = av.notEqual(bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.getElement(j), a[i + j] != b[i + j]);
}
*** 1053,1063 ****
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
! Vector.Mask<Float> mv = av.lessThanEq(bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.getElement(j), a[i + j] <= b[i + j]);
}
--- 1055,1065 ----
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
! VectorMask<Float> mv = av.lessThanEq(bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.getElement(j), a[i + j] <= b[i + j]);
}
*** 1073,1083 ****
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
! Vector.Mask<Float> mv = av.greaterThanEq(bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.getElement(j), a[i + j] >= b[i + j]);
}
--- 1075,1085 ----
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
! VectorMask<Float> mv = av.greaterThanEq(bv);
// Check results as part of computation.
for (int j = 0; j < SPECIES.length(); j++) {
Assert.assertEquals(mv.getElement(j), a[i + j] >= b[i + j]);
}
*** 1095,1105 ****
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
--- 1097,1107 ----
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
*** 1118,1128 ****
float[] r = fr.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
! av.rearrange(FloatVector.shuffleFromArray(SPECIES, order, i)).intoArray(r, i);
}
}
assertRearrangeArraysEquals(a, r, order, SPECIES.length());
}
--- 1120,1130 ----
float[] r = fr.apply(SPECIES.length());
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
! av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);
}
}
assertRearrangeArraysEquals(a, r, order, SPECIES.length());
}
*** 1758,1768 ****
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] c = fc.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
--- 1760,1770 ----
float[] a = fa.apply(SPECIES.length());
float[] b = fb.apply(SPECIES.length());
float[] c = fc.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
FloatVector bv = FloatVector.fromArray(SPECIES, b, i);
*** 1798,1808 ****
static void negMaskedFloatMaxVectorTests(IntFunction<float[]> fa,
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
av.neg(vmask).intoArray(r, i);
--- 1800,1810 ----
static void negMaskedFloatMaxVectorTests(IntFunction<float[]> fa,
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
av.neg(vmask).intoArray(r, i);
*** 1835,1845 ****
static void absMaskedFloatMaxVectorTests(IntFunction<float[]> fa,
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
av.abs(vmask).intoArray(r, i);
--- 1837,1847 ----
static void absMaskedFloatMaxVectorTests(IntFunction<float[]> fa,
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
av.abs(vmask).intoArray(r, i);
*** 1880,1890 ****
static void sqrtMaskedFloatMaxVectorTests(IntFunction<float[]> fa,
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! Vector.Mask<Float> vmask = FloatVector.maskFromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
av.sqrt(vmask).intoArray(r, i);
--- 1882,1892 ----
static void sqrtMaskedFloatMaxVectorTests(IntFunction<float[]> fa,
IntFunction<boolean[]> fm) {
float[] a = fa.apply(SPECIES.length());
float[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
! VectorMask<Float> vmask = VectorMask.fromValues(SPECIES, mask);
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
FloatVector av = FloatVector.fromArray(SPECIES, a, i);
av.sqrt(vmask).intoArray(r, i);
< prev index next >