Path: blob/master/test/jdk/jdk/incubator/vector/Float128VectorTests.java
41304 views
/*1* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @modules jdk.incubator.vector26* @run testng/othervm -ea -esa -Xbatch -XX:-TieredCompilation Float128VectorTests27*/2829// -- This file was mechanically generated: Do not edit! -- //3031import jdk.incubator.vector.VectorShape;32import jdk.incubator.vector.VectorSpecies;33import jdk.incubator.vector.VectorShuffle;34import jdk.incubator.vector.VectorMask;35import jdk.incubator.vector.VectorOperators;36import jdk.incubator.vector.Vector;3738import jdk.incubator.vector.FloatVector;3940import org.testng.Assert;41import org.testng.annotations.DataProvider;42import org.testng.annotations.Test;4344import java.lang.Integer;45import java.util.List;46import java.util.Arrays;47import java.util.function.BiFunction;48import java.util.function.IntFunction;49import java.util.Objects;50import java.util.stream.Collectors;51import java.util.stream.Stream;5253@Test54public class Float128VectorTests extends AbstractVectorTest {5556static final VectorSpecies<Float> SPECIES =57FloatVector.SPECIES_128;5859static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100);606162static final int BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 128);6364static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", BUFFER_REPS * (128 / 8));6566interface FUnOp {67float apply(float a);68}6970static void assertArraysEquals(float[] r, float[] a, FUnOp f) {71int i = 0;72try {73for (; i < a.length; i++) {74Assert.assertEquals(r[i], f.apply(a[i]));75}76} catch (AssertionError e) {77Assert.assertEquals(r[i], f.apply(a[i]), "at index #" + i + ", input = " + a[i]);78}79}8081interface FUnArrayOp {82float[] apply(float a);83}8485static void assertArraysEquals(float[] r, float[] a, FUnArrayOp f) {86int i = 0;87try {88for (; i < a.length; i += SPECIES.length()) {89Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),90f.apply(a[i]));91}92} catch (AssertionError e) {93float[] ref = f.apply(a[i]);94float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());95Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)96+ ", res: " + Arrays.toString(res)97+ "), at index #" + i);98}99}100101static void assertArraysEquals(float[] r, float[] a, boolean[] mask, FUnOp f) {102int i = 0;103try {104for (; i < a.length; i++) {105Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i]);106}107} catch (AssertionError e) {108Assert.assertEquals(r[i], mask[i % SPECIES.length()] ? f.apply(a[i]) : a[i], "at index #" + i + ", input = " + a[i] + ", mask = " + mask[i % SPECIES.length()]);109}110}111112interface FReductionOp {113float apply(float[] a, int idx);114}115116interface FReductionAllOp {117float apply(float[] a);118}119120static void assertReductionArraysEquals(float[] r, float rc, float[] a,121FReductionOp f, FReductionAllOp fa) {122int i = 0;123try {124Assert.assertEquals(rc, fa.apply(a));125for (; i < a.length; i += SPECIES.length()) {126Assert.assertEquals(r[i], f.apply(a, i));127}128} catch (AssertionError e) {129Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");130Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);131}132}133134interface FReductionMaskedOp {135float apply(float[] a, int idx, boolean[] mask);136}137138interface FReductionAllMaskedOp {139float apply(float[] a, boolean[] mask);140}141142static void assertReductionArraysEqualsMasked(float[] r, float rc, float[] a, boolean[] mask,143FReductionMaskedOp f, FReductionAllMaskedOp fa) {144int i = 0;145try {146Assert.assertEquals(rc, fa.apply(a, mask));147for (; i < a.length; i += SPECIES.length()) {148Assert.assertEquals(r[i], f.apply(a, i, mask));149}150} catch (AssertionError e) {151Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");152Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);153}154}155156interface FReductionOpLong {157long apply(float[] a, int idx);158}159160interface FReductionAllOpLong {161long apply(float[] a);162}163164static void assertReductionLongArraysEquals(long[] r, long rc, float[] a,165FReductionOpLong f, FReductionAllOpLong fa) {166int i = 0;167try {168Assert.assertEquals(rc, fa.apply(a));169for (; i < a.length; i += SPECIES.length()) {170Assert.assertEquals(r[i], f.apply(a, i));171}172} catch (AssertionError e) {173Assert.assertEquals(rc, fa.apply(a), "Final result is incorrect!");174Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);175}176}177178interface FReductionMaskedOpLong {179long apply(float[] a, int idx, boolean[] mask);180}181182interface FReductionAllMaskedOpLong {183long apply(float[] a, boolean[] mask);184}185186static void assertReductionLongArraysEqualsMasked(long[] r, long rc, float[] a, boolean[] mask,187FReductionMaskedOpLong f, FReductionAllMaskedOpLong fa) {188int i = 0;189try {190Assert.assertEquals(rc, fa.apply(a, mask));191for (; i < a.length; i += SPECIES.length()) {192Assert.assertEquals(r[i], f.apply(a, i, mask));193}194} catch (AssertionError e) {195Assert.assertEquals(rc, fa.apply(a, mask), "Final result is incorrect!");196Assert.assertEquals(r[i], f.apply(a, i, mask), "at index #" + i);197}198}199200interface FBoolReductionOp {201boolean apply(boolean[] a, int idx);202}203204static void assertReductionBoolArraysEquals(boolean[] r, boolean[] a, FBoolReductionOp f) {205int i = 0;206try {207for (; i < a.length; i += SPECIES.length()) {208Assert.assertEquals(r[i], f.apply(a, i));209}210} catch (AssertionError e) {211Assert.assertEquals(r[i], f.apply(a, i), "at index #" + i);212}213}214215static void assertInsertArraysEquals(float[] r, float[] a, float element, int index) {216int i = 0;217try {218for (; i < a.length; i += 1) {219if(i%SPECIES.length() == index) {220Assert.assertEquals(r[i], element);221} else {222Assert.assertEquals(r[i], a[i]);223}224}225} catch (AssertionError e) {226if (i%SPECIES.length() == index) {227Assert.assertEquals(r[i], element, "at index #" + i);228} else {229Assert.assertEquals(r[i], a[i], "at index #" + i);230}231}232}233234static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, int vector_len) {235int i = 0, j = 0;236try {237for (; i < a.length; i += vector_len) {238for (j = 0; j < vector_len; j++) {239Assert.assertEquals(r[i+j], a[i+order[i+j]]);240}241}242} catch (AssertionError e) {243int idx = i + j;244Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);245}246}247248static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, int vector_len) {249int i = 0, j = 0;250try {251for (; i < a.length; i += vector_len) {252for (j = 0; j < vector_len; j++) {253Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);254}255}256} catch (AssertionError e) {257int idx = i + j;258Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);259}260}261262static void assertRearrangeArraysEquals(float[] r, float[] a, int[] order, boolean[] mask, int vector_len) {263int i = 0, j = 0;264try {265for (; i < a.length; i += vector_len) {266for (j = 0; j < vector_len; j++) {267if (mask[j % SPECIES.length()])268Assert.assertEquals(r[i+j], a[i+order[i+j]]);269else270Assert.assertEquals(r[i+j], (float)0);271}272}273} catch (AssertionError e) {274int idx = i + j;275if (mask[j % SPECIES.length()])276Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);277else278Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);279}280}281282static void assertSelectFromArraysEquals(float[] r, float[] a, float[] order, boolean[] mask, int vector_len) {283int i = 0, j = 0;284try {285for (; i < a.length; i += vector_len) {286for (j = 0; j < vector_len; j++) {287if (mask[j % SPECIES.length()])288Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);289else290Assert.assertEquals(r[i+j], (float)0);291}292}293} catch (AssertionError e) {294int idx = i + j;295if (mask[j % SPECIES.length()])296Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);297else298Assert.assertEquals(r[i+j], (float)0, "at index #" + idx + ", input = " + a[i+(int)order[i+j]] + ", mask = " + mask[j % SPECIES.length()]);299}300}301302static void assertBroadcastArraysEquals(float[] r, float[] a) {303int i = 0;304for (; i < a.length; i += SPECIES.length()) {305int idx = i;306for (int j = idx; j < (idx + SPECIES.length()); j++)307a[j]=a[idx];308}309310try {311for (i = 0; i < a.length; i++) {312Assert.assertEquals(r[i], a[i]);313}314} catch (AssertionError e) {315Assert.assertEquals(r[i], a[i], "at index #" + i + ", input = " + a[i]);316}317}318319interface FBinOp {320float apply(float a, float b);321}322323interface FBinMaskOp {324float apply(float a, float b, boolean m);325326static FBinMaskOp lift(FBinOp f) {327return (a, b, m) -> m ? f.apply(a, b) : a;328}329}330331static void assertArraysEquals(float[] r, float[] a, float[] b, FBinOp f) {332int i = 0;333try {334for (; i < a.length; i++) {335Assert.assertEquals(r[i], f.apply(a[i], b[i]));336}337} catch (AssertionError e) {338Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);339}340}341342static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, FBinOp f) {343int i = 0;344try {345for (; i < a.length; i++) {346Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));347}348} catch (AssertionError e) {349Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]),350"(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);351}352}353354static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, FBinOp f) {355int i = 0;356try {357for (; i < a.length; i++) {358Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()])));359}360} catch (AssertionError e) {361Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()])),362"(" + a[i] + ", " + b[(i / SPECIES.length()) * SPECIES.length()] + ") at index #" + i);363}364}365366static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) {367assertArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));368}369370static void assertArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) {371int i = 0;372try {373for (; i < a.length; i++) {374Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]));375}376} catch (AssertionError err) {377Assert.assertEquals(r[i], f.apply(a[i], b[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", mask = " + mask[i % SPECIES.length()]);378}379}380381static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) {382assertBroadcastArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));383}384385static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) {386int i = 0;387try {388for (; i < a.length; i++) {389Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));390}391} catch (AssertionError err) {392Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],393mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +394", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +395mask[i % SPECIES.length()]);396}397}398399static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) {400assertBroadcastLongArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));401}402403static void assertBroadcastLongArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) {404int i = 0;405try {406for (; i < a.length; i++) {407Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]), mask[i % SPECIES.length()]));408}409} catch (AssertionError err) {410Assert.assertEquals(r[i], f.apply(a[i], (float)((long)b[(i / SPECIES.length()) * SPECIES.length()]),411mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +412", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +413mask[i % SPECIES.length()]);414}415}416417static void assertShiftArraysEquals(float[] r, float[] a, float[] b, FBinOp f) {418int i = 0;419int j = 0;420try {421for (; j < a.length; j += SPECIES.length()) {422for (i = 0; i < SPECIES.length(); i++) {423Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]));424}425}426} catch (AssertionError e) {427Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j]), "at index #" + i + ", " + j);428}429}430431static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinOp f) {432assertShiftArraysEquals(r, a, b, mask, FBinMaskOp.lift(f));433}434435static void assertShiftArraysEquals(float[] r, float[] a, float[] b, boolean[] mask, FBinMaskOp f) {436int i = 0;437int j = 0;438try {439for (; j < a.length; j += SPECIES.length()) {440for (i = 0; i < SPECIES.length(); i++) {441Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]));442}443}444} catch (AssertionError err) {445Assert.assertEquals(r[i+j], f.apply(a[i+j], b[j], mask[i]), "at index #" + i + ", input1 = " + a[i+j] + ", input2 = " + b[j] + ", mask = " + mask[i]);446}447}448449interface FTernOp {450float apply(float a, float b, float c);451}452453interface FTernMaskOp {454float apply(float a, float b, float c, boolean m);455456static FTernMaskOp lift(FTernOp f) {457return (a, b, c, m) -> m ? f.apply(a, b, c) : a;458}459}460461static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) {462int i = 0;463try {464for (; i < a.length; i++) {465Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]));466}467} catch (AssertionError e) {468Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " + c[i]);469}470}471472static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernOp f) {473assertArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));474}475476static void assertArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask, FTernMaskOp f) {477int i = 0;478try {479for (; i < a.length; i++) {480Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]));481}482} catch (AssertionError err) {483Assert.assertEquals(r[i], f.apply(a[i], b[i], c[i], mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = "484+ b[i] + ", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);485}486}487488static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) {489int i = 0;490try {491for (; i < a.length; i++) {492Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]));493}494} catch (AssertionError e) {495Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" +496i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", input3 = " +497c[(i / SPECIES.length()) * SPECIES.length()]);498}499}500501static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) {502int i = 0;503try {504for (; i < a.length; i++) {505Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]));506}507} catch (AssertionError e) {508Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i]), "at index #" +509i + ", input1 = " + a[i] + ", input2 = " +510b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " + c[i]);511}512}513514static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask,515FTernOp f) {516assertBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));517}518519static void assertBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask,520FTernMaskOp f) {521int i = 0;522try {523for (; i < a.length; i++) {524Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],525mask[i % SPECIES.length()]));526}527} catch (AssertionError err) {528Assert.assertEquals(r[i], f.apply(a[i], b[i], c[(i / SPECIES.length()) * SPECIES.length()],529mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] + ", input2 = " +530b[i] + ", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +531mask[i % SPECIES.length()]);532}533}534535static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask,536FTernOp f) {537assertAltBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));538}539540static void assertAltBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask,541FTernMaskOp f) {542int i = 0;543try {544for (; i < a.length; i++) {545Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],546mask[i % SPECIES.length()]));547}548} catch (AssertionError err) {549Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()], c[i],550mask[i % SPECIES.length()]), "at index #" + i + ", input1 = " + a[i] +551", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +552", input3 = " + c[i] + ", mask = " + mask[i % SPECIES.length()]);553}554}555556static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, FTernOp f) {557int i = 0;558try {559for (; i < a.length; i++) {560Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],561c[(i / SPECIES.length()) * SPECIES.length()]));562}563} catch (AssertionError e) {564Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],565c[(i / SPECIES.length()) * SPECIES.length()]), "at index #" + i + ", input1 = " + a[i]566+ ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] + ", input3 = " +567c[(i / SPECIES.length()) * SPECIES.length()]);568}569}570571static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask,572FTernOp f) {573assertDoubleBroadcastArraysEquals(r, a, b, c, mask, FTernMaskOp.lift(f));574}575576static void assertDoubleBroadcastArraysEquals(float[] r, float[] a, float[] b, float[] c, boolean[] mask,577FTernMaskOp f) {578int i = 0;579try {580for (; i < a.length; i++) {581Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],582c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]));583}584} catch (AssertionError err) {585Assert.assertEquals(r[i], f.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()],586c[(i / SPECIES.length()) * SPECIES.length()], mask[i % SPECIES.length()]), "at index #"587+ i + ", input1 = " + a[i] + ", input2 = " + b[(i / SPECIES.length()) * SPECIES.length()] +588", input3 = " + c[(i / SPECIES.length()) * SPECIES.length()] + ", mask = " +589mask[i % SPECIES.length()]);590}591}592593594static boolean isWithin1Ulp(float actual, float expected) {595if (Float.isNaN(expected) && !Float.isNaN(actual)) {596return false;597} else if (!Float.isNaN(expected) && Float.isNaN(actual)) {598return false;599}600601float low = Math.nextDown(expected);602float high = Math.nextUp(expected);603604if (Float.compare(low, expected) > 0) {605return false;606}607608if (Float.compare(high, expected) < 0) {609return false;610}611612return true;613}614615static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, FUnOp mathf, FUnOp strictmathf) {616int i = 0;617try {618// Check that result is within 1 ulp of strict math or equivalent to math implementation.619for (; i < a.length; i++) {620Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i])) == 0 ||621isWithin1Ulp(r[i], strictmathf.apply(a[i])));622}623} catch (AssertionError e) {624Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i])) == 0, "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i]));625Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i])), "at index #" + i + ", input = " + a[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i]));626}627}628629static void assertArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b, FBinOp mathf, FBinOp strictmathf) {630int i = 0;631try {632// Check that result is within 1 ulp of strict math or equivalent to math implementation.633for (; i < a.length; i++) {634Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i], b[i])) == 0 ||635isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])));636}637} catch (AssertionError e) {638Assert.assertTrue(Float.compare(r[i], mathf.apply(a[i], b[i])) == 0, "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected = " + mathf.apply(a[i], b[i]));639Assert.assertTrue(isWithin1Ulp(r[i], strictmathf.apply(a[i], b[i])), "at index #" + i + ", input1 = " + a[i] + ", input2 = " + b[i] + ", actual = " + r[i] + ", expected (within 1 ulp) = " + strictmathf.apply(a[i], b[i]));640}641}642643static void assertBroadcastArraysEqualsWithinOneUlp(float[] r, float[] a, float[] b,644FBinOp mathf, FBinOp strictmathf) {645int i = 0;646try {647// Check that result is within 1 ulp of strict math or equivalent to math implementation.648for (; i < a.length; i++) {649Assert.assertTrue(Float.compare(r[i],650mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])) == 0 ||651isWithin1Ulp(r[i],652strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])));653}654} catch (AssertionError e) {655Assert.assertTrue(Float.compare(r[i],656mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])) == 0,657"at index #" + i + ", input1 = " + a[i] + ", input2 = " +658b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] +659", expected = " + mathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()]));660Assert.assertTrue(isWithin1Ulp(r[i],661strictmathf.apply(a[i], b[(i / SPECIES.length()) * SPECIES.length()])),662"at index #" + i + ", input1 = " + a[i] + ", input2 = " +663b[(i / SPECIES.length()) * SPECIES.length()] + ", actual = " + r[i] +664", expected (within 1 ulp) = " + strictmathf.apply(a[i],665b[(i / SPECIES.length()) * SPECIES.length()]));666}667}668669interface FBinArrayOp {670float apply(float[] a, int b);671}672673static void assertArraysEquals(float[] r, float[] a, FBinArrayOp f) {674int i = 0;675try {676for (; i < a.length; i++) {677Assert.assertEquals(r[i], f.apply(a, i));678}679} catch (AssertionError e) {680Assert.assertEquals(r[i], f.apply(a,i), "at index #" + i);681}682}683684interface FGatherScatterOp {685float[] apply(float[] a, int ix, int[] b, int iy);686}687688static void assertArraysEquals(float[] r, float[] a, int[] b, FGatherScatterOp f) {689int i = 0;690try {691for (; i < a.length; i += SPECIES.length()) {692Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),693f.apply(a, i, b, i));694}695} catch (AssertionError e) {696float[] ref = f.apply(a, i, b, i);697float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());698Assert.assertEquals(res, ref,699"(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "700+ Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))701+ ", b: "702+ Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))703+ " at index #" + i);704}705}706707interface FGatherMaskedOp {708float[] apply(float[] a, int ix, boolean[] mask, int[] b, int iy);709}710711interface FScatterMaskedOp {712float[] apply(float[] r, float[] a, int ix, boolean[] mask, int[] b, int iy);713}714715static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FGatherMaskedOp f) {716int i = 0;717try {718for (; i < a.length; i += SPECIES.length()) {719Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),720f.apply(a, i, mask, b, i));721}722} catch (AssertionError e) {723float[] ref = f.apply(a, i, mask, b, i);724float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());725Assert.assertEquals(res, ref,726"(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "727+ Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))728+ ", b: "729+ Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))730+ ", mask: "731+ Arrays.toString(mask)732+ " at index #" + i);733}734}735736static void assertArraysEquals(float[] r, float[] a, int[] b, boolean[] mask, FScatterMaskedOp f) {737int i = 0;738try {739for (; i < a.length; i += SPECIES.length()) {740Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),741f.apply(r, a, i, mask, b, i));742}743} catch (AssertionError e) {744float[] ref = f.apply(r, a, i, mask, b, i);745float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());746Assert.assertEquals(res, ref,747"(ref: " + Arrays.toString(ref) + ", res: " + Arrays.toString(res) + ", a: "748+ Arrays.toString(Arrays.copyOfRange(a, i, i+SPECIES.length()))749+ ", b: "750+ Arrays.toString(Arrays.copyOfRange(b, i, i+SPECIES.length()))751+ ", r: "752+ Arrays.toString(Arrays.copyOfRange(r, i, i+SPECIES.length()))753+ ", mask: "754+ Arrays.toString(mask)755+ " at index #" + i);756}757}758759interface FLaneOp {760float[] apply(float[] a, int origin, int idx);761}762763static void assertArraysEquals(float[] r, float[] a, int origin, FLaneOp f) {764int i = 0;765try {766for (; i < a.length; i += SPECIES.length()) {767Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),768f.apply(a, origin, i));769}770} catch (AssertionError e) {771float[] ref = f.apply(a, origin, i);772float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());773Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)774+ ", res: " + Arrays.toString(res)775+ "), at index #" + i);776}777}778779interface FLaneBop {780float[] apply(float[] a, float[] b, int origin, int idx);781}782783static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, FLaneBop f) {784int i = 0;785try {786for (; i < a.length; i += SPECIES.length()) {787Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),788f.apply(a, b, origin, i));789}790} catch (AssertionError e) {791float[] ref = f.apply(a, b, origin, i);792float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());793Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)794+ ", res: " + Arrays.toString(res)795+ "), at index #" + i796+ ", at origin #" + origin);797}798}799800interface FLaneMaskedBop {801float[] apply(float[] a, float[] b, int origin, boolean[] mask, int idx);802}803804static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, boolean[] mask, FLaneMaskedBop f) {805int i = 0;806try {807for (; i < a.length; i += SPECIES.length()) {808Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),809f.apply(a, b, origin, mask, i));810}811} catch (AssertionError e) {812float[] ref = f.apply(a, b, origin, mask, i);813float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());814Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)815+ ", res: " + Arrays.toString(res)816+ "), at index #" + i817+ ", at origin #" + origin);818}819}820821interface FLanePartBop {822float[] apply(float[] a, float[] b, int origin, int part, int idx);823}824825static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int part, FLanePartBop f) {826int i = 0;827try {828for (; i < a.length; i += SPECIES.length()) {829Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),830f.apply(a, b, origin, part, i));831}832} catch (AssertionError e) {833float[] ref = f.apply(a, b, origin, part, i);834float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());835Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)836+ ", res: " + Arrays.toString(res)837+ "), at index #" + i838+ ", at origin #" + origin839+ ", with part #" + part);840}841}842843interface FLanePartMaskedBop {844float[] apply(float[] a, float[] b, int origin, int part, boolean[] mask, int idx);845}846847static void assertArraysEquals(float[] r, float[] a, float[] b, int origin, int part, boolean[] mask, FLanePartMaskedBop f) {848int i = 0;849try {850for (; i < a.length; i += SPECIES.length()) {851Assert.assertEquals(Arrays.copyOfRange(r, i, i+SPECIES.length()),852f.apply(a, b, origin, part, mask, i));853}854} catch (AssertionError e) {855float[] ref = f.apply(a, b, origin, part, mask, i);856float[] res = Arrays.copyOfRange(r, i, i+SPECIES.length());857Assert.assertEquals(res, ref, "(ref: " + Arrays.toString(ref)858+ ", res: " + Arrays.toString(res)859+ "), at index #" + i860+ ", at origin #" + origin861+ ", with part #" + part);862}863}864865static int intCornerCaseValue(int i) {866switch(i % 5) {867case 0:868return Integer.MAX_VALUE;869case 1:870return Integer.MIN_VALUE;871case 2:872return Integer.MIN_VALUE;873case 3:874return Integer.MAX_VALUE;875default:876return (int)0;877}878}879880static final List<IntFunction<float[]>> INT_FLOAT_GENERATORS = List.of(881withToString("float[-i * 5]", (int s) -> {882return fill(s * BUFFER_REPS,883i -> (float)(-i * 5));884}),885withToString("float[i * 5]", (int s) -> {886return fill(s * BUFFER_REPS,887i -> (float)(i * 5));888}),889withToString("float[i + 1]", (int s) -> {890return fill(s * BUFFER_REPS,891i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1)));892}),893withToString("float[intCornerCaseValue(i)]", (int s) -> {894return fill(s * BUFFER_REPS,895i -> (float)intCornerCaseValue(i));896})897);898899static void assertArraysEquals(int[] r, float[] a, int offs) {900int i = 0;901try {902for (; i < r.length; i++) {903Assert.assertEquals(r[i], (int)(a[i+offs]));904}905} catch (AssertionError e) {906Assert.assertEquals(r[i], (int)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);907}908}909910static long longCornerCaseValue(int i) {911switch(i % 5) {912case 0:913return Long.MAX_VALUE;914case 1:915return Long.MIN_VALUE;916case 2:917return Long.MIN_VALUE;918case 3:919return Long.MAX_VALUE;920default:921return (long)0;922}923}924925static final List<IntFunction<float[]>> LONG_FLOAT_GENERATORS = List.of(926withToString("float[-i * 5]", (int s) -> {927return fill(s * BUFFER_REPS,928i -> (float)(-i * 5));929}),930withToString("float[i * 5]", (int s) -> {931return fill(s * BUFFER_REPS,932i -> (float)(i * 5));933}),934withToString("float[i + 1]", (int s) -> {935return fill(s * BUFFER_REPS,936i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1)));937}),938withToString("float[cornerCaseValue(i)]", (int s) -> {939return fill(s * BUFFER_REPS,940i -> (float)longCornerCaseValue(i));941})942);943944945static void assertArraysEquals(long[] r, float[] a, int offs) {946int i = 0;947try {948for (; i < r.length; i++) {949Assert.assertEquals(r[i], (long)(a[i+offs]));950}951} catch (AssertionError e) {952Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);953}954}955956static void assertArraysEquals(double[] r, float[] a, int offs) {957int i = 0;958try {959for (; i < r.length; i++) {960Assert.assertEquals(r[i], (double)(a[i+offs]));961}962} catch (AssertionError e) {963Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);964}965}966967968static int bits(float e) {969return Float.floatToIntBits(e);970}971972static final List<IntFunction<float[]>> FLOAT_GENERATORS = List.of(973withToString("float[-i * 5]", (int s) -> {974return fill(s * BUFFER_REPS,975i -> (float)(-i * 5));976}),977withToString("float[i * 5]", (int s) -> {978return fill(s * BUFFER_REPS,979i -> (float)(i * 5));980}),981withToString("float[i + 1]", (int s) -> {982return fill(s * BUFFER_REPS,983i -> (((float)(i + 1) == 0) ? 1 : (float)(i + 1)));984}),985withToString("float[cornerCaseValue(i)]", (int s) -> {986return fill(s * BUFFER_REPS,987i -> cornerCaseValue(i));988})989);990991// Create combinations of pairs992// @@@ Might be sensitive to order e.g. div by 0993static final List<List<IntFunction<float[]>>> FLOAT_GENERATOR_PAIRS =994Stream.of(FLOAT_GENERATORS.get(0)).995flatMap(fa -> FLOAT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))).996collect(Collectors.toList());997998@DataProvider999public Object[][] boolUnaryOpProvider() {1000return BOOL_ARRAY_GENERATORS.stream().1001map(f -> new Object[]{f}).1002toArray(Object[][]::new);1003}10041005static final List<List<IntFunction<float[]>>> FLOAT_GENERATOR_TRIPLES =1006FLOAT_GENERATOR_PAIRS.stream().1007flatMap(pair -> FLOAT_GENERATORS.stream().map(f -> List.of(pair.get(0), pair.get(1), f))).1008collect(Collectors.toList());10091010@DataProvider1011public Object[][] floatBinaryOpProvider() {1012return FLOAT_GENERATOR_PAIRS.stream().map(List::toArray).1013toArray(Object[][]::new);1014}10151016@DataProvider1017public Object[][] floatIndexedOpProvider() {1018return FLOAT_GENERATOR_PAIRS.stream().map(List::toArray).1019toArray(Object[][]::new);1020}10211022@DataProvider1023public Object[][] floatBinaryOpMaskProvider() {1024return BOOLEAN_MASK_GENERATORS.stream().1025flatMap(fm -> FLOAT_GENERATOR_PAIRS.stream().map(lfa -> {1026return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();1027})).1028toArray(Object[][]::new);1029}10301031@DataProvider1032public Object[][] floatTernaryOpProvider() {1033return FLOAT_GENERATOR_TRIPLES.stream().map(List::toArray).1034toArray(Object[][]::new);1035}10361037@DataProvider1038public Object[][] floatTernaryOpMaskProvider() {1039return BOOLEAN_MASK_GENERATORS.stream().1040flatMap(fm -> FLOAT_GENERATOR_TRIPLES.stream().map(lfa -> {1041return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();1042})).1043toArray(Object[][]::new);1044}10451046@DataProvider1047public Object[][] floatUnaryOpProvider() {1048return FLOAT_GENERATORS.stream().1049map(f -> new Object[]{f}).1050toArray(Object[][]::new);1051}10521053@DataProvider1054public Object[][] floatUnaryOpMaskProvider() {1055return BOOLEAN_MASK_GENERATORS.stream().1056flatMap(fm -> FLOAT_GENERATORS.stream().map(fa -> {1057return new Object[] {fa, fm};1058})).1059toArray(Object[][]::new);1060}10611062@DataProvider1063public Object[][] floattoIntUnaryOpProvider() {1064return INT_FLOAT_GENERATORS.stream().1065map(f -> new Object[]{f}).1066toArray(Object[][]::new);1067}10681069@DataProvider1070public Object[][] floattoLongUnaryOpProvider() {1071return LONG_FLOAT_GENERATORS.stream().1072map(f -> new Object[]{f}).1073toArray(Object[][]::new);1074}10751076@DataProvider1077public Object[][] maskProvider() {1078return BOOLEAN_MASK_GENERATORS.stream().1079map(f -> new Object[]{f}).1080toArray(Object[][]::new);1081}10821083@DataProvider1084public Object[][] maskCompareOpProvider() {1085return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).1086toArray(Object[][]::new);1087}10881089@DataProvider1090public Object[][] shuffleProvider() {1091return INT_SHUFFLE_GENERATORS.stream().1092map(f -> new Object[]{f}).1093toArray(Object[][]::new);1094}10951096@DataProvider1097public Object[][] shuffleCompareOpProvider() {1098return INT_SHUFFLE_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).1099toArray(Object[][]::new);1100}11011102@DataProvider1103public Object[][] floatUnaryOpShuffleProvider() {1104return INT_SHUFFLE_GENERATORS.stream().1105flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {1106return new Object[] {fa, fs};1107})).1108toArray(Object[][]::new);1109}11101111@DataProvider1112public Object[][] floatUnaryOpShuffleMaskProvider() {1113return BOOLEAN_MASK_GENERATORS.stream().1114flatMap(fm -> INT_SHUFFLE_GENERATORS.stream().1115flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {1116return new Object[] {fa, fs, fm};1117}))).1118toArray(Object[][]::new);1119}11201121static final List<BiFunction<Integer,Integer,float[]>> FLOAT_SHUFFLE_GENERATORS = List.of(1122withToStringBi("shuffle[random]", (Integer l, Integer m) -> {1123float[] a = new float[l];1124int upper = m;1125for (int i = 0; i < 1; i++) {1126a[i] = (float)RAND.nextInt(upper);1127}1128return a;1129})1130);11311132@DataProvider1133public Object[][] floatUnaryOpSelectFromProvider() {1134return FLOAT_SHUFFLE_GENERATORS.stream().1135flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {1136return new Object[] {fa, fs};1137})).1138toArray(Object[][]::new);1139}11401141@DataProvider1142public Object[][] floatUnaryOpSelectFromMaskProvider() {1143return BOOLEAN_MASK_GENERATORS.stream().1144flatMap(fm -> FLOAT_SHUFFLE_GENERATORS.stream().1145flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {1146return new Object[] {fa, fs, fm};1147}))).1148toArray(Object[][]::new);1149}115011511152@DataProvider1153public Object[][] floatUnaryOpIndexProvider() {1154return INT_INDEX_GENERATORS.stream().1155flatMap(fs -> FLOAT_GENERATORS.stream().map(fa -> {1156return new Object[] {fa, fs};1157})).1158toArray(Object[][]::new);1159}11601161@DataProvider1162public Object[][] floatUnaryMaskedOpIndexProvider() {1163return BOOLEAN_MASK_GENERATORS.stream().1164flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->1165FLOAT_GENERATORS.stream().map(fa -> {1166return new Object[] {fa, fm, fs};1167}))).1168toArray(Object[][]::new);1169}11701171@DataProvider1172public Object[][] scatterMaskedOpIndexProvider() {1173return BOOLEAN_MASK_GENERATORS.stream().1174flatMap(fs -> INT_INDEX_GENERATORS.stream().flatMap(fm ->1175FLOAT_GENERATORS.stream().flatMap(fn ->1176FLOAT_GENERATORS.stream().map(fa -> {1177return new Object[] {fa, fn, fm, fs};1178})))).1179toArray(Object[][]::new);1180}11811182static final List<IntFunction<float[]>> FLOAT_COMPARE_GENERATORS = List.of(1183withToString("float[i]", (int s) -> {1184return fill(s * BUFFER_REPS,1185i -> (float)i);1186}),1187withToString("float[i - length / 2]", (int s) -> {1188return fill(s * BUFFER_REPS,1189i -> (float)(i - (s * BUFFER_REPS / 2)));1190}),1191withToString("float[i + 1]", (int s) -> {1192return fill(s * BUFFER_REPS,1193i -> (float)(i + 1));1194}),1195withToString("float[i - 2]", (int s) -> {1196return fill(s * BUFFER_REPS,1197i -> (float)(i - 2));1198}),1199withToString("float[zigZag(i)]", (int s) -> {1200return fill(s * BUFFER_REPS,1201i -> i%3 == 0 ? (float)i : (i%3 == 1 ? (float)(i + 1) : (float)(i - 2)));1202}),1203withToString("float[cornerCaseValue(i)]", (int s) -> {1204return fill(s * BUFFER_REPS,1205i -> cornerCaseValue(i));1206})1207);12081209static final List<List<IntFunction<float[]>>> FLOAT_TEST_GENERATOR_ARGS =1210FLOAT_COMPARE_GENERATORS.stream().1211map(fa -> List.of(fa)).1212collect(Collectors.toList());12131214@DataProvider1215public Object[][] floatTestOpProvider() {1216return FLOAT_TEST_GENERATOR_ARGS.stream().map(List::toArray).1217toArray(Object[][]::new);1218}12191220@DataProvider1221public Object[][] floatTestOpMaskProvider() {1222return BOOLEAN_MASK_GENERATORS.stream().1223flatMap(fm -> FLOAT_TEST_GENERATOR_ARGS.stream().map(lfa -> {1224return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();1225})).1226toArray(Object[][]::new);1227}12281229static final List<List<IntFunction<float[]>>> FLOAT_COMPARE_GENERATOR_PAIRS =1230FLOAT_COMPARE_GENERATORS.stream().1231flatMap(fa -> FLOAT_COMPARE_GENERATORS.stream().map(fb -> List.of(fa, fb))).1232collect(Collectors.toList());12331234@DataProvider1235public Object[][] floatCompareOpProvider() {1236return FLOAT_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).1237toArray(Object[][]::new);1238}12391240@DataProvider1241public Object[][] floatCompareOpMaskProvider() {1242return BOOLEAN_MASK_GENERATORS.stream().1243flatMap(fm -> FLOAT_COMPARE_GENERATOR_PAIRS.stream().map(lfa -> {1244return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();1245})).1246toArray(Object[][]::new);1247}12481249interface ToFloatF {1250float apply(int i);1251}12521253static float[] fill(int s , ToFloatF f) {1254return fill(new float[s], f);1255}12561257static float[] fill(float[] a, ToFloatF f) {1258for (int i = 0; i < a.length; i++) {1259a[i] = f.apply(i);1260}1261return a;1262}12631264static float cornerCaseValue(int i) {1265switch(i % 7) {1266case 0:1267return Float.MAX_VALUE;1268case 1:1269return Float.MIN_VALUE;1270case 2:1271return Float.NEGATIVE_INFINITY;1272case 3:1273return Float.POSITIVE_INFINITY;1274case 4:1275return Float.NaN;1276case 5:1277return (float)0.0;1278default:1279return (float)-0.0;1280}1281}12821283static float get(float[] a, int i) {1284return (float) a[i];1285}12861287static final IntFunction<float[]> fr = (vl) -> {1288int length = BUFFER_REPS * vl;1289return new float[length];1290};12911292static final IntFunction<boolean[]> fmr = (vl) -> {1293int length = BUFFER_REPS * vl;1294return new boolean[length];1295};12961297static final IntFunction<long[]> lfr = (vl) -> {1298int length = BUFFER_REPS * vl;1299return new long[length];1300};130113021303static boolean eq(float a, float b) {1304return a == b;1305}13061307static boolean neq(float a, float b) {1308return a != b;1309}13101311static boolean lt(float a, float b) {1312return a < b;1313}13141315static boolean le(float a, float b) {1316return a <= b;1317}13181319static boolean gt(float a, float b) {1320return a > b;1321}13221323static boolean ge(float a, float b) {1324return a >= b;1325}132613271328@Test1329static void smokeTest1() {1330FloatVector three = FloatVector.broadcast(SPECIES, (byte)-3);1331FloatVector three2 = (FloatVector) SPECIES.broadcast(-3);1332assert(three.eq(three2).allTrue());1333FloatVector three3 = three2.broadcast(1).broadcast(-3);1334assert(three.eq(three3).allTrue());1335int scale = 2;1336Class<?> ETYPE = float.class;1337if (ETYPE == double.class || ETYPE == long.class)1338scale = 1000000;1339else if (ETYPE == byte.class && SPECIES.length() >= 64)1340scale = 1;1341FloatVector higher = three.addIndex(scale);1342VectorMask<Float> m = three.compare(VectorOperators.LE, higher);1343assert(m.allTrue());1344m = higher.min((float)-1).test(VectorOperators.IS_NEGATIVE);1345assert(m.allTrue());1346m = higher.test(VectorOperators.IS_FINITE);1347assert(m.allTrue());1348float max = higher.reduceLanes(VectorOperators.MAX);1349assert(max == -3 + scale * (SPECIES.length()-1));1350}13511352private static float[]1353bothToArray(FloatVector a, FloatVector b) {1354float[] r = new float[a.length() + b.length()];1355a.intoArray(r, 0);1356b.intoArray(r, a.length());1357return r;1358}13591360@Test1361static void smokeTest2() {1362// Do some zipping and shuffling.1363FloatVector io = (FloatVector) SPECIES.broadcast(0).addIndex(1);1364FloatVector io2 = (FloatVector) VectorShuffle.iota(SPECIES,0,1,false).toVector();1365Assert.assertEquals(io, io2);1366FloatVector a = io.add((float)1); //[1,2]1367FloatVector b = a.neg(); //[-1,-2]1368float[] abValues = bothToArray(a,b); //[1,2,-1,-2]1369VectorShuffle<Float> zip0 = VectorShuffle.makeZip(SPECIES, 0);1370VectorShuffle<Float> zip1 = VectorShuffle.makeZip(SPECIES, 1);1371FloatVector zab0 = a.rearrange(zip0,b); //[1,-1]1372FloatVector zab1 = a.rearrange(zip1,b); //[2,-2]1373float[] zabValues = bothToArray(zab0, zab1); //[1,-1,2,-2]1374// manually zip1375float[] manual = new float[zabValues.length];1376for (int i = 0; i < manual.length; i += 2) {1377manual[i+0] = abValues[i/2];1378manual[i+1] = abValues[a.length() + i/2];1379}1380Assert.assertEquals(Arrays.toString(zabValues), Arrays.toString(manual));1381VectorShuffle<Float> unz0 = VectorShuffle.makeUnzip(SPECIES, 0);1382VectorShuffle<Float> unz1 = VectorShuffle.makeUnzip(SPECIES, 1);1383FloatVector uab0 = zab0.rearrange(unz0,zab1);1384FloatVector uab1 = zab0.rearrange(unz1,zab1);1385float[] abValues1 = bothToArray(uab0, uab1);1386Assert.assertEquals(Arrays.toString(abValues), Arrays.toString(abValues1));1387}13881389static void iotaShuffle() {1390FloatVector io = (FloatVector) SPECIES.broadcast(0).addIndex(1);1391FloatVector io2 = (FloatVector) VectorShuffle.iota(SPECIES, 0 , 1, false).toVector();1392Assert.assertEquals(io, io2);1393}13941395@Test1396// Test all shuffle related operations.1397static void shuffleTest() {1398// To test backend instructions, make sure that C2 is used.1399for (int loop = 0; loop < INVOC_COUNT * INVOC_COUNT; loop++) {1400iotaShuffle();1401}1402}14031404@Test1405void viewAsIntegeralLanesTest() {1406Vector<?> asIntegral = SPECIES.zero().viewAsIntegralLanes();1407VectorSpecies<?> asIntegralSpecies = asIntegral.species();1408Assert.assertNotEquals(asIntegralSpecies.elementType(), SPECIES.elementType());1409Assert.assertEquals(asIntegralSpecies.vectorShape(), SPECIES.vectorShape());1410Assert.assertEquals(asIntegralSpecies.length(), SPECIES.length());1411Assert.assertEquals(asIntegral.viewAsFloatingLanes().species(), SPECIES);1412}14131414@Test1415void viewAsFloatingLanesTest() {1416Vector<?> asFloating = SPECIES.zero().viewAsFloatingLanes();1417Assert.assertEquals(asFloating.species(), SPECIES);1418}14191420static float ADD(float a, float b) {1421return (float)(a + b);1422}14231424@Test(dataProvider = "floatBinaryOpProvider")1425static void ADDFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {1426float[] a = fa.apply(SPECIES.length());1427float[] b = fb.apply(SPECIES.length());1428float[] r = fr.apply(SPECIES.length());14291430for (int ic = 0; ic < INVOC_COUNT; ic++) {1431for (int i = 0; i < a.length; i += SPECIES.length()) {1432FloatVector av = FloatVector.fromArray(SPECIES, a, i);1433FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1434av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);1435}1436}14371438assertArraysEquals(r, a, b, Float128VectorTests::ADD);1439}1440static float add(float a, float b) {1441return (float)(a + b);1442}14431444@Test(dataProvider = "floatBinaryOpProvider")1445static void addFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {1446float[] a = fa.apply(SPECIES.length());1447float[] b = fb.apply(SPECIES.length());1448float[] r = fr.apply(SPECIES.length());14491450for (int i = 0; i < a.length; i += SPECIES.length()) {1451FloatVector av = FloatVector.fromArray(SPECIES, a, i);1452FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1453av.add(bv).intoArray(r, i);1454}14551456assertArraysEquals(r, a, b, Float128VectorTests::add);1457}14581459@Test(dataProvider = "floatBinaryOpMaskProvider")1460static void ADDFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,1461IntFunction<boolean[]> fm) {1462float[] a = fa.apply(SPECIES.length());1463float[] b = fb.apply(SPECIES.length());1464float[] r = fr.apply(SPECIES.length());1465boolean[] mask = fm.apply(SPECIES.length());1466VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);14671468for (int ic = 0; ic < INVOC_COUNT; ic++) {1469for (int i = 0; i < a.length; i += SPECIES.length()) {1470FloatVector av = FloatVector.fromArray(SPECIES, a, i);1471FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1472av.lanewise(VectorOperators.ADD, bv, vmask).intoArray(r, i);1473}1474}14751476assertArraysEquals(r, a, b, mask, Float128VectorTests::ADD);1477}14781479@Test(dataProvider = "floatBinaryOpMaskProvider")1480static void addFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,1481IntFunction<boolean[]> fm) {1482float[] a = fa.apply(SPECIES.length());1483float[] b = fb.apply(SPECIES.length());1484float[] r = fr.apply(SPECIES.length());1485boolean[] mask = fm.apply(SPECIES.length());1486VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);14871488for (int i = 0; i < a.length; i += SPECIES.length()) {1489FloatVector av = FloatVector.fromArray(SPECIES, a, i);1490FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1491av.add(bv, vmask).intoArray(r, i);1492}14931494assertArraysEquals(r, a, b, mask, Float128VectorTests::add);1495}1496static float SUB(float a, float b) {1497return (float)(a - b);1498}14991500@Test(dataProvider = "floatBinaryOpProvider")1501static void SUBFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {1502float[] a = fa.apply(SPECIES.length());1503float[] b = fb.apply(SPECIES.length());1504float[] r = fr.apply(SPECIES.length());15051506for (int ic = 0; ic < INVOC_COUNT; ic++) {1507for (int i = 0; i < a.length; i += SPECIES.length()) {1508FloatVector av = FloatVector.fromArray(SPECIES, a, i);1509FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1510av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);1511}1512}15131514assertArraysEquals(r, a, b, Float128VectorTests::SUB);1515}1516static float sub(float a, float b) {1517return (float)(a - b);1518}15191520@Test(dataProvider = "floatBinaryOpProvider")1521static void subFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {1522float[] a = fa.apply(SPECIES.length());1523float[] b = fb.apply(SPECIES.length());1524float[] r = fr.apply(SPECIES.length());15251526for (int i = 0; i < a.length; i += SPECIES.length()) {1527FloatVector av = FloatVector.fromArray(SPECIES, a, i);1528FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1529av.sub(bv).intoArray(r, i);1530}15311532assertArraysEquals(r, a, b, Float128VectorTests::sub);1533}15341535@Test(dataProvider = "floatBinaryOpMaskProvider")1536static void SUBFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,1537IntFunction<boolean[]> fm) {1538float[] a = fa.apply(SPECIES.length());1539float[] b = fb.apply(SPECIES.length());1540float[] r = fr.apply(SPECIES.length());1541boolean[] mask = fm.apply(SPECIES.length());1542VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);15431544for (int ic = 0; ic < INVOC_COUNT; ic++) {1545for (int i = 0; i < a.length; i += SPECIES.length()) {1546FloatVector av = FloatVector.fromArray(SPECIES, a, i);1547FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1548av.lanewise(VectorOperators.SUB, bv, vmask).intoArray(r, i);1549}1550}15511552assertArraysEquals(r, a, b, mask, Float128VectorTests::SUB);1553}15541555@Test(dataProvider = "floatBinaryOpMaskProvider")1556static void subFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,1557IntFunction<boolean[]> fm) {1558float[] a = fa.apply(SPECIES.length());1559float[] b = fb.apply(SPECIES.length());1560float[] r = fr.apply(SPECIES.length());1561boolean[] mask = fm.apply(SPECIES.length());1562VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);15631564for (int i = 0; i < a.length; i += SPECIES.length()) {1565FloatVector av = FloatVector.fromArray(SPECIES, a, i);1566FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1567av.sub(bv, vmask).intoArray(r, i);1568}15691570assertArraysEquals(r, a, b, mask, Float128VectorTests::sub);1571}1572static float MUL(float a, float b) {1573return (float)(a * b);1574}15751576@Test(dataProvider = "floatBinaryOpProvider")1577static void MULFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {1578float[] a = fa.apply(SPECIES.length());1579float[] b = fb.apply(SPECIES.length());1580float[] r = fr.apply(SPECIES.length());15811582for (int ic = 0; ic < INVOC_COUNT; ic++) {1583for (int i = 0; i < a.length; i += SPECIES.length()) {1584FloatVector av = FloatVector.fromArray(SPECIES, a, i);1585FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1586av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);1587}1588}15891590assertArraysEquals(r, a, b, Float128VectorTests::MUL);1591}1592static float mul(float a, float b) {1593return (float)(a * b);1594}15951596@Test(dataProvider = "floatBinaryOpProvider")1597static void mulFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {1598float[] a = fa.apply(SPECIES.length());1599float[] b = fb.apply(SPECIES.length());1600float[] r = fr.apply(SPECIES.length());16011602for (int i = 0; i < a.length; i += SPECIES.length()) {1603FloatVector av = FloatVector.fromArray(SPECIES, a, i);1604FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1605av.mul(bv).intoArray(r, i);1606}16071608assertArraysEquals(r, a, b, Float128VectorTests::mul);1609}16101611@Test(dataProvider = "floatBinaryOpMaskProvider")1612static void MULFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,1613IntFunction<boolean[]> fm) {1614float[] a = fa.apply(SPECIES.length());1615float[] b = fb.apply(SPECIES.length());1616float[] r = fr.apply(SPECIES.length());1617boolean[] mask = fm.apply(SPECIES.length());1618VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);16191620for (int ic = 0; ic < INVOC_COUNT; ic++) {1621for (int i = 0; i < a.length; i += SPECIES.length()) {1622FloatVector av = FloatVector.fromArray(SPECIES, a, i);1623FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1624av.lanewise(VectorOperators.MUL, bv, vmask).intoArray(r, i);1625}1626}16271628assertArraysEquals(r, a, b, mask, Float128VectorTests::MUL);1629}16301631@Test(dataProvider = "floatBinaryOpMaskProvider")1632static void mulFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,1633IntFunction<boolean[]> fm) {1634float[] a = fa.apply(SPECIES.length());1635float[] b = fb.apply(SPECIES.length());1636float[] r = fr.apply(SPECIES.length());1637boolean[] mask = fm.apply(SPECIES.length());1638VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);16391640for (int i = 0; i < a.length; i += SPECIES.length()) {1641FloatVector av = FloatVector.fromArray(SPECIES, a, i);1642FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1643av.mul(bv, vmask).intoArray(r, i);1644}16451646assertArraysEquals(r, a, b, mask, Float128VectorTests::mul);1647}16481649static float DIV(float a, float b) {1650return (float)(a / b);1651}16521653@Test(dataProvider = "floatBinaryOpProvider")1654static void DIVFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {1655float[] a = fa.apply(SPECIES.length());1656float[] b = fb.apply(SPECIES.length());1657float[] r = fr.apply(SPECIES.length());16581659for (int ic = 0; ic < INVOC_COUNT; ic++) {1660for (int i = 0; i < a.length; i += SPECIES.length()) {1661FloatVector av = FloatVector.fromArray(SPECIES, a, i);1662FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1663av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);1664}1665}16661667assertArraysEquals(r, a, b, Float128VectorTests::DIV);1668}1669static float div(float a, float b) {1670return (float)(a / b);1671}16721673@Test(dataProvider = "floatBinaryOpProvider")1674static void divFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {1675float[] a = fa.apply(SPECIES.length());1676float[] b = fb.apply(SPECIES.length());1677float[] r = fr.apply(SPECIES.length());16781679for (int i = 0; i < a.length; i += SPECIES.length()) {1680FloatVector av = FloatVector.fromArray(SPECIES, a, i);1681FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1682av.div(bv).intoArray(r, i);1683}16841685assertArraysEquals(r, a, b, Float128VectorTests::div);1686}1687168816891690@Test(dataProvider = "floatBinaryOpMaskProvider")1691static void DIVFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,1692IntFunction<boolean[]> fm) {1693float[] a = fa.apply(SPECIES.length());1694float[] b = fb.apply(SPECIES.length());1695float[] r = fr.apply(SPECIES.length());1696boolean[] mask = fm.apply(SPECIES.length());1697VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);16981699for (int ic = 0; ic < INVOC_COUNT; ic++) {1700for (int i = 0; i < a.length; i += SPECIES.length()) {1701FloatVector av = FloatVector.fromArray(SPECIES, a, i);1702FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1703av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);1704}1705}17061707assertArraysEquals(r, a, b, mask, Float128VectorTests::DIV);1708}17091710@Test(dataProvider = "floatBinaryOpMaskProvider")1711static void divFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,1712IntFunction<boolean[]> fm) {1713float[] a = fa.apply(SPECIES.length());1714float[] b = fb.apply(SPECIES.length());1715float[] r = fr.apply(SPECIES.length());1716boolean[] mask = fm.apply(SPECIES.length());1717VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);17181719for (int i = 0; i < a.length; i += SPECIES.length()) {1720FloatVector av = FloatVector.fromArray(SPECIES, a, i);1721FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1722av.div(bv, vmask).intoArray(r, i);1723}17241725assertArraysEquals(r, a, b, mask, Float128VectorTests::div);1726}1727172817291730static float FIRST_NONZERO(float a, float b) {1731return (float)(Double.doubleToLongBits(a)!=0?a:b);1732}17331734@Test(dataProvider = "floatBinaryOpProvider")1735static void FIRST_NONZEROFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {1736float[] a = fa.apply(SPECIES.length());1737float[] b = fb.apply(SPECIES.length());1738float[] r = fr.apply(SPECIES.length());17391740for (int ic = 0; ic < INVOC_COUNT; ic++) {1741for (int i = 0; i < a.length; i += SPECIES.length()) {1742FloatVector av = FloatVector.fromArray(SPECIES, a, i);1743FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1744av.lanewise(VectorOperators.FIRST_NONZERO, bv).intoArray(r, i);1745}1746}17471748assertArraysEquals(r, a, b, Float128VectorTests::FIRST_NONZERO);1749}17501751@Test(dataProvider = "floatBinaryOpMaskProvider")1752static void FIRST_NONZEROFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,1753IntFunction<boolean[]> fm) {1754float[] a = fa.apply(SPECIES.length());1755float[] b = fb.apply(SPECIES.length());1756float[] r = fr.apply(SPECIES.length());1757boolean[] mask = fm.apply(SPECIES.length());1758VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);17591760for (int ic = 0; ic < INVOC_COUNT; ic++) {1761for (int i = 0; i < a.length; i += SPECIES.length()) {1762FloatVector av = FloatVector.fromArray(SPECIES, a, i);1763FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1764av.lanewise(VectorOperators.FIRST_NONZERO, bv, vmask).intoArray(r, i);1765}1766}17671768assertArraysEquals(r, a, b, mask, Float128VectorTests::FIRST_NONZERO);1769}1770177117721773177417751776177717781779@Test(dataProvider = "floatBinaryOpProvider")1780static void addFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {1781float[] a = fa.apply(SPECIES.length());1782float[] b = fb.apply(SPECIES.length());1783float[] r = fr.apply(SPECIES.length());17841785for (int i = 0; i < a.length; i += SPECIES.length()) {1786FloatVector av = FloatVector.fromArray(SPECIES, a, i);1787av.add(b[i]).intoArray(r, i);1788}17891790assertBroadcastArraysEquals(r, a, b, Float128VectorTests::add);1791}17921793@Test(dataProvider = "floatBinaryOpMaskProvider")1794static void addFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb,1795IntFunction<boolean[]> fm) {1796float[] a = fa.apply(SPECIES.length());1797float[] b = fb.apply(SPECIES.length());1798float[] r = fr.apply(SPECIES.length());1799boolean[] mask = fm.apply(SPECIES.length());1800VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);18011802for (int i = 0; i < a.length; i += SPECIES.length()) {1803FloatVector av = FloatVector.fromArray(SPECIES, a, i);1804av.add(b[i], vmask).intoArray(r, i);1805}18061807assertBroadcastArraysEquals(r, a, b, mask, Float128VectorTests::add);1808}18091810@Test(dataProvider = "floatBinaryOpProvider")1811static void subFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {1812float[] a = fa.apply(SPECIES.length());1813float[] b = fb.apply(SPECIES.length());1814float[] r = fr.apply(SPECIES.length());18151816for (int i = 0; i < a.length; i += SPECIES.length()) {1817FloatVector av = FloatVector.fromArray(SPECIES, a, i);1818av.sub(b[i]).intoArray(r, i);1819}18201821assertBroadcastArraysEquals(r, a, b, Float128VectorTests::sub);1822}18231824@Test(dataProvider = "floatBinaryOpMaskProvider")1825static void subFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb,1826IntFunction<boolean[]> fm) {1827float[] a = fa.apply(SPECIES.length());1828float[] b = fb.apply(SPECIES.length());1829float[] r = fr.apply(SPECIES.length());1830boolean[] mask = fm.apply(SPECIES.length());1831VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);18321833for (int i = 0; i < a.length; i += SPECIES.length()) {1834FloatVector av = FloatVector.fromArray(SPECIES, a, i);1835av.sub(b[i], vmask).intoArray(r, i);1836}18371838assertBroadcastArraysEquals(r, a, b, mask, Float128VectorTests::sub);1839}18401841@Test(dataProvider = "floatBinaryOpProvider")1842static void mulFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {1843float[] a = fa.apply(SPECIES.length());1844float[] b = fb.apply(SPECIES.length());1845float[] r = fr.apply(SPECIES.length());18461847for (int i = 0; i < a.length; i += SPECIES.length()) {1848FloatVector av = FloatVector.fromArray(SPECIES, a, i);1849av.mul(b[i]).intoArray(r, i);1850}18511852assertBroadcastArraysEquals(r, a, b, Float128VectorTests::mul);1853}18541855@Test(dataProvider = "floatBinaryOpMaskProvider")1856static void mulFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb,1857IntFunction<boolean[]> fm) {1858float[] a = fa.apply(SPECIES.length());1859float[] b = fb.apply(SPECIES.length());1860float[] r = fr.apply(SPECIES.length());1861boolean[] mask = fm.apply(SPECIES.length());1862VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);18631864for (int i = 0; i < a.length; i += SPECIES.length()) {1865FloatVector av = FloatVector.fromArray(SPECIES, a, i);1866av.mul(b[i], vmask).intoArray(r, i);1867}18681869assertBroadcastArraysEquals(r, a, b, mask, Float128VectorTests::mul);1870}187118721873@Test(dataProvider = "floatBinaryOpProvider")1874static void divFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {1875float[] a = fa.apply(SPECIES.length());1876float[] b = fb.apply(SPECIES.length());1877float[] r = fr.apply(SPECIES.length());18781879for (int i = 0; i < a.length; i += SPECIES.length()) {1880FloatVector av = FloatVector.fromArray(SPECIES, a, i);1881av.div(b[i]).intoArray(r, i);1882}18831884assertBroadcastArraysEquals(r, a, b, Float128VectorTests::div);1885}1886188718881889@Test(dataProvider = "floatBinaryOpMaskProvider")1890static void divFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb,1891IntFunction<boolean[]> fm) {1892float[] a = fa.apply(SPECIES.length());1893float[] b = fb.apply(SPECIES.length());1894float[] r = fr.apply(SPECIES.length());1895boolean[] mask = fm.apply(SPECIES.length());1896VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);18971898for (int i = 0; i < a.length; i += SPECIES.length()) {1899FloatVector av = FloatVector.fromArray(SPECIES, a, i);1900av.div(b[i], vmask).intoArray(r, i);1901}19021903assertBroadcastArraysEquals(r, a, b, mask, Float128VectorTests::div);1904}19051906190719081909191019111912191319141915@Test(dataProvider = "floatBinaryOpProvider")1916static void ADDFloat128VectorTestsBroadcastLongSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {1917float[] a = fa.apply(SPECIES.length());1918float[] b = fb.apply(SPECIES.length());1919float[] r = fr.apply(SPECIES.length());19201921for (int i = 0; i < a.length; i += SPECIES.length()) {1922FloatVector av = FloatVector.fromArray(SPECIES, a, i);1923av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);1924}19251926assertBroadcastLongArraysEquals(r, a, b, Float128VectorTests::ADD);1927}19281929@Test(dataProvider = "floatBinaryOpMaskProvider")1930static void ADDFloat128VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb,1931IntFunction<boolean[]> fm) {1932float[] a = fa.apply(SPECIES.length());1933float[] b = fb.apply(SPECIES.length());1934float[] r = fr.apply(SPECIES.length());1935boolean[] mask = fm.apply(SPECIES.length());1936VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);19371938for (int i = 0; i < a.length; i += SPECIES.length()) {1939FloatVector av = FloatVector.fromArray(SPECIES, a, i);1940av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);1941}19421943assertBroadcastLongArraysEquals(r, a, b, mask, Float128VectorTests::ADD);1944}1945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981static float MIN(float a, float b) {1982return (float)(Math.min(a, b));1983}19841985@Test(dataProvider = "floatBinaryOpProvider")1986static void MINFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {1987float[] a = fa.apply(SPECIES.length());1988float[] b = fb.apply(SPECIES.length());1989float[] r = fr.apply(SPECIES.length());19901991for (int ic = 0; ic < INVOC_COUNT; ic++) {1992for (int i = 0; i < a.length; i += SPECIES.length()) {1993FloatVector av = FloatVector.fromArray(SPECIES, a, i);1994FloatVector bv = FloatVector.fromArray(SPECIES, b, i);1995av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);1996}1997}19981999assertArraysEquals(r, a, b, Float128VectorTests::MIN);2000}2001static float min(float a, float b) {2002return (float)(Math.min(a, b));2003}20042005@Test(dataProvider = "floatBinaryOpProvider")2006static void minFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {2007float[] a = fa.apply(SPECIES.length());2008float[] b = fb.apply(SPECIES.length());2009float[] r = fr.apply(SPECIES.length());20102011for (int i = 0; i < a.length; i += SPECIES.length()) {2012FloatVector av = FloatVector.fromArray(SPECIES, a, i);2013FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2014av.min(bv).intoArray(r, i);2015}20162017assertArraysEquals(r, a, b, Float128VectorTests::min);2018}2019static float MAX(float a, float b) {2020return (float)(Math.max(a, b));2021}20222023@Test(dataProvider = "floatBinaryOpProvider")2024static void MAXFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {2025float[] a = fa.apply(SPECIES.length());2026float[] b = fb.apply(SPECIES.length());2027float[] r = fr.apply(SPECIES.length());20282029for (int ic = 0; ic < INVOC_COUNT; ic++) {2030for (int i = 0; i < a.length; i += SPECIES.length()) {2031FloatVector av = FloatVector.fromArray(SPECIES, a, i);2032FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2033av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);2034}2035}20362037assertArraysEquals(r, a, b, Float128VectorTests::MAX);2038}2039static float max(float a, float b) {2040return (float)(Math.max(a, b));2041}20422043@Test(dataProvider = "floatBinaryOpProvider")2044static void maxFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {2045float[] a = fa.apply(SPECIES.length());2046float[] b = fb.apply(SPECIES.length());2047float[] r = fr.apply(SPECIES.length());20482049for (int i = 0; i < a.length; i += SPECIES.length()) {2050FloatVector av = FloatVector.fromArray(SPECIES, a, i);2051FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2052av.max(bv).intoArray(r, i);2053}20542055assertArraysEquals(r, a, b, Float128VectorTests::max);2056}20572058@Test(dataProvider = "floatBinaryOpProvider")2059static void MINFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {2060float[] a = fa.apply(SPECIES.length());2061float[] b = fb.apply(SPECIES.length());2062float[] r = fr.apply(SPECIES.length());20632064for (int i = 0; i < a.length; i += SPECIES.length()) {2065FloatVector av = FloatVector.fromArray(SPECIES, a, i);2066av.lanewise(VectorOperators.MIN, b[i]).intoArray(r, i);2067}20682069assertBroadcastArraysEquals(r, a, b, Float128VectorTests::MIN);2070}20712072@Test(dataProvider = "floatBinaryOpProvider")2073static void minFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {2074float[] a = fa.apply(SPECIES.length());2075float[] b = fb.apply(SPECIES.length());2076float[] r = fr.apply(SPECIES.length());20772078for (int i = 0; i < a.length; i += SPECIES.length()) {2079FloatVector av = FloatVector.fromArray(SPECIES, a, i);2080av.min(b[i]).intoArray(r, i);2081}20822083assertBroadcastArraysEquals(r, a, b, Float128VectorTests::min);2084}20852086@Test(dataProvider = "floatBinaryOpProvider")2087static void MAXFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {2088float[] a = fa.apply(SPECIES.length());2089float[] b = fb.apply(SPECIES.length());2090float[] r = fr.apply(SPECIES.length());20912092for (int i = 0; i < a.length; i += SPECIES.length()) {2093FloatVector av = FloatVector.fromArray(SPECIES, a, i);2094av.lanewise(VectorOperators.MAX, b[i]).intoArray(r, i);2095}20962097assertBroadcastArraysEquals(r, a, b, Float128VectorTests::MAX);2098}20992100@Test(dataProvider = "floatBinaryOpProvider")2101static void maxFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {2102float[] a = fa.apply(SPECIES.length());2103float[] b = fb.apply(SPECIES.length());2104float[] r = fr.apply(SPECIES.length());21052106for (int i = 0; i < a.length; i += SPECIES.length()) {2107FloatVector av = FloatVector.fromArray(SPECIES, a, i);2108av.max(b[i]).intoArray(r, i);2109}21102111assertBroadcastArraysEquals(r, a, b, Float128VectorTests::max);2112}2113211421152116211721182119212021212122212321242125static float ADDReduce(float[] a, int idx) {2126float res = 0;2127for (int i = idx; i < (idx + SPECIES.length()); i++) {2128res += a[i];2129}21302131return res;2132}21332134static float ADDReduceAll(float[] a) {2135float res = 0;2136for (int i = 0; i < a.length; i += SPECIES.length()) {2137res += ADDReduce(a, i);2138}21392140return res;2141}2142@Test(dataProvider = "floatUnaryOpProvider")2143static void ADDReduceFloat128VectorTests(IntFunction<float[]> fa) {2144float[] a = fa.apply(SPECIES.length());2145float[] r = fr.apply(SPECIES.length());2146float ra = 0;21472148for (int ic = 0; ic < INVOC_COUNT; ic++) {2149for (int i = 0; i < a.length; i += SPECIES.length()) {2150FloatVector av = FloatVector.fromArray(SPECIES, a, i);2151r[i] = av.reduceLanes(VectorOperators.ADD);2152}2153}21542155for (int ic = 0; ic < INVOC_COUNT; ic++) {2156ra = 0;2157for (int i = 0; i < a.length; i += SPECIES.length()) {2158FloatVector av = FloatVector.fromArray(SPECIES, a, i);2159ra += av.reduceLanes(VectorOperators.ADD);2160}2161}21622163assertReductionArraysEquals(r, ra, a,2164Float128VectorTests::ADDReduce, Float128VectorTests::ADDReduceAll);2165}2166static float ADDReduceMasked(float[] a, int idx, boolean[] mask) {2167float res = 0;2168for (int i = idx; i < (idx + SPECIES.length()); i++) {2169if (mask[i % SPECIES.length()])2170res += a[i];2171}21722173return res;2174}21752176static float ADDReduceAllMasked(float[] a, boolean[] mask) {2177float res = 0;2178for (int i = 0; i < a.length; i += SPECIES.length()) {2179res += ADDReduceMasked(a, i, mask);2180}21812182return res;2183}2184@Test(dataProvider = "floatUnaryOpMaskProvider")2185static void ADDReduceFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<boolean[]> fm) {2186float[] a = fa.apply(SPECIES.length());2187float[] r = fr.apply(SPECIES.length());2188boolean[] mask = fm.apply(SPECIES.length());2189VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);2190float ra = 0;21912192for (int ic = 0; ic < INVOC_COUNT; ic++) {2193for (int i = 0; i < a.length; i += SPECIES.length()) {2194FloatVector av = FloatVector.fromArray(SPECIES, a, i);2195r[i] = av.reduceLanes(VectorOperators.ADD, vmask);2196}2197}21982199for (int ic = 0; ic < INVOC_COUNT; ic++) {2200ra = 0;2201for (int i = 0; i < a.length; i += SPECIES.length()) {2202FloatVector av = FloatVector.fromArray(SPECIES, a, i);2203ra += av.reduceLanes(VectorOperators.ADD, vmask);2204}2205}22062207assertReductionArraysEqualsMasked(r, ra, a, mask,2208Float128VectorTests::ADDReduceMasked, Float128VectorTests::ADDReduceAllMasked);2209}2210static float MULReduce(float[] a, int idx) {2211float res = 1;2212for (int i = idx; i < (idx + SPECIES.length()); i++) {2213res *= a[i];2214}22152216return res;2217}22182219static float MULReduceAll(float[] a) {2220float res = 1;2221for (int i = 0; i < a.length; i += SPECIES.length()) {2222res *= MULReduce(a, i);2223}22242225return res;2226}2227@Test(dataProvider = "floatUnaryOpProvider")2228static void MULReduceFloat128VectorTests(IntFunction<float[]> fa) {2229float[] a = fa.apply(SPECIES.length());2230float[] r = fr.apply(SPECIES.length());2231float ra = 1;22322233for (int ic = 0; ic < INVOC_COUNT; ic++) {2234for (int i = 0; i < a.length; i += SPECIES.length()) {2235FloatVector av = FloatVector.fromArray(SPECIES, a, i);2236r[i] = av.reduceLanes(VectorOperators.MUL);2237}2238}22392240for (int ic = 0; ic < INVOC_COUNT; ic++) {2241ra = 1;2242for (int i = 0; i < a.length; i += SPECIES.length()) {2243FloatVector av = FloatVector.fromArray(SPECIES, a, i);2244ra *= av.reduceLanes(VectorOperators.MUL);2245}2246}22472248assertReductionArraysEquals(r, ra, a,2249Float128VectorTests::MULReduce, Float128VectorTests::MULReduceAll);2250}2251static float MULReduceMasked(float[] a, int idx, boolean[] mask) {2252float res = 1;2253for (int i = idx; i < (idx + SPECIES.length()); i++) {2254if (mask[i % SPECIES.length()])2255res *= a[i];2256}22572258return res;2259}22602261static float MULReduceAllMasked(float[] a, boolean[] mask) {2262float res = 1;2263for (int i = 0; i < a.length; i += SPECIES.length()) {2264res *= MULReduceMasked(a, i, mask);2265}22662267return res;2268}2269@Test(dataProvider = "floatUnaryOpMaskProvider")2270static void MULReduceFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<boolean[]> fm) {2271float[] a = fa.apply(SPECIES.length());2272float[] r = fr.apply(SPECIES.length());2273boolean[] mask = fm.apply(SPECIES.length());2274VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);2275float ra = 1;22762277for (int ic = 0; ic < INVOC_COUNT; ic++) {2278for (int i = 0; i < a.length; i += SPECIES.length()) {2279FloatVector av = FloatVector.fromArray(SPECIES, a, i);2280r[i] = av.reduceLanes(VectorOperators.MUL, vmask);2281}2282}22832284for (int ic = 0; ic < INVOC_COUNT; ic++) {2285ra = 1;2286for (int i = 0; i < a.length; i += SPECIES.length()) {2287FloatVector av = FloatVector.fromArray(SPECIES, a, i);2288ra *= av.reduceLanes(VectorOperators.MUL, vmask);2289}2290}22912292assertReductionArraysEqualsMasked(r, ra, a, mask,2293Float128VectorTests::MULReduceMasked, Float128VectorTests::MULReduceAllMasked);2294}2295static float MINReduce(float[] a, int idx) {2296float res = Float.POSITIVE_INFINITY;2297for (int i = idx; i < (idx + SPECIES.length()); i++) {2298res = (float)Math.min(res, a[i]);2299}23002301return res;2302}23032304static float MINReduceAll(float[] a) {2305float res = Float.POSITIVE_INFINITY;2306for (int i = 0; i < a.length; i++) {2307res = (float)Math.min(res, a[i]);2308}23092310return res;2311}2312@Test(dataProvider = "floatUnaryOpProvider")2313static void MINReduceFloat128VectorTests(IntFunction<float[]> fa) {2314float[] a = fa.apply(SPECIES.length());2315float[] r = fr.apply(SPECIES.length());2316float ra = Float.POSITIVE_INFINITY;23172318for (int ic = 0; ic < INVOC_COUNT; ic++) {2319for (int i = 0; i < a.length; i += SPECIES.length()) {2320FloatVector av = FloatVector.fromArray(SPECIES, a, i);2321r[i] = av.reduceLanes(VectorOperators.MIN);2322}2323}23242325for (int ic = 0; ic < INVOC_COUNT; ic++) {2326ra = Float.POSITIVE_INFINITY;2327for (int i = 0; i < a.length; i += SPECIES.length()) {2328FloatVector av = FloatVector.fromArray(SPECIES, a, i);2329ra = (float)Math.min(ra, av.reduceLanes(VectorOperators.MIN));2330}2331}23322333assertReductionArraysEquals(r, ra, a,2334Float128VectorTests::MINReduce, Float128VectorTests::MINReduceAll);2335}2336static float MINReduceMasked(float[] a, int idx, boolean[] mask) {2337float res = Float.POSITIVE_INFINITY;2338for (int i = idx; i < (idx + SPECIES.length()); i++) {2339if(mask[i % SPECIES.length()])2340res = (float)Math.min(res, a[i]);2341}23422343return res;2344}23452346static float MINReduceAllMasked(float[] a, boolean[] mask) {2347float res = Float.POSITIVE_INFINITY;2348for (int i = 0; i < a.length; i++) {2349if(mask[i % SPECIES.length()])2350res = (float)Math.min(res, a[i]);2351}23522353return res;2354}2355@Test(dataProvider = "floatUnaryOpMaskProvider")2356static void MINReduceFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<boolean[]> fm) {2357float[] a = fa.apply(SPECIES.length());2358float[] r = fr.apply(SPECIES.length());2359boolean[] mask = fm.apply(SPECIES.length());2360VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);2361float ra = Float.POSITIVE_INFINITY;23622363for (int ic = 0; ic < INVOC_COUNT; ic++) {2364for (int i = 0; i < a.length; i += SPECIES.length()) {2365FloatVector av = FloatVector.fromArray(SPECIES, a, i);2366r[i] = av.reduceLanes(VectorOperators.MIN, vmask);2367}2368}23692370for (int ic = 0; ic < INVOC_COUNT; ic++) {2371ra = Float.POSITIVE_INFINITY;2372for (int i = 0; i < a.length; i += SPECIES.length()) {2373FloatVector av = FloatVector.fromArray(SPECIES, a, i);2374ra = (float)Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));2375}2376}23772378assertReductionArraysEqualsMasked(r, ra, a, mask,2379Float128VectorTests::MINReduceMasked, Float128VectorTests::MINReduceAllMasked);2380}2381static float MAXReduce(float[] a, int idx) {2382float res = Float.NEGATIVE_INFINITY;2383for (int i = idx; i < (idx + SPECIES.length()); i++) {2384res = (float)Math.max(res, a[i]);2385}23862387return res;2388}23892390static float MAXReduceAll(float[] a) {2391float res = Float.NEGATIVE_INFINITY;2392for (int i = 0; i < a.length; i++) {2393res = (float)Math.max(res, a[i]);2394}23952396return res;2397}2398@Test(dataProvider = "floatUnaryOpProvider")2399static void MAXReduceFloat128VectorTests(IntFunction<float[]> fa) {2400float[] a = fa.apply(SPECIES.length());2401float[] r = fr.apply(SPECIES.length());2402float ra = Float.NEGATIVE_INFINITY;24032404for (int ic = 0; ic < INVOC_COUNT; ic++) {2405for (int i = 0; i < a.length; i += SPECIES.length()) {2406FloatVector av = FloatVector.fromArray(SPECIES, a, i);2407r[i] = av.reduceLanes(VectorOperators.MAX);2408}2409}24102411for (int ic = 0; ic < INVOC_COUNT; ic++) {2412ra = Float.NEGATIVE_INFINITY;2413for (int i = 0; i < a.length; i += SPECIES.length()) {2414FloatVector av = FloatVector.fromArray(SPECIES, a, i);2415ra = (float)Math.max(ra, av.reduceLanes(VectorOperators.MAX));2416}2417}24182419assertReductionArraysEquals(r, ra, a,2420Float128VectorTests::MAXReduce, Float128VectorTests::MAXReduceAll);2421}2422static float MAXReduceMasked(float[] a, int idx, boolean[] mask) {2423float res = Float.NEGATIVE_INFINITY;2424for (int i = idx; i < (idx + SPECIES.length()); i++) {2425if(mask[i % SPECIES.length()])2426res = (float)Math.max(res, a[i]);2427}24282429return res;2430}24312432static float MAXReduceAllMasked(float[] a, boolean[] mask) {2433float res = Float.NEGATIVE_INFINITY;2434for (int i = 0; i < a.length; i++) {2435if(mask[i % SPECIES.length()])2436res = (float)Math.max(res, a[i]);2437}24382439return res;2440}2441@Test(dataProvider = "floatUnaryOpMaskProvider")2442static void MAXReduceFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<boolean[]> fm) {2443float[] a = fa.apply(SPECIES.length());2444float[] r = fr.apply(SPECIES.length());2445boolean[] mask = fm.apply(SPECIES.length());2446VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);2447float ra = Float.NEGATIVE_INFINITY;24482449for (int ic = 0; ic < INVOC_COUNT; ic++) {2450for (int i = 0; i < a.length; i += SPECIES.length()) {2451FloatVector av = FloatVector.fromArray(SPECIES, a, i);2452r[i] = av.reduceLanes(VectorOperators.MAX, vmask);2453}2454}24552456for (int ic = 0; ic < INVOC_COUNT; ic++) {2457ra = Float.NEGATIVE_INFINITY;2458for (int i = 0; i < a.length; i += SPECIES.length()) {2459FloatVector av = FloatVector.fromArray(SPECIES, a, i);2460ra = (float)Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));2461}2462}24632464assertReductionArraysEqualsMasked(r, ra, a, mask,2465Float128VectorTests::MAXReduceMasked, Float128VectorTests::MAXReduceAllMasked);2466}246724682469247024712472@Test(dataProvider = "floatUnaryOpProvider")2473static void withFloat128VectorTests(IntFunction<float []> fa) {2474float[] a = fa.apply(SPECIES.length());2475float[] r = fr.apply(SPECIES.length());24762477for (int ic = 0; ic < INVOC_COUNT; ic++) {2478for (int i = 0; i < a.length; i += SPECIES.length()) {2479FloatVector av = FloatVector.fromArray(SPECIES, a, i);2480av.withLane(0, (float)4).intoArray(r, i);2481}2482}24832484assertInsertArraysEquals(r, a, (float)4, 0);2485}2486static boolean testIS_DEFAULT(float a) {2487return bits(a)==0;2488}24892490@Test(dataProvider = "floatTestOpProvider")2491static void IS_DEFAULTFloat128VectorTests(IntFunction<float[]> fa) {2492float[] a = fa.apply(SPECIES.length());24932494for (int ic = 0; ic < INVOC_COUNT; ic++) {2495for (int i = 0; i < a.length; i += SPECIES.length()) {2496FloatVector av = FloatVector.fromArray(SPECIES, a, i);2497VectorMask<Float> mv = av.test(VectorOperators.IS_DEFAULT);24982499// Check results as part of computation.2500for (int j = 0; j < SPECIES.length(); j++) {2501Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));2502}2503}2504}2505}25062507@Test(dataProvider = "floatTestOpMaskProvider")2508static void IS_DEFAULTMaskedFloat128VectorTestsSmokeTest(IntFunction<float[]> fa,2509IntFunction<boolean[]> fm) {2510float[] a = fa.apply(SPECIES.length());2511boolean[] mask = fm.apply(SPECIES.length());2512VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);25132514for (int i = 0; i < a.length; i += SPECIES.length()) {2515FloatVector av = FloatVector.fromArray(SPECIES, a, i);2516VectorMask<Float> mv = av.test(VectorOperators.IS_DEFAULT, vmask);25172518// Check results as part of computation.2519for (int j = 0; j < SPECIES.length(); j++) {2520Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));2521}2522}2523}2524static boolean testIS_NEGATIVE(float a) {2525return bits(a)<0;2526}25272528@Test(dataProvider = "floatTestOpProvider")2529static void IS_NEGATIVEFloat128VectorTests(IntFunction<float[]> fa) {2530float[] a = fa.apply(SPECIES.length());25312532for (int ic = 0; ic < INVOC_COUNT; ic++) {2533for (int i = 0; i < a.length; i += SPECIES.length()) {2534FloatVector av = FloatVector.fromArray(SPECIES, a, i);2535VectorMask<Float> mv = av.test(VectorOperators.IS_NEGATIVE);25362537// Check results as part of computation.2538for (int j = 0; j < SPECIES.length(); j++) {2539Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));2540}2541}2542}2543}25442545@Test(dataProvider = "floatTestOpMaskProvider")2546static void IS_NEGATIVEMaskedFloat128VectorTestsSmokeTest(IntFunction<float[]> fa,2547IntFunction<boolean[]> fm) {2548float[] a = fa.apply(SPECIES.length());2549boolean[] mask = fm.apply(SPECIES.length());2550VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);25512552for (int i = 0; i < a.length; i += SPECIES.length()) {2553FloatVector av = FloatVector.fromArray(SPECIES, a, i);2554VectorMask<Float> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);25552556// Check results as part of computation.2557for (int j = 0; j < SPECIES.length(); j++) {2558Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));2559}2560}2561}25622563static boolean testIS_FINITE(float a) {2564return Float.isFinite(a);2565}25662567@Test(dataProvider = "floatTestOpProvider")2568static void IS_FINITEFloat128VectorTests(IntFunction<float[]> fa) {2569float[] a = fa.apply(SPECIES.length());25702571for (int ic = 0; ic < INVOC_COUNT; ic++) {2572for (int i = 0; i < a.length; i += SPECIES.length()) {2573FloatVector av = FloatVector.fromArray(SPECIES, a, i);2574VectorMask<Float> mv = av.test(VectorOperators.IS_FINITE);25752576// Check results as part of computation.2577for (int j = 0; j < SPECIES.length(); j++) {2578Assert.assertEquals(mv.laneIsSet(j), testIS_FINITE(a[i + j]));2579}2580}2581}2582}25832584@Test(dataProvider = "floatTestOpMaskProvider")2585static void IS_FINITEMaskedFloat128VectorTestsSmokeTest(IntFunction<float[]> fa,2586IntFunction<boolean[]> fm) {2587float[] a = fa.apply(SPECIES.length());2588boolean[] mask = fm.apply(SPECIES.length());2589VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);25902591for (int i = 0; i < a.length; i += SPECIES.length()) {2592FloatVector av = FloatVector.fromArray(SPECIES, a, i);2593VectorMask<Float> mv = av.test(VectorOperators.IS_FINITE, vmask);25942595// Check results as part of computation.2596for (int j = 0; j < SPECIES.length(); j++) {2597Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_FINITE(a[i + j]));2598}2599}2600}260126022603static boolean testIS_NAN(float a) {2604return Float.isNaN(a);2605}26062607@Test(dataProvider = "floatTestOpProvider")2608static void IS_NANFloat128VectorTests(IntFunction<float[]> fa) {2609float[] a = fa.apply(SPECIES.length());26102611for (int ic = 0; ic < INVOC_COUNT; ic++) {2612for (int i = 0; i < a.length; i += SPECIES.length()) {2613FloatVector av = FloatVector.fromArray(SPECIES, a, i);2614VectorMask<Float> mv = av.test(VectorOperators.IS_NAN);26152616// Check results as part of computation.2617for (int j = 0; j < SPECIES.length(); j++) {2618Assert.assertEquals(mv.laneIsSet(j), testIS_NAN(a[i + j]));2619}2620}2621}2622}26232624@Test(dataProvider = "floatTestOpMaskProvider")2625static void IS_NANMaskedFloat128VectorTestsSmokeTest(IntFunction<float[]> fa,2626IntFunction<boolean[]> fm) {2627float[] a = fa.apply(SPECIES.length());2628boolean[] mask = fm.apply(SPECIES.length());2629VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);26302631for (int i = 0; i < a.length; i += SPECIES.length()) {2632FloatVector av = FloatVector.fromArray(SPECIES, a, i);2633VectorMask<Float> mv = av.test(VectorOperators.IS_NAN, vmask);26342635// Check results as part of computation.2636for (int j = 0; j < SPECIES.length(); j++) {2637Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NAN(a[i + j]));2638}2639}2640}264126422643static boolean testIS_INFINITE(float a) {2644return Float.isInfinite(a);2645}26462647@Test(dataProvider = "floatTestOpProvider")2648static void IS_INFINITEFloat128VectorTests(IntFunction<float[]> fa) {2649float[] a = fa.apply(SPECIES.length());26502651for (int ic = 0; ic < INVOC_COUNT; ic++) {2652for (int i = 0; i < a.length; i += SPECIES.length()) {2653FloatVector av = FloatVector.fromArray(SPECIES, a, i);2654VectorMask<Float> mv = av.test(VectorOperators.IS_INFINITE);26552656// Check results as part of computation.2657for (int j = 0; j < SPECIES.length(); j++) {2658Assert.assertEquals(mv.laneIsSet(j), testIS_INFINITE(a[i + j]));2659}2660}2661}2662}26632664@Test(dataProvider = "floatTestOpMaskProvider")2665static void IS_INFINITEMaskedFloat128VectorTestsSmokeTest(IntFunction<float[]> fa,2666IntFunction<boolean[]> fm) {2667float[] a = fa.apply(SPECIES.length());2668boolean[] mask = fm.apply(SPECIES.length());2669VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);26702671for (int i = 0; i < a.length; i += SPECIES.length()) {2672FloatVector av = FloatVector.fromArray(SPECIES, a, i);2673VectorMask<Float> mv = av.test(VectorOperators.IS_INFINITE, vmask);26742675// Check results as part of computation.2676for (int j = 0; j < SPECIES.length(); j++) {2677Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_INFINITE(a[i + j]));2678}2679}2680}268126822683@Test(dataProvider = "floatCompareOpProvider")2684static void LTFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {2685float[] a = fa.apply(SPECIES.length());2686float[] b = fb.apply(SPECIES.length());26872688for (int ic = 0; ic < INVOC_COUNT; ic++) {2689for (int i = 0; i < a.length; i += SPECIES.length()) {2690FloatVector av = FloatVector.fromArray(SPECIES, a, i);2691FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2692VectorMask<Float> mv = av.compare(VectorOperators.LT, bv);26932694// Check results as part of computation.2695for (int j = 0; j < SPECIES.length(); j++) {2696Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));2697}2698}2699}2700}270127022703@Test(dataProvider = "floatCompareOpProvider")2704static void ltFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {2705float[] a = fa.apply(SPECIES.length());2706float[] b = fb.apply(SPECIES.length());27072708for (int ic = 0; ic < INVOC_COUNT; ic++) {2709for (int i = 0; i < a.length; i += SPECIES.length()) {2710FloatVector av = FloatVector.fromArray(SPECIES, a, i);2711FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2712VectorMask<Float> mv = av.lt(bv);27132714// Check results as part of computation.2715for (int j = 0; j < SPECIES.length(); j++) {2716Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));2717}2718}2719}2720}27212722@Test(dataProvider = "floatCompareOpMaskProvider")2723static void LTFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,2724IntFunction<boolean[]> fm) {2725float[] a = fa.apply(SPECIES.length());2726float[] b = fb.apply(SPECIES.length());2727boolean[] mask = fm.apply(SPECIES.length());27282729VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);27302731for (int ic = 0; ic < INVOC_COUNT; ic++) {2732for (int i = 0; i < a.length; i += SPECIES.length()) {2733FloatVector av = FloatVector.fromArray(SPECIES, a, i);2734FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2735VectorMask<Float> mv = av.compare(VectorOperators.LT, bv, vmask);27362737// Check results as part of computation.2738for (int j = 0; j < SPECIES.length(); j++) {2739Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));2740}2741}2742}2743}274427452746@Test(dataProvider = "floatCompareOpProvider")2747static void GTFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {2748float[] a = fa.apply(SPECIES.length());2749float[] b = fb.apply(SPECIES.length());27502751for (int ic = 0; ic < INVOC_COUNT; ic++) {2752for (int i = 0; i < a.length; i += SPECIES.length()) {2753FloatVector av = FloatVector.fromArray(SPECIES, a, i);2754FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2755VectorMask<Float> mv = av.compare(VectorOperators.GT, bv);27562757// Check results as part of computation.2758for (int j = 0; j < SPECIES.length(); j++) {2759Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));2760}2761}2762}2763}27642765@Test(dataProvider = "floatCompareOpMaskProvider")2766static void GTFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,2767IntFunction<boolean[]> fm) {2768float[] a = fa.apply(SPECIES.length());2769float[] b = fb.apply(SPECIES.length());2770boolean[] mask = fm.apply(SPECIES.length());27712772VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);27732774for (int ic = 0; ic < INVOC_COUNT; ic++) {2775for (int i = 0; i < a.length; i += SPECIES.length()) {2776FloatVector av = FloatVector.fromArray(SPECIES, a, i);2777FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2778VectorMask<Float> mv = av.compare(VectorOperators.GT, bv, vmask);27792780// Check results as part of computation.2781for (int j = 0; j < SPECIES.length(); j++) {2782Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));2783}2784}2785}2786}278727882789@Test(dataProvider = "floatCompareOpProvider")2790static void EQFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {2791float[] a = fa.apply(SPECIES.length());2792float[] b = fb.apply(SPECIES.length());27932794for (int ic = 0; ic < INVOC_COUNT; ic++) {2795for (int i = 0; i < a.length; i += SPECIES.length()) {2796FloatVector av = FloatVector.fromArray(SPECIES, a, i);2797FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2798VectorMask<Float> mv = av.compare(VectorOperators.EQ, bv);27992800// Check results as part of computation.2801for (int j = 0; j < SPECIES.length(); j++) {2802Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));2803}2804}2805}2806}280728082809@Test(dataProvider = "floatCompareOpProvider")2810static void eqFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {2811float[] a = fa.apply(SPECIES.length());2812float[] b = fb.apply(SPECIES.length());28132814for (int ic = 0; ic < INVOC_COUNT; ic++) {2815for (int i = 0; i < a.length; i += SPECIES.length()) {2816FloatVector av = FloatVector.fromArray(SPECIES, a, i);2817FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2818VectorMask<Float> mv = av.eq(bv);28192820// Check results as part of computation.2821for (int j = 0; j < SPECIES.length(); j++) {2822Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));2823}2824}2825}2826}28272828@Test(dataProvider = "floatCompareOpMaskProvider")2829static void EQFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,2830IntFunction<boolean[]> fm) {2831float[] a = fa.apply(SPECIES.length());2832float[] b = fb.apply(SPECIES.length());2833boolean[] mask = fm.apply(SPECIES.length());28342835VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);28362837for (int ic = 0; ic < INVOC_COUNT; ic++) {2838for (int i = 0; i < a.length; i += SPECIES.length()) {2839FloatVector av = FloatVector.fromArray(SPECIES, a, i);2840FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2841VectorMask<Float> mv = av.compare(VectorOperators.EQ, bv, vmask);28422843// Check results as part of computation.2844for (int j = 0; j < SPECIES.length(); j++) {2845Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));2846}2847}2848}2849}285028512852@Test(dataProvider = "floatCompareOpProvider")2853static void NEFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {2854float[] a = fa.apply(SPECIES.length());2855float[] b = fb.apply(SPECIES.length());28562857for (int ic = 0; ic < INVOC_COUNT; ic++) {2858for (int i = 0; i < a.length; i += SPECIES.length()) {2859FloatVector av = FloatVector.fromArray(SPECIES, a, i);2860FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2861VectorMask<Float> mv = av.compare(VectorOperators.NE, bv);28622863// Check results as part of computation.2864for (int j = 0; j < SPECIES.length(); j++) {2865Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));2866}2867}2868}2869}28702871@Test(dataProvider = "floatCompareOpMaskProvider")2872static void NEFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,2873IntFunction<boolean[]> fm) {2874float[] a = fa.apply(SPECIES.length());2875float[] b = fb.apply(SPECIES.length());2876boolean[] mask = fm.apply(SPECIES.length());28772878VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);28792880for (int ic = 0; ic < INVOC_COUNT; ic++) {2881for (int i = 0; i < a.length; i += SPECIES.length()) {2882FloatVector av = FloatVector.fromArray(SPECIES, a, i);2883FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2884VectorMask<Float> mv = av.compare(VectorOperators.NE, bv, vmask);28852886// Check results as part of computation.2887for (int j = 0; j < SPECIES.length(); j++) {2888Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));2889}2890}2891}2892}289328942895@Test(dataProvider = "floatCompareOpProvider")2896static void LEFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {2897float[] a = fa.apply(SPECIES.length());2898float[] b = fb.apply(SPECIES.length());28992900for (int ic = 0; ic < INVOC_COUNT; ic++) {2901for (int i = 0; i < a.length; i += SPECIES.length()) {2902FloatVector av = FloatVector.fromArray(SPECIES, a, i);2903FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2904VectorMask<Float> mv = av.compare(VectorOperators.LE, bv);29052906// Check results as part of computation.2907for (int j = 0; j < SPECIES.length(); j++) {2908Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));2909}2910}2911}2912}29132914@Test(dataProvider = "floatCompareOpMaskProvider")2915static void LEFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,2916IntFunction<boolean[]> fm) {2917float[] a = fa.apply(SPECIES.length());2918float[] b = fb.apply(SPECIES.length());2919boolean[] mask = fm.apply(SPECIES.length());29202921VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);29222923for (int ic = 0; ic < INVOC_COUNT; ic++) {2924for (int i = 0; i < a.length; i += SPECIES.length()) {2925FloatVector av = FloatVector.fromArray(SPECIES, a, i);2926FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2927VectorMask<Float> mv = av.compare(VectorOperators.LE, bv, vmask);29282929// Check results as part of computation.2930for (int j = 0; j < SPECIES.length(); j++) {2931Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));2932}2933}2934}2935}293629372938@Test(dataProvider = "floatCompareOpProvider")2939static void GEFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {2940float[] a = fa.apply(SPECIES.length());2941float[] b = fb.apply(SPECIES.length());29422943for (int ic = 0; ic < INVOC_COUNT; ic++) {2944for (int i = 0; i < a.length; i += SPECIES.length()) {2945FloatVector av = FloatVector.fromArray(SPECIES, a, i);2946FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2947VectorMask<Float> mv = av.compare(VectorOperators.GE, bv);29482949// Check results as part of computation.2950for (int j = 0; j < SPECIES.length(); j++) {2951Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));2952}2953}2954}2955}29562957@Test(dataProvider = "floatCompareOpMaskProvider")2958static void GEFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,2959IntFunction<boolean[]> fm) {2960float[] a = fa.apply(SPECIES.length());2961float[] b = fb.apply(SPECIES.length());2962boolean[] mask = fm.apply(SPECIES.length());29632964VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);29652966for (int ic = 0; ic < INVOC_COUNT; ic++) {2967for (int i = 0; i < a.length; i += SPECIES.length()) {2968FloatVector av = FloatVector.fromArray(SPECIES, a, i);2969FloatVector bv = FloatVector.fromArray(SPECIES, b, i);2970VectorMask<Float> mv = av.compare(VectorOperators.GE, bv, vmask);29712972// Check results as part of computation.2973for (int j = 0; j < SPECIES.length(); j++) {2974Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));2975}2976}2977}2978}29792980298129822983298429852986298729882989@Test(dataProvider = "floatCompareOpProvider")2990static void LTFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {2991float[] a = fa.apply(SPECIES.length());2992float[] b = fb.apply(SPECIES.length());29932994for (int i = 0; i < a.length; i += SPECIES.length()) {2995FloatVector av = FloatVector.fromArray(SPECIES, a, i);2996VectorMask<Float> mv = av.compare(VectorOperators.LT, b[i]);29972998// Check results as part of computation.2999for (int j = 0; j < SPECIES.length(); j++) {3000Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);3001}3002}3003}300430053006@Test(dataProvider = "floatCompareOpMaskProvider")3007static void LTFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction<float[]> fa,3008IntFunction<float[]> fb, IntFunction<boolean[]> fm) {3009float[] a = fa.apply(SPECIES.length());3010float[] b = fb.apply(SPECIES.length());3011boolean[] mask = fm.apply(SPECIES.length());30123013VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);30143015for (int i = 0; i < a.length; i += SPECIES.length()) {3016FloatVector av = FloatVector.fromArray(SPECIES, a, i);3017VectorMask<Float> mv = av.compare(VectorOperators.LT, b[i], vmask);30183019// Check results as part of computation.3020for (int j = 0; j < SPECIES.length(); j++) {3021Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));3022}3023}3024}30253026@Test(dataProvider = "floatCompareOpProvider")3027static void LTFloat128VectorTestsBroadcastLongSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {3028float[] a = fa.apply(SPECIES.length());3029float[] b = fb.apply(SPECIES.length());30303031for (int i = 0; i < a.length; i += SPECIES.length()) {3032FloatVector av = FloatVector.fromArray(SPECIES, a, i);3033VectorMask<Float> mv = av.compare(VectorOperators.LT, (long)b[i]);30343035// Check results as part of computation.3036for (int j = 0; j < SPECIES.length(); j++) {3037Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (float)((long)b[i]));3038}3039}3040}304130423043@Test(dataProvider = "floatCompareOpMaskProvider")3044static void LTFloat128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<float[]> fa,3045IntFunction<float[]> fb, IntFunction<boolean[]> fm) {3046float[] a = fa.apply(SPECIES.length());3047float[] b = fb.apply(SPECIES.length());3048boolean[] mask = fm.apply(SPECIES.length());30493050VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);30513052for (int i = 0; i < a.length; i += SPECIES.length()) {3053FloatVector av = FloatVector.fromArray(SPECIES, a, i);3054VectorMask<Float> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);30553056// Check results as part of computation.3057for (int j = 0; j < SPECIES.length(); j++) {3058Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (float)((long)b[i])));3059}3060}3061}30623063@Test(dataProvider = "floatCompareOpProvider")3064static void EQFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {3065float[] a = fa.apply(SPECIES.length());3066float[] b = fb.apply(SPECIES.length());30673068for (int i = 0; i < a.length; i += SPECIES.length()) {3069FloatVector av = FloatVector.fromArray(SPECIES, a, i);3070VectorMask<Float> mv = av.compare(VectorOperators.EQ, b[i]);30713072// Check results as part of computation.3073for (int j = 0; j < SPECIES.length(); j++) {3074Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);3075}3076}3077}307830793080@Test(dataProvider = "floatCompareOpMaskProvider")3081static void EQFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction<float[]> fa,3082IntFunction<float[]> fb, IntFunction<boolean[]> fm) {3083float[] a = fa.apply(SPECIES.length());3084float[] b = fb.apply(SPECIES.length());3085boolean[] mask = fm.apply(SPECIES.length());30863087VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);30883089for (int i = 0; i < a.length; i += SPECIES.length()) {3090FloatVector av = FloatVector.fromArray(SPECIES, a, i);3091VectorMask<Float> mv = av.compare(VectorOperators.EQ, b[i], vmask);30923093// Check results as part of computation.3094for (int j = 0; j < SPECIES.length(); j++) {3095Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));3096}3097}3098}30993100@Test(dataProvider = "floatCompareOpProvider")3101static void EQFloat128VectorTestsBroadcastLongSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {3102float[] a = fa.apply(SPECIES.length());3103float[] b = fb.apply(SPECIES.length());31043105for (int i = 0; i < a.length; i += SPECIES.length()) {3106FloatVector av = FloatVector.fromArray(SPECIES, a, i);3107VectorMask<Float> mv = av.compare(VectorOperators.EQ, (long)b[i]);31083109// Check results as part of computation.3110for (int j = 0; j < SPECIES.length(); j++) {3111Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (float)((long)b[i]));3112}3113}3114}311531163117@Test(dataProvider = "floatCompareOpMaskProvider")3118static void EQFloat128VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<float[]> fa,3119IntFunction<float[]> fb, IntFunction<boolean[]> fm) {3120float[] a = fa.apply(SPECIES.length());3121float[] b = fb.apply(SPECIES.length());3122boolean[] mask = fm.apply(SPECIES.length());31233124VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);31253126for (int i = 0; i < a.length; i += SPECIES.length()) {3127FloatVector av = FloatVector.fromArray(SPECIES, a, i);3128VectorMask<Float> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);31293130// Check results as part of computation.3131for (int j = 0; j < SPECIES.length(); j++) {3132Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (float)((long)b[i])));3133}3134}3135}31363137static float blend(float a, float b, boolean mask) {3138return mask ? b : a;3139}31403141@Test(dataProvider = "floatBinaryOpMaskProvider")3142static void blendFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb,3143IntFunction<boolean[]> fm) {3144float[] a = fa.apply(SPECIES.length());3145float[] b = fb.apply(SPECIES.length());3146float[] r = fr.apply(SPECIES.length());3147boolean[] mask = fm.apply(SPECIES.length());3148VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);31493150for (int ic = 0; ic < INVOC_COUNT; ic++) {3151for (int i = 0; i < a.length; i += SPECIES.length()) {3152FloatVector av = FloatVector.fromArray(SPECIES, a, i);3153FloatVector bv = FloatVector.fromArray(SPECIES, b, i);3154av.blend(bv, vmask).intoArray(r, i);3155}3156}31573158assertArraysEquals(r, a, b, mask, Float128VectorTests::blend);3159}31603161@Test(dataProvider = "floatUnaryOpShuffleProvider")3162static void RearrangeFloat128VectorTests(IntFunction<float[]> fa,3163BiFunction<Integer,Integer,int[]> fs) {3164float[] a = fa.apply(SPECIES.length());3165int[] order = fs.apply(a.length, SPECIES.length());3166float[] r = fr.apply(SPECIES.length());31673168for (int ic = 0; ic < INVOC_COUNT; ic++) {3169for (int i = 0; i < a.length; i += SPECIES.length()) {3170FloatVector av = FloatVector.fromArray(SPECIES, a, i);3171av.rearrange(VectorShuffle.fromArray(SPECIES, order, i)).intoArray(r, i);3172}3173}31743175assertRearrangeArraysEquals(r, a, order, SPECIES.length());3176}31773178@Test(dataProvider = "floatUnaryOpShuffleMaskProvider")3179static void RearrangeFloat128VectorTestsMaskedSmokeTest(IntFunction<float[]> fa,3180BiFunction<Integer,Integer,int[]> fs,3181IntFunction<boolean[]> fm) {3182float[] a = fa.apply(SPECIES.length());3183int[] order = fs.apply(a.length, SPECIES.length());3184float[] r = fr.apply(SPECIES.length());3185boolean[] mask = fm.apply(SPECIES.length());3186VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);31873188for (int i = 0; i < a.length; i += SPECIES.length()) {3189FloatVector av = FloatVector.fromArray(SPECIES, a, i);3190av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);3191}31923193assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());3194}3195@Test(dataProvider = "floatUnaryOpProvider")3196static void getFloat128VectorTests(IntFunction<float[]> fa) {3197float[] a = fa.apply(SPECIES.length());3198float[] r = fr.apply(SPECIES.length());31993200for (int ic = 0; ic < INVOC_COUNT; ic++) {3201for (int i = 0; i < a.length; i += SPECIES.length()) {3202FloatVector av = FloatVector.fromArray(SPECIES, a, i);3203int num_lanes = SPECIES.length();3204// Manually unroll because full unroll happens after intrinsification.3205// Unroll is needed because get intrinsic requires for index to be a known constant.3206if (num_lanes == 1) {3207r[i]=av.lane(0);3208} else if (num_lanes == 2) {3209r[i]=av.lane(0);3210r[i+1]=av.lane(1);3211} else if (num_lanes == 4) {3212r[i]=av.lane(0);3213r[i+1]=av.lane(1);3214r[i+2]=av.lane(2);3215r[i+3]=av.lane(3);3216} else if (num_lanes == 8) {3217r[i]=av.lane(0);3218r[i+1]=av.lane(1);3219r[i+2]=av.lane(2);3220r[i+3]=av.lane(3);3221r[i+4]=av.lane(4);3222r[i+5]=av.lane(5);3223r[i+6]=av.lane(6);3224r[i+7]=av.lane(7);3225} else if (num_lanes == 16) {3226r[i]=av.lane(0);3227r[i+1]=av.lane(1);3228r[i+2]=av.lane(2);3229r[i+3]=av.lane(3);3230r[i+4]=av.lane(4);3231r[i+5]=av.lane(5);3232r[i+6]=av.lane(6);3233r[i+7]=av.lane(7);3234r[i+8]=av.lane(8);3235r[i+9]=av.lane(9);3236r[i+10]=av.lane(10);3237r[i+11]=av.lane(11);3238r[i+12]=av.lane(12);3239r[i+13]=av.lane(13);3240r[i+14]=av.lane(14);3241r[i+15]=av.lane(15);3242} else if (num_lanes == 32) {3243r[i]=av.lane(0);3244r[i+1]=av.lane(1);3245r[i+2]=av.lane(2);3246r[i+3]=av.lane(3);3247r[i+4]=av.lane(4);3248r[i+5]=av.lane(5);3249r[i+6]=av.lane(6);3250r[i+7]=av.lane(7);3251r[i+8]=av.lane(8);3252r[i+9]=av.lane(9);3253r[i+10]=av.lane(10);3254r[i+11]=av.lane(11);3255r[i+12]=av.lane(12);3256r[i+13]=av.lane(13);3257r[i+14]=av.lane(14);3258r[i+15]=av.lane(15);3259r[i+16]=av.lane(16);3260r[i+17]=av.lane(17);3261r[i+18]=av.lane(18);3262r[i+19]=av.lane(19);3263r[i+20]=av.lane(20);3264r[i+21]=av.lane(21);3265r[i+22]=av.lane(22);3266r[i+23]=av.lane(23);3267r[i+24]=av.lane(24);3268r[i+25]=av.lane(25);3269r[i+26]=av.lane(26);3270r[i+27]=av.lane(27);3271r[i+28]=av.lane(28);3272r[i+29]=av.lane(29);3273r[i+30]=av.lane(30);3274r[i+31]=av.lane(31);3275} else if (num_lanes == 64) {3276r[i]=av.lane(0);3277r[i+1]=av.lane(1);3278r[i+2]=av.lane(2);3279r[i+3]=av.lane(3);3280r[i+4]=av.lane(4);3281r[i+5]=av.lane(5);3282r[i+6]=av.lane(6);3283r[i+7]=av.lane(7);3284r[i+8]=av.lane(8);3285r[i+9]=av.lane(9);3286r[i+10]=av.lane(10);3287r[i+11]=av.lane(11);3288r[i+12]=av.lane(12);3289r[i+13]=av.lane(13);3290r[i+14]=av.lane(14);3291r[i+15]=av.lane(15);3292r[i+16]=av.lane(16);3293r[i+17]=av.lane(17);3294r[i+18]=av.lane(18);3295r[i+19]=av.lane(19);3296r[i+20]=av.lane(20);3297r[i+21]=av.lane(21);3298r[i+22]=av.lane(22);3299r[i+23]=av.lane(23);3300r[i+24]=av.lane(24);3301r[i+25]=av.lane(25);3302r[i+26]=av.lane(26);3303r[i+27]=av.lane(27);3304r[i+28]=av.lane(28);3305r[i+29]=av.lane(29);3306r[i+30]=av.lane(30);3307r[i+31]=av.lane(31);3308r[i+32]=av.lane(32);3309r[i+33]=av.lane(33);3310r[i+34]=av.lane(34);3311r[i+35]=av.lane(35);3312r[i+36]=av.lane(36);3313r[i+37]=av.lane(37);3314r[i+38]=av.lane(38);3315r[i+39]=av.lane(39);3316r[i+40]=av.lane(40);3317r[i+41]=av.lane(41);3318r[i+42]=av.lane(42);3319r[i+43]=av.lane(43);3320r[i+44]=av.lane(44);3321r[i+45]=av.lane(45);3322r[i+46]=av.lane(46);3323r[i+47]=av.lane(47);3324r[i+48]=av.lane(48);3325r[i+49]=av.lane(49);3326r[i+50]=av.lane(50);3327r[i+51]=av.lane(51);3328r[i+52]=av.lane(52);3329r[i+53]=av.lane(53);3330r[i+54]=av.lane(54);3331r[i+55]=av.lane(55);3332r[i+56]=av.lane(56);3333r[i+57]=av.lane(57);3334r[i+58]=av.lane(58);3335r[i+59]=av.lane(59);3336r[i+60]=av.lane(60);3337r[i+61]=av.lane(61);3338r[i+62]=av.lane(62);3339r[i+63]=av.lane(63);3340} else {3341for (int j = 0; j < SPECIES.length(); j++) {3342r[i+j]=av.lane(j);3343}3344}3345}3346}33473348assertArraysEquals(r, a, Float128VectorTests::get);3349}33503351@Test(dataProvider = "floatUnaryOpProvider")3352static void BroadcastFloat128VectorTests(IntFunction<float[]> fa) {3353float[] a = fa.apply(SPECIES.length());3354float[] r = new float[a.length];33553356for (int ic = 0; ic < INVOC_COUNT; ic++) {3357for (int i = 0; i < a.length; i += SPECIES.length()) {3358FloatVector.broadcast(SPECIES, a[i]).intoArray(r, i);3359}3360}33613362assertBroadcastArraysEquals(r, a);3363}336433653366336733683369@Test(dataProvider = "floatUnaryOpProvider")3370static void ZeroFloat128VectorTests(IntFunction<float[]> fa) {3371float[] a = fa.apply(SPECIES.length());3372float[] r = new float[a.length];33733374for (int ic = 0; ic < INVOC_COUNT; ic++) {3375for (int i = 0; i < a.length; i += SPECIES.length()) {3376FloatVector.zero(SPECIES).intoArray(a, i);3377}3378}33793380Assert.assertEquals(a, r);3381}33823383338433853386static float[] sliceUnary(float[] a, int origin, int idx) {3387float[] res = new float[SPECIES.length()];3388for (int i = 0; i < SPECIES.length(); i++){3389if(i+origin < SPECIES.length())3390res[i] = a[idx+i+origin];3391else3392res[i] = (float)0;3393}3394return res;3395}33963397@Test(dataProvider = "floatUnaryOpProvider")3398static void sliceUnaryFloat128VectorTests(IntFunction<float[]> fa) {3399float[] a = fa.apply(SPECIES.length());3400float[] r = new float[a.length];3401int origin = (new java.util.Random()).nextInt(SPECIES.length());3402for (int ic = 0; ic < INVOC_COUNT; ic++) {3403for (int i = 0; i < a.length; i += SPECIES.length()) {3404FloatVector av = FloatVector.fromArray(SPECIES, a, i);3405av.slice(origin).intoArray(r, i);3406}3407}34083409assertArraysEquals(r, a, origin, Float128VectorTests::sliceUnary);3410}3411static float[] sliceBinary(float[] a, float[] b, int origin, int idx) {3412float[] res = new float[SPECIES.length()];3413for (int i = 0, j = 0; i < SPECIES.length(); i++){3414if(i+origin < SPECIES.length())3415res[i] = a[idx+i+origin];3416else {3417res[i] = b[idx+j];3418j++;3419}3420}3421return res;3422}34233424@Test(dataProvider = "floatBinaryOpProvider")3425static void sliceBinaryFloat128VectorTestsBinary(IntFunction<float[]> fa, IntFunction<float[]> fb) {3426float[] a = fa.apply(SPECIES.length());3427float[] b = fb.apply(SPECIES.length());3428float[] r = new float[a.length];3429int origin = (new java.util.Random()).nextInt(SPECIES.length());3430for (int ic = 0; ic < INVOC_COUNT; ic++) {3431for (int i = 0; i < a.length; i += SPECIES.length()) {3432FloatVector av = FloatVector.fromArray(SPECIES, a, i);3433FloatVector bv = FloatVector.fromArray(SPECIES, b, i);3434av.slice(origin, bv).intoArray(r, i);3435}3436}34373438assertArraysEquals(r, a, b, origin, Float128VectorTests::sliceBinary);3439}3440static float[] slice(float[] a, float[] b, int origin, boolean[] mask, int idx) {3441float[] res = new float[SPECIES.length()];3442for (int i = 0, j = 0; i < SPECIES.length(); i++){3443if(i+origin < SPECIES.length())3444res[i] = mask[i] ? a[idx+i+origin] : (float)0;3445else {3446res[i] = mask[i] ? b[idx+j] : (float)0;3447j++;3448}3449}3450return res;3451}34523453@Test(dataProvider = "floatBinaryOpMaskProvider")3454static void sliceFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,3455IntFunction<boolean[]> fm) {3456float[] a = fa.apply(SPECIES.length());3457float[] b = fb.apply(SPECIES.length());3458boolean[] mask = fm.apply(SPECIES.length());3459VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);34603461float[] r = new float[a.length];3462int origin = (new java.util.Random()).nextInt(SPECIES.length());3463for (int ic = 0; ic < INVOC_COUNT; ic++) {3464for (int i = 0; i < a.length; i += SPECIES.length()) {3465FloatVector av = FloatVector.fromArray(SPECIES, a, i);3466FloatVector bv = FloatVector.fromArray(SPECIES, b, i);3467av.slice(origin, bv, vmask).intoArray(r, i);3468}3469}34703471assertArraysEquals(r, a, b, origin, mask, Float128VectorTests::slice);3472}3473static float[] unsliceUnary(float[] a, int origin, int idx) {3474float[] res = new float[SPECIES.length()];3475for (int i = 0, j = 0; i < SPECIES.length(); i++){3476if(i < origin)3477res[i] = (float)0;3478else {3479res[i] = a[idx+j];3480j++;3481}3482}3483return res;3484}34853486@Test(dataProvider = "floatUnaryOpProvider")3487static void unsliceUnaryFloat128VectorTests(IntFunction<float[]> fa) {3488float[] a = fa.apply(SPECIES.length());3489float[] r = new float[a.length];3490int origin = (new java.util.Random()).nextInt(SPECIES.length());3491for (int ic = 0; ic < INVOC_COUNT; ic++) {3492for (int i = 0; i < a.length; i += SPECIES.length()) {3493FloatVector av = FloatVector.fromArray(SPECIES, a, i);3494av.unslice(origin).intoArray(r, i);3495}3496}34973498assertArraysEquals(r, a, origin, Float128VectorTests::unsliceUnary);3499}3500static float[] unsliceBinary(float[] a, float[] b, int origin, int part, int idx) {3501float[] res = new float[SPECIES.length()];3502for (int i = 0, j = 0; i < SPECIES.length(); i++){3503if (part == 0) {3504if (i < origin)3505res[i] = b[idx+i];3506else {3507res[i] = a[idx+j];3508j++;3509}3510} else if (part == 1) {3511if (i < origin)3512res[i] = a[idx+SPECIES.length()-origin+i];3513else {3514res[i] = b[idx+origin+j];3515j++;3516}3517}3518}3519return res;3520}35213522@Test(dataProvider = "floatBinaryOpProvider")3523static void unsliceBinaryFloat128VectorTestsBinary(IntFunction<float[]> fa, IntFunction<float[]> fb) {3524float[] a = fa.apply(SPECIES.length());3525float[] b = fb.apply(SPECIES.length());3526float[] r = new float[a.length];3527int origin = (new java.util.Random()).nextInt(SPECIES.length());3528int part = (new java.util.Random()).nextInt(2);3529for (int ic = 0; ic < INVOC_COUNT; ic++) {3530for (int i = 0; i < a.length; i += SPECIES.length()) {3531FloatVector av = FloatVector.fromArray(SPECIES, a, i);3532FloatVector bv = FloatVector.fromArray(SPECIES, b, i);3533av.unslice(origin, bv, part).intoArray(r, i);3534}3535}35363537assertArraysEquals(r, a, b, origin, part, Float128VectorTests::unsliceBinary);3538}3539static float[] unslice(float[] a, float[] b, int origin, int part, boolean[] mask, int idx) {3540float[] res = new float[SPECIES.length()];3541for (int i = 0, j = 0; i < SPECIES.length(); i++){3542if(i+origin < SPECIES.length())3543res[i] = b[idx+i+origin];3544else {3545res[i] = b[idx+j];3546j++;3547}3548}3549for (int i = 0; i < SPECIES.length(); i++){3550res[i] = mask[i] ? a[idx+i] : res[i];3551}3552float[] res1 = new float[SPECIES.length()];3553if (part == 0) {3554for (int i = 0, j = 0; i < SPECIES.length(); i++){3555if (i < origin)3556res1[i] = b[idx+i];3557else {3558res1[i] = res[j];3559j++;3560}3561}3562} else if (part == 1) {3563for (int i = 0, j = 0; i < SPECIES.length(); i++){3564if (i < origin)3565res1[i] = res[SPECIES.length()-origin+i];3566else {3567res1[i] = b[idx+origin+j];3568j++;3569}3570}3571}3572return res1;3573}35743575@Test(dataProvider = "floatBinaryOpMaskProvider")3576static void unsliceFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,3577IntFunction<boolean[]> fm) {3578float[] a = fa.apply(SPECIES.length());3579float[] b = fb.apply(SPECIES.length());3580boolean[] mask = fm.apply(SPECIES.length());3581VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);3582float[] r = new float[a.length];3583int origin = (new java.util.Random()).nextInt(SPECIES.length());3584int part = (new java.util.Random()).nextInt(2);3585for (int ic = 0; ic < INVOC_COUNT; ic++) {3586for (int i = 0; i < a.length; i += SPECIES.length()) {3587FloatVector av = FloatVector.fromArray(SPECIES, a, i);3588FloatVector bv = FloatVector.fromArray(SPECIES, b, i);3589av.unslice(origin, bv, part, vmask).intoArray(r, i);3590}3591}35923593assertArraysEquals(r, a, b, origin, part, mask, Float128VectorTests::unslice);3594}35953596static float SIN(float a) {3597return (float)(Math.sin((double)a));3598}35993600static float strictSIN(float a) {3601return (float)(StrictMath.sin((double)a));3602}36033604@Test(dataProvider = "floatUnaryOpProvider")3605static void SINFloat128VectorTests(IntFunction<float[]> fa) {3606float[] a = fa.apply(SPECIES.length());3607float[] r = fr.apply(SPECIES.length());36083609for (int ic = 0; ic < INVOC_COUNT; ic++) {3610for (int i = 0; i < a.length; i += SPECIES.length()) {3611FloatVector av = FloatVector.fromArray(SPECIES, a, i);3612av.lanewise(VectorOperators.SIN).intoArray(r, i);3613}3614}36153616assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::SIN, Float128VectorTests::strictSIN);3617}361836193620static float EXP(float a) {3621return (float)(Math.exp((double)a));3622}36233624static float strictEXP(float a) {3625return (float)(StrictMath.exp((double)a));3626}36273628@Test(dataProvider = "floatUnaryOpProvider")3629static void EXPFloat128VectorTests(IntFunction<float[]> fa) {3630float[] a = fa.apply(SPECIES.length());3631float[] r = fr.apply(SPECIES.length());36323633for (int ic = 0; ic < INVOC_COUNT; ic++) {3634for (int i = 0; i < a.length; i += SPECIES.length()) {3635FloatVector av = FloatVector.fromArray(SPECIES, a, i);3636av.lanewise(VectorOperators.EXP).intoArray(r, i);3637}3638}36393640assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::EXP, Float128VectorTests::strictEXP);3641}364236433644static float LOG1P(float a) {3645return (float)(Math.log1p((double)a));3646}36473648static float strictLOG1P(float a) {3649return (float)(StrictMath.log1p((double)a));3650}36513652@Test(dataProvider = "floatUnaryOpProvider")3653static void LOG1PFloat128VectorTests(IntFunction<float[]> fa) {3654float[] a = fa.apply(SPECIES.length());3655float[] r = fr.apply(SPECIES.length());36563657for (int ic = 0; ic < INVOC_COUNT; ic++) {3658for (int i = 0; i < a.length; i += SPECIES.length()) {3659FloatVector av = FloatVector.fromArray(SPECIES, a, i);3660av.lanewise(VectorOperators.LOG1P).intoArray(r, i);3661}3662}36633664assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::LOG1P, Float128VectorTests::strictLOG1P);3665}366636673668static float LOG(float a) {3669return (float)(Math.log((double)a));3670}36713672static float strictLOG(float a) {3673return (float)(StrictMath.log((double)a));3674}36753676@Test(dataProvider = "floatUnaryOpProvider")3677static void LOGFloat128VectorTests(IntFunction<float[]> fa) {3678float[] a = fa.apply(SPECIES.length());3679float[] r = fr.apply(SPECIES.length());36803681for (int ic = 0; ic < INVOC_COUNT; ic++) {3682for (int i = 0; i < a.length; i += SPECIES.length()) {3683FloatVector av = FloatVector.fromArray(SPECIES, a, i);3684av.lanewise(VectorOperators.LOG).intoArray(r, i);3685}3686}36873688assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::LOG, Float128VectorTests::strictLOG);3689}369036913692static float LOG10(float a) {3693return (float)(Math.log10((double)a));3694}36953696static float strictLOG10(float a) {3697return (float)(StrictMath.log10((double)a));3698}36993700@Test(dataProvider = "floatUnaryOpProvider")3701static void LOG10Float128VectorTests(IntFunction<float[]> fa) {3702float[] a = fa.apply(SPECIES.length());3703float[] r = fr.apply(SPECIES.length());37043705for (int ic = 0; ic < INVOC_COUNT; ic++) {3706for (int i = 0; i < a.length; i += SPECIES.length()) {3707FloatVector av = FloatVector.fromArray(SPECIES, a, i);3708av.lanewise(VectorOperators.LOG10).intoArray(r, i);3709}3710}37113712assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::LOG10, Float128VectorTests::strictLOG10);3713}371437153716static float EXPM1(float a) {3717return (float)(Math.expm1((double)a));3718}37193720static float strictEXPM1(float a) {3721return (float)(StrictMath.expm1((double)a));3722}37233724@Test(dataProvider = "floatUnaryOpProvider")3725static void EXPM1Float128VectorTests(IntFunction<float[]> fa) {3726float[] a = fa.apply(SPECIES.length());3727float[] r = fr.apply(SPECIES.length());37283729for (int ic = 0; ic < INVOC_COUNT; ic++) {3730for (int i = 0; i < a.length; i += SPECIES.length()) {3731FloatVector av = FloatVector.fromArray(SPECIES, a, i);3732av.lanewise(VectorOperators.EXPM1).intoArray(r, i);3733}3734}37353736assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::EXPM1, Float128VectorTests::strictEXPM1);3737}373837393740static float COS(float a) {3741return (float)(Math.cos((double)a));3742}37433744static float strictCOS(float a) {3745return (float)(StrictMath.cos((double)a));3746}37473748@Test(dataProvider = "floatUnaryOpProvider")3749static void COSFloat128VectorTests(IntFunction<float[]> fa) {3750float[] a = fa.apply(SPECIES.length());3751float[] r = fr.apply(SPECIES.length());37523753for (int ic = 0; ic < INVOC_COUNT; ic++) {3754for (int i = 0; i < a.length; i += SPECIES.length()) {3755FloatVector av = FloatVector.fromArray(SPECIES, a, i);3756av.lanewise(VectorOperators.COS).intoArray(r, i);3757}3758}37593760assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::COS, Float128VectorTests::strictCOS);3761}376237633764static float TAN(float a) {3765return (float)(Math.tan((double)a));3766}37673768static float strictTAN(float a) {3769return (float)(StrictMath.tan((double)a));3770}37713772@Test(dataProvider = "floatUnaryOpProvider")3773static void TANFloat128VectorTests(IntFunction<float[]> fa) {3774float[] a = fa.apply(SPECIES.length());3775float[] r = fr.apply(SPECIES.length());37763777for (int ic = 0; ic < INVOC_COUNT; ic++) {3778for (int i = 0; i < a.length; i += SPECIES.length()) {3779FloatVector av = FloatVector.fromArray(SPECIES, a, i);3780av.lanewise(VectorOperators.TAN).intoArray(r, i);3781}3782}37833784assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::TAN, Float128VectorTests::strictTAN);3785}378637873788static float SINH(float a) {3789return (float)(Math.sinh((double)a));3790}37913792static float strictSINH(float a) {3793return (float)(StrictMath.sinh((double)a));3794}37953796@Test(dataProvider = "floatUnaryOpProvider")3797static void SINHFloat128VectorTests(IntFunction<float[]> fa) {3798float[] a = fa.apply(SPECIES.length());3799float[] r = fr.apply(SPECIES.length());38003801for (int ic = 0; ic < INVOC_COUNT; ic++) {3802for (int i = 0; i < a.length; i += SPECIES.length()) {3803FloatVector av = FloatVector.fromArray(SPECIES, a, i);3804av.lanewise(VectorOperators.SINH).intoArray(r, i);3805}3806}38073808assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::SINH, Float128VectorTests::strictSINH);3809}381038113812static float COSH(float a) {3813return (float)(Math.cosh((double)a));3814}38153816static float strictCOSH(float a) {3817return (float)(StrictMath.cosh((double)a));3818}38193820@Test(dataProvider = "floatUnaryOpProvider")3821static void COSHFloat128VectorTests(IntFunction<float[]> fa) {3822float[] a = fa.apply(SPECIES.length());3823float[] r = fr.apply(SPECIES.length());38243825for (int ic = 0; ic < INVOC_COUNT; ic++) {3826for (int i = 0; i < a.length; i += SPECIES.length()) {3827FloatVector av = FloatVector.fromArray(SPECIES, a, i);3828av.lanewise(VectorOperators.COSH).intoArray(r, i);3829}3830}38313832assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::COSH, Float128VectorTests::strictCOSH);3833}383438353836static float TANH(float a) {3837return (float)(Math.tanh((double)a));3838}38393840static float strictTANH(float a) {3841return (float)(StrictMath.tanh((double)a));3842}38433844@Test(dataProvider = "floatUnaryOpProvider")3845static void TANHFloat128VectorTests(IntFunction<float[]> fa) {3846float[] a = fa.apply(SPECIES.length());3847float[] r = fr.apply(SPECIES.length());38483849for (int ic = 0; ic < INVOC_COUNT; ic++) {3850for (int i = 0; i < a.length; i += SPECIES.length()) {3851FloatVector av = FloatVector.fromArray(SPECIES, a, i);3852av.lanewise(VectorOperators.TANH).intoArray(r, i);3853}3854}38553856assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::TANH, Float128VectorTests::strictTANH);3857}385838593860static float ASIN(float a) {3861return (float)(Math.asin((double)a));3862}38633864static float strictASIN(float a) {3865return (float)(StrictMath.asin((double)a));3866}38673868@Test(dataProvider = "floatUnaryOpProvider")3869static void ASINFloat128VectorTests(IntFunction<float[]> fa) {3870float[] a = fa.apply(SPECIES.length());3871float[] r = fr.apply(SPECIES.length());38723873for (int ic = 0; ic < INVOC_COUNT; ic++) {3874for (int i = 0; i < a.length; i += SPECIES.length()) {3875FloatVector av = FloatVector.fromArray(SPECIES, a, i);3876av.lanewise(VectorOperators.ASIN).intoArray(r, i);3877}3878}38793880assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::ASIN, Float128VectorTests::strictASIN);3881}388238833884static float ACOS(float a) {3885return (float)(Math.acos((double)a));3886}38873888static float strictACOS(float a) {3889return (float)(StrictMath.acos((double)a));3890}38913892@Test(dataProvider = "floatUnaryOpProvider")3893static void ACOSFloat128VectorTests(IntFunction<float[]> fa) {3894float[] a = fa.apply(SPECIES.length());3895float[] r = fr.apply(SPECIES.length());38963897for (int ic = 0; ic < INVOC_COUNT; ic++) {3898for (int i = 0; i < a.length; i += SPECIES.length()) {3899FloatVector av = FloatVector.fromArray(SPECIES, a, i);3900av.lanewise(VectorOperators.ACOS).intoArray(r, i);3901}3902}39033904assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::ACOS, Float128VectorTests::strictACOS);3905}390639073908static float ATAN(float a) {3909return (float)(Math.atan((double)a));3910}39113912static float strictATAN(float a) {3913return (float)(StrictMath.atan((double)a));3914}39153916@Test(dataProvider = "floatUnaryOpProvider")3917static void ATANFloat128VectorTests(IntFunction<float[]> fa) {3918float[] a = fa.apply(SPECIES.length());3919float[] r = fr.apply(SPECIES.length());39203921for (int ic = 0; ic < INVOC_COUNT; ic++) {3922for (int i = 0; i < a.length; i += SPECIES.length()) {3923FloatVector av = FloatVector.fromArray(SPECIES, a, i);3924av.lanewise(VectorOperators.ATAN).intoArray(r, i);3925}3926}39273928assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::ATAN, Float128VectorTests::strictATAN);3929}393039313932static float CBRT(float a) {3933return (float)(Math.cbrt((double)a));3934}39353936static float strictCBRT(float a) {3937return (float)(StrictMath.cbrt((double)a));3938}39393940@Test(dataProvider = "floatUnaryOpProvider")3941static void CBRTFloat128VectorTests(IntFunction<float[]> fa) {3942float[] a = fa.apply(SPECIES.length());3943float[] r = fr.apply(SPECIES.length());39443945for (int ic = 0; ic < INVOC_COUNT; ic++) {3946for (int i = 0; i < a.length; i += SPECIES.length()) {3947FloatVector av = FloatVector.fromArray(SPECIES, a, i);3948av.lanewise(VectorOperators.CBRT).intoArray(r, i);3949}3950}39513952assertArraysEqualsWithinOneUlp(r, a, Float128VectorTests::CBRT, Float128VectorTests::strictCBRT);3953}395439553956static float HYPOT(float a, float b) {3957return (float)(Math.hypot((double)a, (double)b));3958}39593960static float strictHYPOT(float a, float b) {3961return (float)(StrictMath.hypot((double)a, (double)b));3962}39633964@Test(dataProvider = "floatBinaryOpProvider")3965static void HYPOTFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {3966float[] a = fa.apply(SPECIES.length());3967float[] b = fb.apply(SPECIES.length());3968float[] r = fr.apply(SPECIES.length());39693970for (int ic = 0; ic < INVOC_COUNT; ic++) {3971for (int i = 0; i < a.length; i += SPECIES.length()) {3972FloatVector av = FloatVector.fromArray(SPECIES, a, i);3973FloatVector bv = FloatVector.fromArray(SPECIES, b, i);3974av.lanewise(VectorOperators.HYPOT, bv).intoArray(r, i);3975}3976}39773978assertArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::HYPOT, Float128VectorTests::strictHYPOT);3979}3980398139823983static float POW(float a, float b) {3984return (float)(Math.pow((double)a, (double)b));3985}39863987static float strictPOW(float a, float b) {3988return (float)(StrictMath.pow((double)a, (double)b));3989}39903991@Test(dataProvider = "floatBinaryOpProvider")3992static void POWFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {3993float[] a = fa.apply(SPECIES.length());3994float[] b = fb.apply(SPECIES.length());3995float[] r = fr.apply(SPECIES.length());39963997for (int ic = 0; ic < INVOC_COUNT; ic++) {3998for (int i = 0; i < a.length; i += SPECIES.length()) {3999FloatVector av = FloatVector.fromArray(SPECIES, a, i);4000FloatVector bv = FloatVector.fromArray(SPECIES, b, i);4001av.lanewise(VectorOperators.POW, bv).intoArray(r, i);4002}4003}40044005assertArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::POW, Float128VectorTests::strictPOW);4006}40074008static float pow(float a, float b) {4009return (float)(Math.pow((double)a, (double)b));4010}40114012static float strictpow(float a, float b) {4013return (float)(StrictMath.pow((double)a, (double)b));4014}40154016@Test(dataProvider = "floatBinaryOpProvider")4017static void powFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {4018float[] a = fa.apply(SPECIES.length());4019float[] b = fb.apply(SPECIES.length());4020float[] r = fr.apply(SPECIES.length());40214022for (int ic = 0; ic < INVOC_COUNT; ic++) {4023for (int i = 0; i < a.length; i += SPECIES.length()) {4024FloatVector av = FloatVector.fromArray(SPECIES, a, i);4025FloatVector bv = FloatVector.fromArray(SPECIES, b, i);4026av.pow(bv).intoArray(r, i);4027}4028}40294030assertArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::pow, Float128VectorTests::strictpow);4031}4032403340344035static float ATAN2(float a, float b) {4036return (float)(Math.atan2((double)a, (double)b));4037}40384039static float strictATAN2(float a, float b) {4040return (float)(StrictMath.atan2((double)a, (double)b));4041}40424043@Test(dataProvider = "floatBinaryOpProvider")4044static void ATAN2Float128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb) {4045float[] a = fa.apply(SPECIES.length());4046float[] b = fb.apply(SPECIES.length());4047float[] r = fr.apply(SPECIES.length());40484049for (int ic = 0; ic < INVOC_COUNT; ic++) {4050for (int i = 0; i < a.length; i += SPECIES.length()) {4051FloatVector av = FloatVector.fromArray(SPECIES, a, i);4052FloatVector bv = FloatVector.fromArray(SPECIES, b, i);4053av.lanewise(VectorOperators.ATAN2, bv).intoArray(r, i);4054}4055}40564057assertArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::ATAN2, Float128VectorTests::strictATAN2);4058}4059406040614062@Test(dataProvider = "floatBinaryOpProvider")4063static void POWFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {4064float[] a = fa.apply(SPECIES.length());4065float[] b = fb.apply(SPECIES.length());4066float[] r = fr.apply(SPECIES.length());40674068for (int i = 0; i < a.length; i += SPECIES.length()) {4069FloatVector av = FloatVector.fromArray(SPECIES, a, i);4070av.lanewise(VectorOperators.POW, b[i]).intoArray(r, i);4071}40724073assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::POW, Float128VectorTests::strictPOW);4074}40754076@Test(dataProvider = "floatBinaryOpProvider")4077static void powFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {4078float[] a = fa.apply(SPECIES.length());4079float[] b = fb.apply(SPECIES.length());4080float[] r = fr.apply(SPECIES.length());40814082for (int i = 0; i < a.length; i += SPECIES.length()) {4083FloatVector av = FloatVector.fromArray(SPECIES, a, i);4084av.pow(b[i]).intoArray(r, i);4085}40864087assertBroadcastArraysEqualsWithinOneUlp(r, a, b, Float128VectorTests::pow, Float128VectorTests::strictpow);4088}4089409040914092static float FMA(float a, float b, float c) {4093return (float)(Math.fma(a, b, c));4094}4095static float fma(float a, float b, float c) {4096return (float)(Math.fma(a, b, c));4097}409840994100@Test(dataProvider = "floatTernaryOpProvider")4101static void FMAFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb, IntFunction<float[]> fc) {4102float[] a = fa.apply(SPECIES.length());4103float[] b = fb.apply(SPECIES.length());4104float[] c = fc.apply(SPECIES.length());4105float[] r = fr.apply(SPECIES.length());41064107for (int ic = 0; ic < INVOC_COUNT; ic++) {4108for (int i = 0; i < a.length; i += SPECIES.length()) {4109FloatVector av = FloatVector.fromArray(SPECIES, a, i);4110FloatVector bv = FloatVector.fromArray(SPECIES, b, i);4111FloatVector cv = FloatVector.fromArray(SPECIES, c, i);4112av.lanewise(VectorOperators.FMA, bv, cv).intoArray(r, i);4113}4114}41154116assertArraysEquals(r, a, b, c, Float128VectorTests::FMA);4117}4118@Test(dataProvider = "floatTernaryOpProvider")4119static void fmaFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb, IntFunction<float[]> fc) {4120float[] a = fa.apply(SPECIES.length());4121float[] b = fb.apply(SPECIES.length());4122float[] c = fc.apply(SPECIES.length());4123float[] r = fr.apply(SPECIES.length());41244125for (int i = 0; i < a.length; i += SPECIES.length()) {4126FloatVector av = FloatVector.fromArray(SPECIES, a, i);4127FloatVector bv = FloatVector.fromArray(SPECIES, b, i);4128FloatVector cv = FloatVector.fromArray(SPECIES, c, i);4129av.fma(bv, cv).intoArray(r, i);4130}41314132assertArraysEquals(r, a, b, c, Float128VectorTests::fma);4133}413441354136@Test(dataProvider = "floatTernaryOpMaskProvider")4137static void FMAFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<float[]> fb,4138IntFunction<float[]> fc, IntFunction<boolean[]> fm) {4139float[] a = fa.apply(SPECIES.length());4140float[] b = fb.apply(SPECIES.length());4141float[] c = fc.apply(SPECIES.length());4142float[] r = fr.apply(SPECIES.length());4143boolean[] mask = fm.apply(SPECIES.length());4144VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);41454146for (int ic = 0; ic < INVOC_COUNT; ic++) {4147for (int i = 0; i < a.length; i += SPECIES.length()) {4148FloatVector av = FloatVector.fromArray(SPECIES, a, i);4149FloatVector bv = FloatVector.fromArray(SPECIES, b, i);4150FloatVector cv = FloatVector.fromArray(SPECIES, c, i);4151av.lanewise(VectorOperators.FMA, bv, cv, vmask).intoArray(r, i);4152}4153}41544155assertArraysEquals(r, a, b, c, mask, Float128VectorTests::FMA);4156}415741584159416041614162@Test(dataProvider = "floatTernaryOpProvider")4163static void FMAFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb, IntFunction<float[]> fc) {4164float[] a = fa.apply(SPECIES.length());4165float[] b = fb.apply(SPECIES.length());4166float[] c = fc.apply(SPECIES.length());4167float[] r = fr.apply(SPECIES.length());41684169for (int i = 0; i < a.length; i += SPECIES.length()) {4170FloatVector av = FloatVector.fromArray(SPECIES, a, i);4171FloatVector bv = FloatVector.fromArray(SPECIES, b, i);4172av.lanewise(VectorOperators.FMA, bv, c[i]).intoArray(r, i);4173}4174assertBroadcastArraysEquals(r, a, b, c, Float128VectorTests::FMA);4175}41764177@Test(dataProvider = "floatTernaryOpProvider")4178static void FMAFloat128VectorTestsAltBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb, IntFunction<float[]> fc) {4179float[] a = fa.apply(SPECIES.length());4180float[] b = fb.apply(SPECIES.length());4181float[] c = fc.apply(SPECIES.length());4182float[] r = fr.apply(SPECIES.length());41834184for (int i = 0; i < a.length; i += SPECIES.length()) {4185FloatVector av = FloatVector.fromArray(SPECIES, a, i);4186FloatVector cv = FloatVector.fromArray(SPECIES, c, i);4187av.lanewise(VectorOperators.FMA, b[i], cv).intoArray(r, i);4188}4189assertAltBroadcastArraysEquals(r, a, b, c, Float128VectorTests::FMA);4190}419141924193@Test(dataProvider = "floatTernaryOpMaskProvider")4194static void FMAFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb,4195IntFunction<float[]> fc, IntFunction<boolean[]> fm) {4196float[] a = fa.apply(SPECIES.length());4197float[] b = fb.apply(SPECIES.length());4198float[] c = fc.apply(SPECIES.length());4199float[] r = fr.apply(SPECIES.length());4200boolean[] mask = fm.apply(SPECIES.length());4201VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);42024203for (int i = 0; i < a.length; i += SPECIES.length()) {4204FloatVector av = FloatVector.fromArray(SPECIES, a, i);4205FloatVector bv = FloatVector.fromArray(SPECIES, b, i);4206av.lanewise(VectorOperators.FMA, bv, c[i], vmask).intoArray(r, i);4207}42084209assertBroadcastArraysEquals(r, a, b, c, mask, Float128VectorTests::FMA);4210}42114212@Test(dataProvider = "floatTernaryOpMaskProvider")4213static void FMAFloat128VectorTestsAltBroadcastMaskedSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb,4214IntFunction<float[]> fc, IntFunction<boolean[]> fm) {4215float[] a = fa.apply(SPECIES.length());4216float[] b = fb.apply(SPECIES.length());4217float[] c = fc.apply(SPECIES.length());4218float[] r = fr.apply(SPECIES.length());4219boolean[] mask = fm.apply(SPECIES.length());4220VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);42214222for (int i = 0; i < a.length; i += SPECIES.length()) {4223FloatVector av = FloatVector.fromArray(SPECIES, a, i);4224FloatVector cv = FloatVector.fromArray(SPECIES, c, i);4225av.lanewise(VectorOperators.FMA, b[i], cv, vmask).intoArray(r, i);4226}42274228assertAltBroadcastArraysEquals(r, a, b, c, mask, Float128VectorTests::FMA);4229}42304231423242334234@Test(dataProvider = "floatTernaryOpProvider")4235static void FMAFloat128VectorTestsDoubleBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb, IntFunction<float[]> fc) {4236float[] a = fa.apply(SPECIES.length());4237float[] b = fb.apply(SPECIES.length());4238float[] c = fc.apply(SPECIES.length());4239float[] r = fr.apply(SPECIES.length());42404241for (int i = 0; i < a.length; i += SPECIES.length()) {4242FloatVector av = FloatVector.fromArray(SPECIES, a, i);4243av.lanewise(VectorOperators.FMA, b[i], c[i]).intoArray(r, i);4244}42454246assertDoubleBroadcastArraysEquals(r, a, b, c, Float128VectorTests::FMA);4247}4248@Test(dataProvider = "floatTernaryOpProvider")4249static void fmaFloat128VectorTestsDoubleBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb, IntFunction<float[]> fc) {4250float[] a = fa.apply(SPECIES.length());4251float[] b = fb.apply(SPECIES.length());4252float[] c = fc.apply(SPECIES.length());4253float[] r = fr.apply(SPECIES.length());42544255for (int i = 0; i < a.length; i += SPECIES.length()) {4256FloatVector av = FloatVector.fromArray(SPECIES, a, i);4257av.fma(b[i], c[i]).intoArray(r, i);4258}42594260assertDoubleBroadcastArraysEquals(r, a, b, c, Float128VectorTests::fma);4261}426242634264@Test(dataProvider = "floatTernaryOpMaskProvider")4265static void FMAFloat128VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb,4266IntFunction<float[]> fc, IntFunction<boolean[]> fm) {4267float[] a = fa.apply(SPECIES.length());4268float[] b = fb.apply(SPECIES.length());4269float[] c = fc.apply(SPECIES.length());4270float[] r = fr.apply(SPECIES.length());4271boolean[] mask = fm.apply(SPECIES.length());4272VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);42734274for (int i = 0; i < a.length; i += SPECIES.length()) {4275FloatVector av = FloatVector.fromArray(SPECIES, a, i);4276av.lanewise(VectorOperators.FMA, b[i], c[i], vmask).intoArray(r, i);4277}42784279assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Float128VectorTests::FMA);4280}42814282428342844285static float NEG(float a) {4286return (float)(-((float)a));4287}42884289static float neg(float a) {4290return (float)(-((float)a));4291}42924293@Test(dataProvider = "floatUnaryOpProvider")4294static void NEGFloat128VectorTests(IntFunction<float[]> fa) {4295float[] a = fa.apply(SPECIES.length());4296float[] r = fr.apply(SPECIES.length());42974298for (int ic = 0; ic < INVOC_COUNT; ic++) {4299for (int i = 0; i < a.length; i += SPECIES.length()) {4300FloatVector av = FloatVector.fromArray(SPECIES, a, i);4301av.lanewise(VectorOperators.NEG).intoArray(r, i);4302}4303}43044305assertArraysEquals(r, a, Float128VectorTests::NEG);4306}43074308@Test(dataProvider = "floatUnaryOpProvider")4309static void negFloat128VectorTests(IntFunction<float[]> fa) {4310float[] a = fa.apply(SPECIES.length());4311float[] r = fr.apply(SPECIES.length());43124313for (int ic = 0; ic < INVOC_COUNT; ic++) {4314for (int i = 0; i < a.length; i += SPECIES.length()) {4315FloatVector av = FloatVector.fromArray(SPECIES, a, i);4316av.neg().intoArray(r, i);4317}4318}43194320assertArraysEquals(r, a, Float128VectorTests::neg);4321}43224323@Test(dataProvider = "floatUnaryOpMaskProvider")4324static void NEGMaskedFloat128VectorTests(IntFunction<float[]> fa,4325IntFunction<boolean[]> fm) {4326float[] a = fa.apply(SPECIES.length());4327float[] r = fr.apply(SPECIES.length());4328boolean[] mask = fm.apply(SPECIES.length());4329VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);43304331for (int ic = 0; ic < INVOC_COUNT; ic++) {4332for (int i = 0; i < a.length; i += SPECIES.length()) {4333FloatVector av = FloatVector.fromArray(SPECIES, a, i);4334av.lanewise(VectorOperators.NEG, vmask).intoArray(r, i);4335}4336}43374338assertArraysEquals(r, a, mask, Float128VectorTests::NEG);4339}43404341static float ABS(float a) {4342return (float)(Math.abs((float)a));4343}43444345static float abs(float a) {4346return (float)(Math.abs((float)a));4347}43484349@Test(dataProvider = "floatUnaryOpProvider")4350static void ABSFloat128VectorTests(IntFunction<float[]> fa) {4351float[] a = fa.apply(SPECIES.length());4352float[] r = fr.apply(SPECIES.length());43534354for (int ic = 0; ic < INVOC_COUNT; ic++) {4355for (int i = 0; i < a.length; i += SPECIES.length()) {4356FloatVector av = FloatVector.fromArray(SPECIES, a, i);4357av.lanewise(VectorOperators.ABS).intoArray(r, i);4358}4359}43604361assertArraysEquals(r, a, Float128VectorTests::ABS);4362}43634364@Test(dataProvider = "floatUnaryOpProvider")4365static void absFloat128VectorTests(IntFunction<float[]> fa) {4366float[] a = fa.apply(SPECIES.length());4367float[] r = fr.apply(SPECIES.length());43684369for (int ic = 0; ic < INVOC_COUNT; ic++) {4370for (int i = 0; i < a.length; i += SPECIES.length()) {4371FloatVector av = FloatVector.fromArray(SPECIES, a, i);4372av.abs().intoArray(r, i);4373}4374}43754376assertArraysEquals(r, a, Float128VectorTests::abs);4377}43784379@Test(dataProvider = "floatUnaryOpMaskProvider")4380static void ABSMaskedFloat128VectorTests(IntFunction<float[]> fa,4381IntFunction<boolean[]> fm) {4382float[] a = fa.apply(SPECIES.length());4383float[] r = fr.apply(SPECIES.length());4384boolean[] mask = fm.apply(SPECIES.length());4385VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);43864387for (int ic = 0; ic < INVOC_COUNT; ic++) {4388for (int i = 0; i < a.length; i += SPECIES.length()) {4389FloatVector av = FloatVector.fromArray(SPECIES, a, i);4390av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);4391}4392}43934394assertArraysEquals(r, a, mask, Float128VectorTests::ABS);4395}439643974398439944004401440244034404static float SQRT(float a) {4405return (float)(Math.sqrt((double)a));4406}44074408static float sqrt(float a) {4409return (float)(Math.sqrt((double)a));4410}4411441244134414@Test(dataProvider = "floatUnaryOpProvider")4415static void SQRTFloat128VectorTests(IntFunction<float[]> fa) {4416float[] a = fa.apply(SPECIES.length());4417float[] r = fr.apply(SPECIES.length());44184419for (int ic = 0; ic < INVOC_COUNT; ic++) {4420for (int i = 0; i < a.length; i += SPECIES.length()) {4421FloatVector av = FloatVector.fromArray(SPECIES, a, i);4422av.lanewise(VectorOperators.SQRT).intoArray(r, i);4423}4424}44254426assertArraysEquals(r, a, Float128VectorTests::SQRT);4427}44284429@Test(dataProvider = "floatUnaryOpProvider")4430static void sqrtFloat128VectorTests(IntFunction<float[]> fa) {4431float[] a = fa.apply(SPECIES.length());4432float[] r = fr.apply(SPECIES.length());44334434for (int ic = 0; ic < INVOC_COUNT; ic++) {4435for (int i = 0; i < a.length; i += SPECIES.length()) {4436FloatVector av = FloatVector.fromArray(SPECIES, a, i);4437av.sqrt().intoArray(r, i);4438}4439}44404441assertArraysEquals(r, a, Float128VectorTests::sqrt);4442}4443444444454446@Test(dataProvider = "floatUnaryOpMaskProvider")4447static void SQRTMaskedFloat128VectorTests(IntFunction<float[]> fa,4448IntFunction<boolean[]> fm) {4449float[] a = fa.apply(SPECIES.length());4450float[] r = fr.apply(SPECIES.length());4451boolean[] mask = fm.apply(SPECIES.length());4452VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);44534454for (int ic = 0; ic < INVOC_COUNT; ic++) {4455for (int i = 0; i < a.length; i += SPECIES.length()) {4456FloatVector av = FloatVector.fromArray(SPECIES, a, i);4457av.lanewise(VectorOperators.SQRT, vmask).intoArray(r, i);4458}4459}44604461assertArraysEquals(r, a, mask, Float128VectorTests::SQRT);4462}44634464static float[] gather(float a[], int ix, int[] b, int iy) {4465float[] res = new float[SPECIES.length()];4466for (int i = 0; i < SPECIES.length(); i++) {4467int bi = iy + i;4468res[i] = a[b[bi] + ix];4469}4470return res;4471}44724473@Test(dataProvider = "floatUnaryOpIndexProvider")4474static void gatherFloat128VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {4475float[] a = fa.apply(SPECIES.length());4476int[] b = fs.apply(a.length, SPECIES.length());4477float[] r = new float[a.length];44784479for (int ic = 0; ic < INVOC_COUNT; ic++) {4480for (int i = 0; i < a.length; i += SPECIES.length()) {4481FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i);4482av.intoArray(r, i);4483}4484}44854486assertArraysEquals(r, a, b, Float128VectorTests::gather);4487}4488static float[] gatherMasked(float a[], int ix, boolean[] mask, int[] b, int iy) {4489float[] res = new float[SPECIES.length()];4490for (int i = 0; i < SPECIES.length(); i++) {4491int bi = iy + i;4492if (mask[i]) {4493res[i] = a[b[bi] + ix];4494}4495}4496return res;4497}44984499@Test(dataProvider = "floatUnaryMaskedOpIndexProvider")4500static void gatherMaskedFloat128VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {4501float[] a = fa.apply(SPECIES.length());4502int[] b = fs.apply(a.length, SPECIES.length());4503float[] r = new float[a.length];4504boolean[] mask = fm.apply(SPECIES.length());4505VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);45064507for (int ic = 0; ic < INVOC_COUNT; ic++) {4508for (int i = 0; i < a.length; i += SPECIES.length()) {4509FloatVector av = FloatVector.fromArray(SPECIES, a, i, b, i, vmask);4510av.intoArray(r, i);4511}4512}45134514assertArraysEquals(r, a, b, mask, Float128VectorTests::gatherMasked);4515}45164517static float[] scatter(float a[], int ix, int[] b, int iy) {4518float[] res = new float[SPECIES.length()];4519for (int i = 0; i < SPECIES.length(); i++) {4520int bi = iy + i;4521res[b[bi]] = a[i + ix];4522}4523return res;4524}45254526@Test(dataProvider = "floatUnaryOpIndexProvider")4527static void scatterFloat128VectorTests(IntFunction<float[]> fa, BiFunction<Integer,Integer,int[]> fs) {4528float[] a = fa.apply(SPECIES.length());4529int[] b = fs.apply(a.length, SPECIES.length());4530float[] r = new float[a.length];45314532for (int ic = 0; ic < INVOC_COUNT; ic++) {4533for (int i = 0; i < a.length; i += SPECIES.length()) {4534FloatVector av = FloatVector.fromArray(SPECIES, a, i);4535av.intoArray(r, i, b, i);4536}4537}45384539assertArraysEquals(r, a, b, Float128VectorTests::scatter);4540}45414542static float[] scatterMasked(float r[], float a[], int ix, boolean[] mask, int[] b, int iy) {4543// First, gather r.4544float[] oldVal = gather(r, ix, b, iy);4545float[] newVal = new float[SPECIES.length()];45464547// Second, blending it with a.4548for (int i = 0; i < SPECIES.length(); i++) {4549newVal[i] = blend(oldVal[i], a[i+ix], mask[i]);4550}45514552// Third, scatter: copy old value of r, and scatter it manually.4553float[] res = Arrays.copyOfRange(r, ix, ix+SPECIES.length());4554for (int i = 0; i < SPECIES.length(); i++) {4555int bi = iy + i;4556res[b[bi]] = newVal[i];4557}45584559return res;4560}45614562@Test(dataProvider = "scatterMaskedOpIndexProvider")4563static void scatterMaskedFloat128VectorTests(IntFunction<float[]> fa, IntFunction<float[]> fb, BiFunction<Integer,Integer,int[]> fs, IntFunction<boolean[]> fm) {4564float[] a = fa.apply(SPECIES.length());4565int[] b = fs.apply(a.length, SPECIES.length());4566float[] r = fb.apply(SPECIES.length());4567boolean[] mask = fm.apply(SPECIES.length());4568VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);45694570for (int ic = 0; ic < INVOC_COUNT; ic++) {4571for (int i = 0; i < a.length; i += SPECIES.length()) {4572FloatVector av = FloatVector.fromArray(SPECIES, a, i);4573av.intoArray(r, i, b, i, vmask);4574}4575}45764577assertArraysEquals(r, a, b, mask, Float128VectorTests::scatterMasked);4578}457945804581@Test(dataProvider = "floatCompareOpProvider")4582static void ltFloat128VectorTestsBroadcastSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {4583float[] a = fa.apply(SPECIES.length());4584float[] b = fb.apply(SPECIES.length());45854586for (int i = 0; i < a.length; i += SPECIES.length()) {4587FloatVector av = FloatVector.fromArray(SPECIES, a, i);4588VectorMask<Float> mv = av.lt(b[i]);45894590// Check results as part of computation.4591for (int j = 0; j < SPECIES.length(); j++) {4592Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);4593}4594}4595}45964597@Test(dataProvider = "floatCompareOpProvider")4598static void eqFloat128VectorTestsBroadcastMaskedSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb) {4599float[] a = fa.apply(SPECIES.length());4600float[] b = fb.apply(SPECIES.length());46014602for (int i = 0; i < a.length; i += SPECIES.length()) {4603FloatVector av = FloatVector.fromArray(SPECIES, a, i);4604VectorMask<Float> mv = av.eq(b[i]);46054606// Check results as part of computation.4607for (int j = 0; j < SPECIES.length(); j++) {4608Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);4609}4610}4611}46124613@Test(dataProvider = "floattoIntUnaryOpProvider")4614static void toIntArrayFloat128VectorTestsSmokeTest(IntFunction<float[]> fa) {4615float[] a = fa.apply(SPECIES.length());46164617for (int i = 0; i < a.length; i += SPECIES.length()) {4618FloatVector av = FloatVector.fromArray(SPECIES, a, i);4619int[] r = av.toIntArray();4620assertArraysEquals(r, a, i);4621}4622}46234624@Test(dataProvider = "floattoLongUnaryOpProvider")4625static void toLongArrayFloat128VectorTestsSmokeTest(IntFunction<float[]> fa) {4626float[] a = fa.apply(SPECIES.length());46274628for (int i = 0; i < a.length; i += SPECIES.length()) {4629FloatVector av = FloatVector.fromArray(SPECIES, a, i);4630long[] r = av.toLongArray();4631assertArraysEquals(r, a, i);4632}4633}46344635@Test(dataProvider = "floatUnaryOpProvider")4636static void toDoubleArrayFloat128VectorTestsSmokeTest(IntFunction<float[]> fa) {4637float[] a = fa.apply(SPECIES.length());46384639for (int i = 0; i < a.length; i += SPECIES.length()) {4640FloatVector av = FloatVector.fromArray(SPECIES, a, i);4641double[] r = av.toDoubleArray();4642assertArraysEquals(r, a, i);4643}4644}46454646@Test(dataProvider = "floatUnaryOpProvider")4647static void toStringFloat128VectorTestsSmokeTest(IntFunction<float[]> fa) {4648float[] a = fa.apply(SPECIES.length());46494650for (int i = 0; i < a.length; i += SPECIES.length()) {4651FloatVector av = FloatVector.fromArray(SPECIES, a, i);4652String str = av.toString();46534654float subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());4655Assert.assertTrue(str.equals(Arrays.toString(subarr)), "at index " + i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);4656}4657}46584659@Test(dataProvider = "floatUnaryOpProvider")4660static void hashCodeFloat128VectorTestsSmokeTest(IntFunction<float[]> fa) {4661float[] a = fa.apply(SPECIES.length());46624663for (int i = 0; i < a.length; i += SPECIES.length()) {4664FloatVector av = FloatVector.fromArray(SPECIES, a, i);4665int hash = av.hashCode();46664667float subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());4668int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));4669Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);4670}4671}467246734674static long ADDReduceLong(float[] a, int idx) {4675float res = 0;4676for (int i = idx; i < (idx + SPECIES.length()); i++) {4677res += a[i];4678}46794680return (long)res;4681}46824683static long ADDReduceAllLong(float[] a) {4684long res = 0;4685for (int i = 0; i < a.length; i += SPECIES.length()) {4686res += ADDReduceLong(a, i);4687}46884689return res;4690}46914692@Test(dataProvider = "floatUnaryOpProvider")4693static void ADDReduceLongFloat128VectorTests(IntFunction<float[]> fa) {4694float[] a = fa.apply(SPECIES.length());4695long[] r = lfr.apply(SPECIES.length());4696long ra = 0;46974698for (int i = 0; i < a.length; i += SPECIES.length()) {4699FloatVector av = FloatVector.fromArray(SPECIES, a, i);4700r[i] = av.reduceLanesToLong(VectorOperators.ADD);4701}47024703ra = 0;4704for (int i = 0; i < a.length; i ++) {4705ra += r[i];4706}47074708assertReductionLongArraysEquals(r, ra, a,4709Float128VectorTests::ADDReduceLong, Float128VectorTests::ADDReduceAllLong);4710}47114712static long ADDReduceLongMasked(float[] a, int idx, boolean[] mask) {4713float res = 0;4714for (int i = idx; i < (idx + SPECIES.length()); i++) {4715if(mask[i % SPECIES.length()])4716res += a[i];4717}47184719return (long)res;4720}47214722static long ADDReduceAllLongMasked(float[] a, boolean[] mask) {4723long res = 0;4724for (int i = 0; i < a.length; i += SPECIES.length()) {4725res += ADDReduceLongMasked(a, i, mask);4726}47274728return res;4729}47304731@Test(dataProvider = "floatUnaryOpMaskProvider")4732static void ADDReduceLongFloat128VectorTestsMasked(IntFunction<float[]> fa, IntFunction<boolean[]> fm) {4733float[] a = fa.apply(SPECIES.length());4734long[] r = lfr.apply(SPECIES.length());4735boolean[] mask = fm.apply(SPECIES.length());4736VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);4737long ra = 0;47384739for (int i = 0; i < a.length; i += SPECIES.length()) {4740FloatVector av = FloatVector.fromArray(SPECIES, a, i);4741r[i] = av.reduceLanesToLong(VectorOperators.ADD, vmask);4742}47434744ra = 0;4745for (int i = 0; i < a.length; i ++) {4746ra += r[i];4747}47484749assertReductionLongArraysEqualsMasked(r, ra, a, mask,4750Float128VectorTests::ADDReduceLongMasked, Float128VectorTests::ADDReduceAllLongMasked);4751}47524753@Test(dataProvider = "floattoLongUnaryOpProvider")4754static void BroadcastLongFloat128VectorTestsSmokeTest(IntFunction<float[]> fa) {4755float[] a = fa.apply(SPECIES.length());4756float[] r = new float[a.length];47574758for (int i = 0; i < a.length; i += SPECIES.length()) {4759FloatVector.broadcast(SPECIES, (long)a[i]).intoArray(r, i);4760}4761assertBroadcastArraysEquals(r, a);4762}47634764@Test(dataProvider = "floatBinaryOpMaskProvider")4765static void blendFloat128VectorTestsBroadcastLongSmokeTest(IntFunction<float[]> fa, IntFunction<float[]> fb,4766IntFunction<boolean[]> fm) {4767float[] a = fa.apply(SPECIES.length());4768float[] b = fb.apply(SPECIES.length());4769float[] r = fr.apply(SPECIES.length());4770boolean[] mask = fm.apply(SPECIES.length());4771VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);47724773for (int ic = 0; ic < INVOC_COUNT; ic++) {4774for (int i = 0; i < a.length; i += SPECIES.length()) {4775FloatVector av = FloatVector.fromArray(SPECIES, a, i);4776av.blend((long)b[i], vmask).intoArray(r, i);4777}4778}4779assertBroadcastLongArraysEquals(r, a, b, mask, Float128VectorTests::blend);4780}478147824783@Test(dataProvider = "floatUnaryOpSelectFromProvider")4784static void SelectFromFloat128VectorTests(IntFunction<float[]> fa,4785BiFunction<Integer,Integer,float[]> fs) {4786float[] a = fa.apply(SPECIES.length());4787float[] order = fs.apply(a.length, SPECIES.length());4788float[] r = fr.apply(SPECIES.length());47894790for (int i = 0; i < a.length; i += SPECIES.length()) {4791FloatVector av = FloatVector.fromArray(SPECIES, a, i);4792FloatVector bv = FloatVector.fromArray(SPECIES, order, i);4793bv.selectFrom(av).intoArray(r, i);4794}47954796assertSelectFromArraysEquals(r, a, order, SPECIES.length());4797}47984799@Test(dataProvider = "floatUnaryOpSelectFromMaskProvider")4800static void SelectFromFloat128VectorTestsMaskedSmokeTest(IntFunction<float[]> fa,4801BiFunction<Integer,Integer,float[]> fs,4802IntFunction<boolean[]> fm) {4803float[] a = fa.apply(SPECIES.length());4804float[] order = fs.apply(a.length, SPECIES.length());4805float[] r = fr.apply(SPECIES.length());4806boolean[] mask = fm.apply(SPECIES.length());4807VectorMask<Float> vmask = VectorMask.fromArray(SPECIES, mask, 0);48084809for (int i = 0; i < a.length; i += SPECIES.length()) {4810FloatVector av = FloatVector.fromArray(SPECIES, a, i);4811FloatVector bv = FloatVector.fromArray(SPECIES, order, i);4812bv.selectFrom(av, vmask).intoArray(r, i);4813}48144815assertSelectFromArraysEquals(r, a, order, mask, SPECIES.length());4816}48174818@Test(dataProvider = "shuffleProvider")4819static void shuffleMiscellaneousFloat128VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {4820int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());48214822for (int i = 0; i < a.length; i += SPECIES.length()) {4823var shuffle = VectorShuffle.fromArray(SPECIES, a, i);4824int hash = shuffle.hashCode();4825int length = shuffle.length();48264827int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());4828int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));4829Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);4830Assert.assertEquals(length, SPECIES.length());4831}4832}48334834@Test(dataProvider = "shuffleProvider")4835static void shuffleToStringFloat128VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fs) {4836int[] a = fs.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());48374838for (int i = 0; i < a.length; i += SPECIES.length()) {4839var shuffle = VectorShuffle.fromArray(SPECIES, a, i);4840String str = shuffle.toString();48414842int subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());4843Assert.assertTrue(str.equals("Shuffle" + Arrays.toString(subarr)), "at index " +4844i + ", string should be = " + Arrays.toString(subarr) + ", but is = " + str);4845}4846}48474848@Test(dataProvider = "shuffleCompareOpProvider")4849static void shuffleEqualsFloat128VectorTestsSmokeTest(BiFunction<Integer,Integer,int[]> fa, BiFunction<Integer,Integer,int[]> fb) {4850int[] a = fa.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());4851int[] b = fb.apply(SPECIES.length() * BUFFER_REPS, SPECIES.length());48524853for (int i = 0; i < a.length; i += SPECIES.length()) {4854var av = VectorShuffle.fromArray(SPECIES, a, i);4855var bv = VectorShuffle.fromArray(SPECIES, b, i);4856boolean eq = av.equals(bv);4857int to = i + SPECIES.length();4858Assert.assertEquals(eq, Arrays.equals(a, i, to, b, i, to));4859}4860}48614862@Test(dataProvider = "maskCompareOpProvider")4863static void maskEqualsFloat128VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {4864boolean[] a = fa.apply(SPECIES.length());4865boolean[] b = fb.apply(SPECIES.length());48664867for (int i = 0; i < a.length; i += SPECIES.length()) {4868var av = SPECIES.loadMask(a, i);4869var bv = SPECIES.loadMask(b, i);4870boolean equals = av.equals(bv);4871int to = i + SPECIES.length();4872Assert.assertEquals(equals, Arrays.equals(a, i, to, b, i, to));4873}4874}48754876static boolean beq(boolean a, boolean b) {4877return (a == b);4878}48794880@Test(dataProvider = "maskCompareOpProvider")4881static void maskEqFloat128VectorTestsSmokeTest(IntFunction<boolean[]> fa, IntFunction<boolean[]> fb) {4882boolean[] a = fa.apply(SPECIES.length());4883boolean[] b = fb.apply(SPECIES.length());4884boolean[] r = new boolean[a.length];48854886for (int i = 0; i < a.length; i += SPECIES.length()) {4887var av = SPECIES.loadMask(a, i);4888var bv = SPECIES.loadMask(b, i);4889var cv = av.eq(bv);4890cv.intoArray(r, i);4891}4892assertArraysEquals(r, a, b, Float128VectorTests::beq);4893}48944895@Test(dataProvider = "maskProvider")4896static void maskHashCodeFloat128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {4897boolean[] a = fa.apply(SPECIES.length());48984899for (int i = 0; i < a.length; i += SPECIES.length()) {4900var vmask = SPECIES.loadMask(a, i);4901int hash = vmask.hashCode();49024903boolean subarr[] = Arrays.copyOfRange(a, i, i + SPECIES.length());4904int expectedHash = Objects.hash(SPECIES, Arrays.hashCode(subarr));4905Assert.assertTrue(hash == expectedHash, "at index " + i + ", hash should be = " + expectedHash + ", but is = " + hash);4906}4907}49084909@Test(dataProvider = "maskProvider")4910static void maskTrueCountFloat128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {4911boolean[] a = fa.apply(SPECIES.length());49124913for (int i = 0; i < a.length; i += SPECIES.length()) {4914var vmask = SPECIES.loadMask(a, i);4915int tcount = vmask.trueCount();4916int expectedTcount = 0;4917for (int j = i; j < i + SPECIES.length(); j++) {4918expectedTcount += a[j] ? 1 : 0;4919}4920Assert.assertTrue(tcount == expectedTcount, "at index " + i + ", trueCount should be = " + expectedTcount + ", but is = " + tcount);4921}4922}49234924@Test(dataProvider = "maskProvider")4925static void maskLastTrueFloat128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {4926boolean[] a = fa.apply(SPECIES.length());49274928for (int i = 0; i < a.length; i += SPECIES.length()) {4929var vmask = SPECIES.loadMask(a, i);4930int ltrue = vmask.lastTrue();4931int j = i + SPECIES.length() - 1;4932for (; j >= i; j--) {4933if (a[j]) break;4934}4935int expectedLtrue = j - i;49364937Assert.assertTrue(ltrue == expectedLtrue, "at index " + i +4938", lastTrue should be = " + expectedLtrue + ", but is = " + ltrue);4939}4940}49414942@Test(dataProvider = "maskProvider")4943static void maskFirstTrueFloat128VectorTestsSmokeTest(IntFunction<boolean[]> fa) {4944boolean[] a = fa.apply(SPECIES.length());49454946for (int i = 0; i < a.length; i += SPECIES.length()) {4947var vmask = SPECIES.loadMask(a, i);4948int ftrue = vmask.firstTrue();4949int j = i;4950for (; j < i + SPECIES.length() ; j++) {4951if (a[j]) break;4952}4953int expectedFtrue = j - i;49544955Assert.assertTrue(ftrue == expectedFtrue, "at index " + i +4956", firstTrue should be = " + expectedFtrue + ", but is = " + ftrue);4957}4958}49594960@DataProvider4961public static Object[][] longMaskProvider() {4962return new Object[][]{4963{0xFFFFFFFFFFFFFFFFL},4964{0x0000000000000000L},4965{0x5555555555555555L},4966{0x0123456789abcdefL},4967};4968}49694970@Test(dataProvider = "longMaskProvider")4971static void maskFromToLongFloat128VectorTestsSmokeTest(long inputLong) {4972var vmask = VectorMask.fromLong(SPECIES, inputLong);4973long outputLong = vmask.toLong();4974Assert.assertEquals(outputLong, inputLong & (((1L << (SPECIES.length() - 1)) << 1) - 1));4975}49764977@DataProvider4978public static Object[][] offsetProvider() {4979return new Object[][]{4980{0},4981{-1},4982{+1},4983{+2},4984{-2},4985};4986}49874988@Test(dataProvider = "offsetProvider")4989static void indexInRangeFloat128VectorTestsSmokeTest(int offset) {4990int limit = SPECIES.length() * BUFFER_REPS;4991for (int i = 0; i < limit; i += SPECIES.length()) {4992var actualMask = SPECIES.indexInRange(i + offset, limit);4993var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);4994assert(actualMask.equals(expectedMask));4995for (int j = 0; j < SPECIES.length(); j++) {4996int index = i + j + offset;4997Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);4998}4999}5000}50015002@DataProvider5003public static Object[][] lengthProvider() {5004return new Object[][]{5005{0},5006{1},5007{32},5008{37},5009{1024},5010{1024+1},5011{1024+5},5012};5013}50145015@Test(dataProvider = "lengthProvider")5016static void loopBoundFloat128VectorTestsSmokeTest(int length) {5017int actualLoopBound = SPECIES.loopBound(length);5018int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());5019Assert.assertEquals(actualLoopBound, expectedLoopBound);5020}50215022@Test5023static void ElementSizeFloat128VectorTestsSmokeTest() {5024FloatVector av = FloatVector.zero(SPECIES);5025int elsize = av.elementSize();5026Assert.assertEquals(elsize, Float.SIZE);5027}50285029@Test5030static void VectorShapeFloat128VectorTestsSmokeTest() {5031FloatVector av = FloatVector.zero(SPECIES);5032VectorShape vsh = av.shape();5033assert(vsh.equals(VectorShape.S_128_BIT));5034}50355036@Test5037static void ShapeWithLanesFloat128VectorTestsSmokeTest() {5038FloatVector av = FloatVector.zero(SPECIES);5039VectorShape vsh = av.shape();5040VectorSpecies species = vsh.withLanes(float.class);5041assert(species.equals(SPECIES));5042}50435044@Test5045static void ElementTypeFloat128VectorTestsSmokeTest() {5046FloatVector av = FloatVector.zero(SPECIES);5047assert(av.species().elementType() == float.class);5048}50495050@Test5051static void SpeciesElementSizeFloat128VectorTestsSmokeTest() {5052FloatVector av = FloatVector.zero(SPECIES);5053assert(av.species().elementSize() == Float.SIZE);5054}50555056@Test5057static void VectorTypeFloat128VectorTestsSmokeTest() {5058FloatVector av = FloatVector.zero(SPECIES);5059assert(av.species().vectorType() == av.getClass());5060}50615062@Test5063static void WithLanesFloat128VectorTestsSmokeTest() {5064FloatVector av = FloatVector.zero(SPECIES);5065VectorSpecies species = av.species().withLanes(float.class);5066assert(species.equals(SPECIES));5067}50685069@Test5070static void WithShapeFloat128VectorTestsSmokeTest() {5071FloatVector av = FloatVector.zero(SPECIES);5072VectorShape vsh = av.shape();5073VectorSpecies species = av.species().withShape(vsh);5074assert(species.equals(SPECIES));5075}5076}5077507850795080