Skip to content

Commit

Permalink
8309697: [TESTBUG] Remove "@requires vm.flagless" from jtreg vectoriz…
Browse files Browse the repository at this point in the history
…ation tests

Reviewed-by: kvn, thartmann, epeter, chagedorn
  • Loading branch information
Pengfei Li committed Aug 29, 2023
1 parent e5ea9aa commit a03954e
Show file tree
Hide file tree
Showing 23 changed files with 61 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* -XX:+WhiteBoxAPI
* compiler.vectorization.runner.ArrayCopyTest
*
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* compiler.vectorization.runner.ArrayIndexFillTest
*
* @requires (os.simpleArch == "x64") | (os.simpleArch == "aarch64")
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@
* -XX:+WhiteBoxAPI
* -XX:-OptimizeFill
* compiler.vectorization.runner.ArrayInvariantFillTest
* @run main/othervm -Xbootclasspath/a:.
* -XX:+UnlockDiagnosticVMOptions
* -XX:+WhiteBoxAPI
* -XX:+OptimizeFill
* compiler.vectorization.runner.ArrayInvariantFillTest
*
* @requires (os.simpleArch == "x64") | (os.simpleArch == "aarch64")
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down Expand Up @@ -66,7 +71,11 @@ public ArrayInvariantFillTest() {
// ---------------- Simple Fill ----------------
@Test
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
applyIf = {"OptimizeFill", "false"},
counts = {IRNode.REPLICATE_B, ">0"})
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
applyIf = {"OptimizeFill", "true"},
counts = {IRNode.REPLICATE_B, "0"})
public byte[] fillByteArray() {
byte[] res = new byte[SIZE];
for (int i = 0; i < SIZE; i++) {
Expand All @@ -77,7 +86,11 @@ public byte[] fillByteArray() {

@Test
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
applyIf = {"OptimizeFill", "false"},
counts = {IRNode.REPLICATE_S, ">0"})
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
applyIf = {"OptimizeFill", "true"},
counts = {IRNode.REPLICATE_S, "0"})
public short[] fillShortArray() {
short[] res = new short[SIZE];
for (int i = 0; i < SIZE; i++) {
Expand All @@ -88,7 +101,11 @@ public short[] fillShortArray() {

@Test
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
applyIf = {"OptimizeFill", "false"},
counts = {IRNode.REPLICATE_S, ">0"})
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
applyIf = {"OptimizeFill", "true"},
counts = {IRNode.REPLICATE_S, "0"})
public char[] fillCharArray() {
char[] res = new char[SIZE];
for (int i = 0; i < SIZE; i++) {
Expand All @@ -99,7 +116,11 @@ public char[] fillCharArray() {

@Test
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
applyIf = {"OptimizeFill", "false"},
counts = {IRNode.REPLICATE_I, ">0"})
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
applyIf = {"OptimizeFill", "true"},
counts = {IRNode.REPLICATE_I, "0"})
public int[] fillIntArray() {
int[] res = new int[SIZE];
for (int i = 0; i < SIZE; i++) {
Expand All @@ -121,7 +142,11 @@ public long[] fillLongArray() {

@Test
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
applyIf = {"OptimizeFill", "false"},
counts = {IRNode.REPLICATE_F, ">0"})
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
applyIf = {"OptimizeFill", "true"},
counts = {IRNode.REPLICATE_F, "0"})
public float[] fillFloatArray() {
float[] res = new float[SIZE];
for (int i = 0; i < SIZE; i++) {
Expand Down Expand Up @@ -177,7 +202,11 @@ public long[] fillLongArrayWithFloat() {

@Test
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
applyIf = {"OptimizeFill", "false"},
counts = {IRNode.REPLICATE_I, ">0"})
@IR(applyIfCPUFeatureOr = {"asimd", "true", "sse2", "true"},
applyIf = {"OptimizeFill", "true"},
counts = {IRNode.REPLICATE_I, "0"})
public int[] fillIntArrayWithDouble() {
int[] res = new int[SIZE];
for (int i = 0; i < SIZE; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* compiler.vectorization.runner.ArrayShiftOpTest
*
* @requires (os.simpleArch == "x64") | (os.simpleArch == "aarch64")
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* -XX:+WhiteBoxAPI
* compiler.vectorization.runner.ArrayTypeConvertTest
*
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* -XX:+WhiteBoxAPI
* compiler.vectorization.runner.ArrayUnsafeOpTest
*
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* -XX:+WhiteBoxAPI
* compiler.vectorization.runner.BasicBooleanOpTest
*
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* -XX:LoopUnrollLimit=1000
* compiler.vectorization.runner.BasicByteOpTest
*
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* -XX:+WhiteBoxAPI
* compiler.vectorization.runner.BasicCharOpTest
*
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* compiler.vectorization.runner.BasicDoubleOpTest
*
* @requires (os.simpleArch == "x64") | (os.simpleArch == "aarch64")
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* compiler.vectorization.runner.BasicFloatOpTest
*
* @requires (os.simpleArch == "x64") | (os.simpleArch == "aarch64")
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* -XX:+WhiteBoxAPI
* compiler.vectorization.runner.BasicIntOpTest
*
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* compiler.vectorization.runner.BasicLongOpTest
*
* @requires (os.simpleArch == "x64") | (os.simpleArch == "aarch64")
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* -XX:+WhiteBoxAPI
* compiler.vectorization.runner.BasicShortOpTest
*
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* compiler.vectorization.runner.LoopArrayIndexComputeTest
*
* @requires (os.simpleArch == "x64") | (os.simpleArch == "aarch64")
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down Expand Up @@ -321,7 +321,7 @@ public byte[] byteArrayWithDependencePos() {
byte[] res = new byte[SIZE];
System.arraycopy(bytes, 0, res, 0, SIZE);
for (int i = 0; i < SIZE / 2; i++) {
res[i] *= bytes[i + 3];
res[i] += bytes[i + 3];
}
return res;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* -XX:+WhiteBoxAPI
* compiler.vectorization.runner.LoopCombinedOpTest
*
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* -XX:+WhiteBoxAPI
* compiler.vectorization.runner.LoopControlFlowTest
*
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* -XX:+WhiteBoxAPI
* compiler.vectorization.runner.LoopLiveOutNodesTest
*
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
* -XX:+WhiteBoxAPI
* compiler.vectorization.runner.LoopRangeStrideTest
*
* @requires vm.compiler2.enabled & vm.flagless
* @requires (os.arch=="amd64" | os.arch=="x86_64" | os.simpleArch == "aarch64")
* @requires (os.simpleArch == "x64") | (os.simpleArch == "aarch64")
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* compiler.vectorization.runner.LoopReductionOpTest
*
* @requires (os.simpleArch == "x64") | (os.simpleArch == "aarch64")
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* -XX:+WhiteBoxAPI
* compiler.vectorization.runner.MultipleLoopsTest
*
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* -XX:LoopStripMiningIter=10
* compiler.vectorization.runner.StripMinedLoopTest
*
* @requires vm.compiler2.enabled & vm.flagless
* @requires vm.compiler2.enabled
*/

package compiler.vectorization.runner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,11 @@

import compiler.lib.ir_framework.*;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

import java.io.File;

import jdk.test.lib.Platform;
import jdk.test.lib.Utils;

import jdk.test.whitebox.WhiteBox;
Expand All @@ -51,16 +44,14 @@ public class VectorizationTestRunner {
private static final int NMETHOD_COMP_LEVEL_IDX = 1;
private static final int NMETHOD_INSTS_IDX = 2;

private static final long COMP_THRES_SECONDS = 30;

protected void run() {
Class klass = getClass();

// 1) Vectorization correctness test
// For each method annotated with @Test in the test method, this test runner
// For each method annotated with "@Test" in test classes, this test runner
// invokes it twice - first time in the interpreter and second time compiled
// by C2. Then this runner compares the two return values. Hence we require
// each test method returning a primitive value or an array of primitive type.
// And each test method should not throw any exceptions.
Class klass = getClass();
for (Method method : klass.getDeclaredMethods()) {
try {
if (method.isAnnotationPresent(Test.class)) {
Expand All @@ -77,8 +68,6 @@ protected void run() {
// To test vectorizability, invoke the IR test framework to check existence of
// expected C2 IR node.
TestFramework irTest = new TestFramework(klass);
// Add extra VM options to enable more auto-vectorization chances
irTest.addFlags("-XX:-OptimizeFill");
irTest.start();
}

Expand Down Expand Up @@ -114,26 +103,23 @@ private void runTestOnMethod(Method method) throws InterruptedException {
Object expected = null;
Object actual = null;

// Lock compilation and inovke the method to get reference result from
// the interpreter
WB.lockCompilation();
// Temporarily disable the compiler and invoke the method to get reference
// result from the interpreter
WB.setBooleanVMFlag("UseCompiler", false);
try {
expected = method.invoke(this);
} catch (Exception e) {
e.printStackTrace();
fail("Exception is thrown in test method invocation (interpreter).");
}
assert(WB.getMethodCompilationLevel(method) == COMP_LEVEL_INTP);
WB.unlockCompilation();
WB.setBooleanVMFlag("UseCompiler", true);

// Compile the method and invoke it again
long enqueueTime = System.currentTimeMillis();
WB.enqueueMethodForCompilation(method, COMP_LEVEL_C2);
while (WB.getMethodCompilationLevel(method) != COMP_LEVEL_C2) {
if (System.currentTimeMillis() - enqueueTime > COMP_THRES_SECONDS * 1000) {
fail("Method is not compiled after " + COMP_THRES_SECONDS + "s.");
}
Thread.sleep(50 /*ms*/);
Thread.sleep(100 /*ms*/);
}
try {
actual = method.invoke(this);
Expand Down

1 comment on commit a03954e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.