Skip to content

ipolyzos/java-vector-api-playground

Repository files navigation

Java Vector API Playground

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.

Vector API

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.

Project Structure

  • 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).

Prerequisites

  • Java 17 or later (with preview features enabled)
  • Maven
  • Make

Setup

To set up the project, run:

$ make setup

Compile

To compile the project, run:

$ make compile

Package

To package the project, run:

$ make package

Running Benchmarks

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

Benchmark Results

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:

References

Contributions

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.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published