The aim of this project is to provide a test environment for experimenting with the Java Vector API and simplify the process of running tests and contacting benchmarks. In addition to the benchmarks and tests included in this repository, our goal is to compile documentation and links to key resources that support the efficient and optimal use of the API. We also aim to maintain a record and a library of these valuable sources for future reference.
The primary goals of the Vector API are to provide a platform-independent interface that allows for efficient implementation across various CPU architectures, such as x64 and AArch64, while ensuring consistent runtime compilation and performance. This reliability is crucial for developers to confidently utilize vector operations, with the expectation that they will closely align with hardware vector instructions, such as Streaming SIMD Extensions (SSE) and Advanced Vector Extensions (AVX) on x64, as well as NEON and SVE on AArch64.
The Vector API is designed in such a way to offer developers a straightforward and efficient means of expressing vector computations, which can be compiled at runtime into optimized vector instructions on compatible CPU architectures. This approach enables significantly better performance than traditional scalar computations.
The latest update, proposed for JDK 22, introduces minor improvements and bug fixes, most notably expanding support for vector access to heap MemorySegments backed by arrays of any primitive element type. This marks a substantial enhancement over the previous limitation, which only supported byte arrays, broadening the API's versatility and performance potential.
- src/main/java/main: Contains the main Java source files for the benchmarks.
- pom.xml: Maven configuration file.
- Makefile: Makefile to automate the build process and run benchmarks.
- results: Directory to store benchmark results
NOTE:
Please note that the results
directory is ignored from git as it is auto-generated, also lost with cleanup).
- Java 17 or later (with preview features enabled)
- Maven
- Make
To set up the project, run:
$ make setup
To compile the project, run:
$ make compile
To package the project, run:
$ make package
To run the benchmarks, use the following commands:
- ArrayStats:
$ make run-array-stats
- ArrayStatsNoSuperWord:
$ make run-array-stats-no-super-word
- ComplexExpression:
$ make run-complex-expression
- ComplexExpressionNoSuperWord:
$ make run-complex-expression-no-super-word
- DotProduct:
$ make run-dot-product
- DotProductNoSuperWord:
$ make run-dot-product-no-super-word
- ElementWiseMultiplication:
$ make run-element-wise-multiplication
- ElementWiseMultiplicationNoSuperWord:
$ make run-element-wise-multiplication-no-super-word
- MatrixMultiplication:
$ make run-matrix-multiplication
- MatrixMultiplicationNoSuperWord:
$ make run-matrix-multiplication-no-super-word
- SimpleSum:
$ make run-simple-sum
- SimpleSumNoSuperWord:
$make run-simple-sum-no-super-word
- Sorting:
$ make run-sorting
- SortingNoSuperWord:
$ make run-sorting-no-super-word
- VectorAddition:
make run-vector-addition
- VectorAdditionNoSuperWord:
make run-vector-addition-no-super-word
- MatrixMultiplication:
$ make run-matrix-multiplication
- MatrixMultiplicationNoSuperWord:
$ make run-matrix-multiplication-no-super-word
- All Benchmarks:
$ make run-all
All the benchmarks presented below were run on the same machine with the same specifications as presented in the specific benchmark README.md
file.
The results visualized using the JMH Visualizer and they are the average time taken by the benchmarks to execute. Finaly the warmup and the actual benchmarks were run multiple times (5) to ensure the accuracy of the results and they are stored in the results
directory as .json
files which are ignored from git by default as they are auto-generated (also lost with cleanup).
Here is a list of the benchmarks we have executed so far:
- Java Vector API - JEP-338 - (Incubator, JDK 16)
- Java Vector API - JEP-414 - (Second Incubator, JDK 17)
- Java Vector API - JEP-417 - (Third Incubator, JDK 18)
- Java Vector API - JEP-426 - (Fourth Incubator, JDK 19)
- Java Vector API - JEP-438 - (Fifth Incubator, JDK 20)
- Java Vector API - JEP-448 - (Sixth Incubator, JDK 21)
- Java Vector API - JEP-460 - (Seventh Incubator, JDK 22)
- Java Vector API (Incubator) Documentation
- Java Vector API Documentation
- Java Vector API: A New Era of Vectorization in Java by Baeldung
- Java Vector API on AArch64
- Java’s new Vector API: How fast is it? — Part 1 by Tomer Zeltzer
- Jector math made easy: John Rose and Paul Sandoz on Java’s Vector API
- Vector API: SIMD Programming in Java
- Java Vector API: Benchmarking and Performance Analysis
- Design of a custom vector operation API exploiting SIMD intrinsics within Java
- Vectorization for Java
- JEP 315: Improve Aarch64 Intrinsics
We welcome contributions to the Java Vector API Playground project! If you are interested in contributing, please read our CONTRIBUTIONS guide for detailed instructions on how to get started. Please also adhere to our Code of Conduct in all your interactions with the project.
This project is licensed under the MIT License - see the LICENSE file for details.