Skip to content

Any plans to support the Vector API? #380

@Ledmington

Description

@Ledmington

Right now, if you write a simple loop using the Vector API like this:

import jdk.incubator.vector.DoubleVector;
import jdk.incubator.vector.VectorSpecies;
import jdk.incubator.vector.VectorOperators;
import java.util.random.RandomGenerator;
import java.util.random.RandomGeneratorFactory;

final class Main {

    private static final RandomGenerator rng = RandomGeneratorFactory.getDefault().create(System.nanoTime());
    private static final VectorSpecies<Double> species = DoubleVector.SPECIES_PREFERRED;

    public static void main(final String[] args){
        final int length = 100_000;
        final double[] v = new double[length];
        for(int i=0; i<length; i++) {
            v[i] = rng.nextDouble(-1.0, 1.0);
        }

        DoubleVector s = DoubleVector.broadcast(species, 0.0);
        for(int i=0; i<species.loopBound(length); i += species.length()) {
            final DoubleVector vi = DoubleVector.fromArray(species, v, i);
            s = s.add(vi);
        }
        System.out.println(s.reduceLanes(VectorOperators.ADD));
    }
}

JitWatch will show you nothing: not even the source code or the bytecode.

Do you have any plans to support it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions