Skip to content

mandelbrot Java # 7

mandelbrot converted to SIMD using Vector API from OpenJDK's Project Panama mandelbrot.java

To compile: ~/devel/jdk-16/bin/javac --add-modules jdk.incubator.vector mandelbrot.java

To run: ~/devel/jdk-16/bin/java --add-modules jdk.incubator.vector mandelbrot 16000

Note 1: Vector API is in incubator stage, therefore:

  • it prints a warning message to standard error, so you need to filter that out
  • it will change in future Java versions, so code will need adjustments to work
  • it has incomplete performance optimizations, e.g. vector comparisons - I've added a comment explaining my weird way of comparing values with 4

Note 2: Vector API has much longer warmup than ordinary scalar code. Major chunk of time is spent on executing unoptimized code and on JIT optimizations. If you run the code with bigger parameters then you'll see the performance improving as proportionally less time will be spent in unoptimized code and JIT compiler.

If you're OK with incubator level APIs in JDK then maybe I'll prepare more examples using APIs from Project Panama.

Edited by Piotr Tarsa