4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import jdk.incubator.vector.Vector;
25 import jdk.internal.misc.Unsafe;
26 import org.testng.Assert;
27 import org.testng.annotations.DataProvider;
28 import org.testng.annotations.Test;
29
30 /**
31 * @test
32 * @modules jdk.incubator.vector java.base/jdk.internal.misc
33 * @run testng PreferredSpeciesTest
34 */
35
36 public class PreferredSpeciesTest {
37 static final Unsafe U = Unsafe.getUnsafe();
38
39 @DataProvider
40 public static Object[][] classesProvider() {
41 return new Object[][]{
42 {byte.class},
43 {short.class},
44 {int.class},
45 {float.class},
46 {long.class},
47 {double.class},
48 };
49 }
50
51 @Test(dataProvider = "classesProvider")
52 void testVectorLength(Class<?> c) {
53 Vector.Species<?> species =
54 Vector.Species.ofPreferred(c);
55
56 Assert.assertEquals(species.length(), U.getMaxVectorSize(c));
57 }
58 }
|
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 import jdk.incubator.vector.*;
25 import jdk.internal.misc.Unsafe;
26 import org.testng.Assert;
27 import org.testng.annotations.DataProvider;
28 import org.testng.annotations.Test;
29
30 /**
31 * @test
32 * @modules jdk.incubator.vector java.base/jdk.internal.misc
33 * @run testng PreferredSpeciesTest
34 */
35
36 public class PreferredSpeciesTest {
37 static final Unsafe U = Unsafe.getUnsafe();
38
39 @DataProvider
40 public static Object[][] classesProvider() {
41 return new Object[][]{
42 {byte.class},
43 {short.class},
44 {int.class},
45 {float.class},
46 {long.class},
47 {double.class},
48 };
49 }
50
51 @Test(dataProvider = "classesProvider")
52 void testVectorLength(Class<?> c) {
53 Vector.Species<?> species = null;
54 if (c == byte.class) {
55 species = ByteVector.SPECIES_PREFERRED;
56 } else if (c == short.class) {
57 species = ShortVector.SPECIES_PREFERRED;
58 } else if (c == int.class) {
59 species = IntVector.SPECIES_PREFERRED;
60 } else if (c == long.class) {
61 species = LongVector.SPECIES_PREFERRED;
62 } else if (c == float.class) {
63 species = FloatVector.SPECIES_PREFERRED;
64 } else if (c == double.class) {
65 species = DoubleVector.SPECIES_PREFERRED;
66 } else {
67 throw new IllegalArgumentException("Bad vector element type: " + c.getName());
68 }
69
70 Assert.assertEquals(species.length(), U.getMaxVectorSize(c));
71 }
72 }
|