[vector] tests with data providers

Lupusoru, Razvan A razvan.a.lupusoru at intel.com
Wed Mar 14 22:22:10 UTC 2018


And on that note - sounds like you can merge! Thanks!

--Razvan

-----Original Message-----
From: panama-dev [mailto:panama-dev-bounces at openjdk.java.net] On Behalf Of Halimi, Jean-Philippe
Sent: Wednesday, March 14, 2018 3:20 PM
To: Paul Sandoz <paul.sandoz at oracle.com>
Cc: panama-dev at openjdk.java.net
Subject: RE: [vector] tests with data providers

I see, that's a pretty nice improvement. Thanks for the clarification. Can't wait to try it out on new tests.

Jp

-----Original Message-----
From: Paul Sandoz [mailto:paul.sandoz at oracle.com] 
Sent: Wednesday, March 14, 2018 3:18 PM
To: Halimi, Jean-Philippe <jean-philippe.halimi at intel.com>
Cc: panama-dev at openjdk.java.net
Subject: Re: [vector] tests with data providers



> On Mar 14, 2018, at 2:38 PM, Halimi, Jean-Philippe <jean-philippe.halimi at intel.com> wrote:
> 
> Hi Paul,
> 
> Sorry for the delayed answer. I think the patch looks good! I just have one remark:
> 

Thanks.


> - In Binary-Masked-op.template, is there a reason why you removed the 3 different mask types?
> 

You were proving three hard coded tests in one method and this could be refactored and generalized into data providers. Each of those masks is now defined here:

static final List<IntFunction<boolean[]>> BOOLEAN_MASK_GENERATORS = List.of(
        withToString("mask[i % 2]", (int l) -> {
            boolean[] a = new boolean[l];
            for (int i = 0; i < l; i++) {
                a[i] = (i % 2 == 0);
            }
            return a;
        }),
        withToString("mask[true]", (int l) -> {
            boolean[] a = new boolean[l];
            Arrays.fill(a, true);
            return a;
        }),
        withToString("mask[false]", boolean[]::new) );

Then we create the cross product of those 3 masks with pairs of 2 input arrays to produce the arguments input to the binary operations:

@DataProvider
public Object[][] intBinaryOpMaskProvider() {
    return BOOLEAN_MASK_GENERATORS.stream().
            flatMap(fm -> INT_GENERATOR_PAIRS.stream().map(lfa -> {
                return Stream.concat(lfa.stream(), Stream.of(fm)).toArray();
            })).
            toArray(Object[][]::new);
}

In the test output you should see stuff like:

test Short64VectorTests.subShort64VectorTests(short[i * 5], short[i + 1], mask[i % 2]): success test Short64VectorTests.subShort64VectorTests(short[i * 5], short[i + 1], mask[true]): success test Short64VectorTests.subShort64VectorTests(short[i * 5], short[i + 1], mask[false]): success

Paul.


More information about the panama-dev mailing list