Skip to content

Commit

Permalink
Add a separate option to allow running Panama Vectorization for all t…
Browse files Browse the repository at this point in the history
…ests with suitable C2 defaults (#13351)

This commit adds a separate option, tests.defaultvectorization, to allow running Panama Vectorization for all tests with suitable C2 defaults.

For example:

./gradlew :lucene:core:test -Ptests.defaultvectorization=true
---------

Co-authored-by: Uwe Schindler <[email protected]>
  • Loading branch information
ChrisHegarty and uschindler committed May 10, 2024
1 parent b888652 commit 05ca9d5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 3 additions & 3 deletions gradle/testing/defaults-tests.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ allprojects {
includeInReproLine: false
],
[propName: 'tests.jvmargs',
value: { -> propertyOrEnvOrDefault("tests.jvmargs", "TEST_JVM_ARGS", isCIBuild ? "" : "-XX:TieredStopAtLevel=1 -XX:+UseParallelGC -XX:ActiveProcessorCount=1") },
value: { -> envOrDefault("TEST_JVM_ARGS", (isCIBuild || testsDefaultVectorizationRequested()) ? "" : "-XX:TieredStopAtLevel=1 -XX:+UseParallelGC -XX:ActiveProcessorCount=1") },
description: "Arguments passed to each forked JVM."],
// Other settings.
[propName: 'tests.neverUpToDate', value: true,
Expand All @@ -66,6 +66,8 @@ allprojects {
}
return propertyOrDefault(option.propName, option.value)
}

testsDefaultVectorizationRequested = { -> Boolean.parseBoolean(resolvedTestOption('tests.defaultvectorization') as String) }

testsCwd = file("${buildDir}/tmp/tests-cwd")
testsTmpDir = file(resolvedTestOption("tests.workDir"))
Expand Down Expand Up @@ -116,8 +118,6 @@ allprojects {

ignoreFailures = resolvedTestOption("tests.haltonfailure").toBoolean() == false

jvmArgs Commandline.translateCommandline(resolvedTestOption("tests.jvmargs"))

// Up to JDK-15 we have to enforce --illegal-access=deny, because we want no code to access
// JDK internals; JDK-16 and later will default to deny, see https://openjdk.java.net/jeps/396:
if (rootProject.runtimeJavaVersion < JavaVersion.VERSION_16) {
Expand Down
15 changes: 10 additions & 5 deletions gradle/testing/randomization.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ allprojects {
allprojects {
plugins.withType(JavaPlugin) {
ext {
String randomVectorSize = RandomPicks.randomFrom(new Random(projectSeedLong), ["default", "128", "256", "512"])
testOptions += [
// seed, repetition and amplification.
[propName: 'tests.seed', value: { -> rootSeed }, description: "Sets the master randomization seed."],
Expand Down Expand Up @@ -107,11 +108,13 @@ allprojects {
[propName: 'tests.bwcdir', value: null, description: "Data for backward-compatibility indexes."],
// vectorization related
[propName: 'tests.vectorsize',
value: { ->
RandomPicks.randomFrom(new Random(projectSeedLong), ["128", "256", "512"])
},
description: "Sets preferred vector size in bits."],
[propName: 'tests.forceintegervectors', value: "true", description: "Forces use of integer vectors even when slow."],
value: { -> testsDefaultVectorizationRequested() ? 'default' : randomVectorSize },
description: "Sets preferred vector size in bits."],
[propName: 'tests.forceintegervectors',
value: { -> testsDefaultVectorizationRequested() ? false : (randomVectorSize != 'default') },
description: "Forces use of integer vectors even when slow."],
[propName: 'tests.defaultvectorization', value: false,
description: "Uses defaults for running tests with correct JVM settings to test Panama vectorization (tests.jvmargs, tests.vectorsize, tests.forceintegervectors)."],
]
}
}
Expand Down Expand Up @@ -161,6 +164,8 @@ allprojects {
// and not the test JVM itself.
systemProperties testOptionsResolved

jvmArgs Commandline.translateCommandline(testOptionsResolved['tests.jvmargs'])

if (Boolean.parseBoolean(testOptionsResolved['tests.asserts'])) {
jvmArgs("-ea", "-esa")
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public abstract class VectorizationProvider {
try {
vs =
Stream.ofNullable(System.getProperty("tests.vectorsize"))
.filter(Predicate.not(String::isEmpty))
.filter(Predicate.not(Set.of("", "default")::contains))
.mapToInt(Integer::parseInt)
.findAny();
} catch (
Expand Down

0 comments on commit 05ca9d5

Please sign in to comment.