Oracle and Intel are developing a Java API to add first-class vector, or SIMD (single instruction, multiple data), support to the platform, which could yield big performance gains.
Part of Project Panama, which focuses on interconnecting JVM and native code, the API aims to provide an initial iteration of an incubator module, jdk.incubator.vector
, to express vector computations that compile at runtime to optimal hardware instructions on supported CPU architectures. Plans call for support of the Graal compiler. Goals of the project include:
- Providing a clear and concise API, capable of expressing a wide range of vector computations.
- Reliable runtime compilation and performance on x64 architectures.
- Architecture agnosticism.
- Graceful degradation, in which if a vector computation cannot be fully expressed at runtime as a sequence, either because an x64 architecture does not support some of the instructions or another CPU architecture is not supported, then the Vector API implementation would degrade gracefully but still function. Developers may receive warnings on this.
If Oracle and Intel deliver on their promises, the Java Vector API will provide a mechanism to write complex vector algorithms in Java, using existing support in the HotSpot virtual machine for vectorization. With vector operations, a degree of parallelism lets more work be done in a single CPU cycle. So, significant performance gains are possible. And a user model in the API will make vectorization more predictable, using underlying vector hardware.
At this point, the proposal does not cite a particular release of Java that would be home to the API, though the scope of the project is intended for the standard edition of Java. The project carries a risk that the API may be biased to SIMD on x64 architectures. But other architectures will be taken into account, specifically the ARM Scalar Vector Extension architecture, Oracle and Intel say.