Mandroid
Mandroid

Reputation: 7524

JMH results for Java VectorAPI not as expected

I am trying to benchmark java VectorAPI. Following is my setup:

public class BenchmarkVector {

    static final VectorSpecies<Float> SPECIES = FloatVector.SPECIES_PREFERRED;

    static int size = 10_000_000; // Large dataset
    static float[] array1 = new float[size];
    static float[] array2 = new float[size];

    public static void main(String[] args) throws IOException {
        for (int i = 0; i < size; i++) {
            array1[i] = i * 1.0f;
            array2[i] = i * 2.0f;
        }
        org.openjdk.jmh.Main.main(args);

    }

    @Benchmark
    @BenchmarkMode(Mode.AverageTime)
    @Warmup(iterations = 5, time = 100, timeUnit =  TimeUnit.MILLISECONDS)
    @Measurement(iterations = 5, time = 100, timeUnit =  TimeUnit.MILLISECONDS)
    public static float[] addTwoVectorArrays() {
        var v1 = FloatVector.fromArray(SPECIES, array1, 0);
        var v2 = FloatVector.fromArray(SPECIES, array2, 0);
        var result = v1.add(v2);
        return result.toArray();
    }
}

Benchmarking details are coming up as:

Run progress: 50.00% complete, ETA 00:00:08

Fork: 1 of 5

WARNING: Using incubator modules: jdk.incubator.vector

Warmup Iteration   1: ? 10?? s/op

Warmup Iteration   2: ? 10?? s/op

Warmup Iteration   3: ? 10?? s/op

Warmup Iteration   4: ? 10?? s/op

Warmup Iteration   5: ? 10?? s/op

Iteration   1: ? 10?? s/op

Iteration   2: ? 10?? s/op

Iteration   3: ? 10?? s/op

Iteration   4: ? 10?? s/op

Iteration   5: ? 10?? s/op

Not sure why it shows readings like '? 10?? s/op'?

Compared to this, benchmark for non-vectorapi based code, I get normal results:

Warmup Iteration   5: 0.011 s/op

Iteration   1: 0.011 s/op

Am I missing any configuration here?

Upvotes: 0

Views: 28

Answers (0)

Related Questions