Usage:
The option “-XX:[+|-]UseSuperWord” enables the transformation of scalar operations into superword operations.
Since:
Starting from JDK 6.
Syntax:
java -XX:[+|-]UseSuperWord MainClass
Example:
- To enable the transformation of scalar operations into superword operations: java -XX:+UseSuperWord MainClass
- To disable the transformation of scalar operations into superword operations: java -XX:-UseSuperWord MainClass
Description:
Before introducing the flag, we should explain what is Vectorization and SuperWord level parallelism?
Let’s us start with Vectorization; Vectorization is a method of parallel computing which compiles repetitive program instructions into a single vector. This vector is executed afterwards to speed up program execution. Vectorization can be done by compiler (auto vectorization) or programmer.
In Java, the vectorization is only done by the compiler. After compiling the source code to Java bytecode, the compiler takes into consideration those bytecodes and determine which bloc can be transformed to a vector of instructions.
Example of the benefit of vectorization:
Any code can be converted to vector of instructions if it run the same operations multiple times. Let’s take a look at this code snippet:
List<Integer> numbers = new ArrayList<Integer>();
for (int i = 0; i < 20; i++) {
numbers.add(numbers.get(i) + numbers.get(i));
}
The line inside of the loop get executed many times which will allow the use a vector of instruction to sum multiple results at once instead of doing it individually.
Superword level parallelism (SLP) is a method of traditional vectorization which simplify parallelism across loop iterations, Single Instruction/Multiple Data (SIMD) and basic blocks. Like vectorization, SuperWord allows to achieve parallel processing.
JVM introduced the flag “UseSuperWord” to enable/disable transformation of scalar operations into superword operations.
Default Value:
This option is enabled by default.
Note:
Only the Java HotSpot Server VM supports this option.
Errors:
None.
Related Posts:
Edit your Comment