-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8280120: [IR Framework] Add attribute to @IR to enable/disable IR matching based on the architecture #15938
Conversation
…tures before cpu features; lint new test; tweak tests.
👋 Welcome back danielogh! A progress list of the required criteria for merging this PR into |
@danielogh The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a useful addition, thanks for working on this!
I have a couple of comments but otherwise, it looks good!
"linux", | ||
"mac", | ||
"windows", | ||
// vm.simpleArch values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also support ppc, arm, and s390
@@ -233,6 +278,76 @@ private boolean hasAllRequiredFlags(String[] andRules, String ruleType) { | |||
return returnValue; | |||
} | |||
|
|||
private boolean hasAllRequiredPlatformFeature(String[] andRules) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should try to clean all these different hasAll*/hasAny*/check*
up/unify them at some point. But that's for another day.
* value where a true value necessities existence of platform feature and vice-versa. | ||
* IR verifications checks are enforced only if the specified feature constraint is met. | ||
*/ | ||
String[] applyIfPlatformFeature() default {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can just use the name applyIfPlatform
?
@@ -25,7 +25,6 @@ | |||
* @test | |||
* @bug 8076276 | |||
* @summary Add C2 x86 Superword support for scalar sum reduction optimizations : long test | |||
* @requires vm.bits == "64" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should file a follow-up RFE to check all IR tests that have such a @requires
limitation and see if we could just change some specific rules to use these new constraints in order to let the test pass for all platforms.
@@ -118,6 +118,11 @@ Sometimes, an `@IR` rule should only be applied if a certain CPU feature is pres | |||
|
|||
If a `@Test` annotated method has multiple preconditions (for example `applyIf` and `applyIfCPUFeature`), they are evaluated as a logical conjunction. It's worth noting that flags in `applyIf` are checked only if the CPU features in `applyIfCPUFeature` are matched when they are both specified. This avoids the VM flag being evaluated on hardware that does not support it. An example with both `applyIfCPUFeatureXXX` and `applyIfXXX` can be found in [TestPreconditions](../../../testlibrary_tests/ir_framework/tests/TestPreconditions.java) (internal framework test). | |||
|
|||
#### Disable/Enable IR Rules based on available Platform Features |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just say "platform"?
#### Disable/Enable IR Rules based on available Platform Features | |
#### Disable/Enable IR Rules based on Platform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, modulo issues/comments raised by Christian and a few additional minor comments and suggestions.
It seems the IR test framework's annotation-based precondition language is slowly converging towards jtreg's @requires expressions. In the long run, it would be interesting to investigate whether we could simply reuse the jtreg @requires expression support (as suggested in JDK-8294279).
@@ -108,6 +108,27 @@ | |||
*/ | |||
String[] applyIf() default {}; | |||
|
|||
/** | |||
* Accepts a single feature pair which is composed of platform feature string followed by a true/false | |||
* value where a true value necessities existence of platform feature and vice-versa. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* value where a true value necessities existence of platform feature and vice-versa. | |
* value where a true value necessitates existence of platform feature and vice-versa. |
|
||
/** | ||
* Accepts a list of feature pairs where each pair is composed of target feature string followed by a true/false | ||
* value where a true value necessities existence of target feature and vice-versa. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* value where a true value necessities existence of target feature and vice-versa. | |
* value where a true value necessitates existence of target feature and vice-versa. |
|
||
/** | ||
* Accepts a list of feature pairs where each pair is composed of target feature string followed by a true/false | ||
* value where a true value necessities existence of target feature and vice-versa. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* value where a true value necessities existence of target feature and vice-versa. | |
* value where a true value necessitates existence of target feature and vice-versa. |
/** | ||
* Accepts a list of feature pairs where each pair is composed of target feature string followed by a true/false | ||
* value where a true value necessities existence of target feature and vice-versa. | ||
* IR verifications checks are enforced if any of the specified feature constraint is met. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* IR verifications checks are enforced if any of the specified feature constraint is met. | |
* IR verifications checks are enforced if any of the specified feature constraints is met. |
@@ -233,6 +278,76 @@ private boolean hasAllRequiredFlags(String[] andRules, String ruleType) { | |||
return returnValue; | |||
} | |||
|
|||
private boolean hasAllRequiredPlatformFeature(String[] andRules) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename to hasAllRequiredPlatformFeatures
?
} | ||
} | ||
|
||
// IR rule is enforced if all the feature conditions holds good |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// IR rule is enforced if all the feature conditions holds good | |
// IR rule is enforced if all the feature conditions hold good |
applyIfAnd = {"UseSVE", "= 0", "LoopMaxUnroll", "= 0"}, | ||
counts = {IRNode.LOOP, ">= 1000"}) | ||
public static void testApplyBoth4() {} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could complete these tests with a couple more tests that check the evaluation order rules w.r.t. VM flag and CPU feature pre-conditions, something like:
@Test
@IR(applyIfPlatformFeatureAnd = {"x64", "true", "aarch64", "true"},
applyIf = {"UseNonExistingFlag", "true"},
counts = {IRNode.LOOP, ">= 1000"})
public static void testPlatformFeaturePrecedenceOverVMFlags() {}
@Test
@IR(applyIfPlatformFeatureAnd = {"x64", "true", "aarch64", "true"},
applyIfCPUFeature = {"non-existing-cpu-feature", "true"},
counts = {IRNode.LOOP, ">= 1000"})
public static void testPlatformFeaturePrecedenceOverCPUFeatures() {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! We got something similar wrong recently, so this is a must.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: Not necessary
Thanks @chhagedorn for the suggestion. The preconditions read better after renaming. Going over IR tests and removing @requires fields sounds good in order to run tests on all platforms and to consolidate tests. Appreciate the review @robcasloz. I rewrote parts of the documentation and added more tests. Since we are implementing functionality that is similar to jtreg This PR might be ready for another round of reviews. |
The new version looks good. Maybe I missed something, but does any of the newly added tests address my suggestion (https://github.com/openjdk/jdk/pull/15938/files#r1338489724) to check that platform preconditions take precedence over VM flags, i.e. VM flags are not even validated if platform preconditions do not hold? |
Thanks for the review. The intention is that the last four tests in |
Right, thanks for the clarification! |
@danielogh This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 214 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@chhagedorn, @robcasloz, @eme64, @TobiHartmann) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Thanks for doing this, @danielogh ! Update: And I think you don't need to add more IR rules. You already have tests that use VM flags that only exist on certain platforms. Platform features need to be evaluated before VM flags, but not necessarily before CPU features. (just repeating what we discussed offline) Update 2: I filed the follow-up RFE: JDK-8317341 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work, looks good to me :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice enhancement! Looks good to me.
Thanks @eme64 and @TobiHartmann for reviews |
/integrate |
@danielogh |
Thanks for all the work on this, we wanted this for a while! |
Going to push as commit a8549b6.
Your commit was automatically rebased without conflicts. |
@eme64 @danielogh Pushed as commit a8549b6. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This PR adds support for platform features in IR Framework preconditions. This allows us to write platform-specific IR checks in the same .java test file.
Platforms considered in this PR are: operating system, arch, and data model (32 or 64-bit VM). Supported field values correspond to vm.simpleArch, os.family, and vm.bits, as used in jtreg
@requires
fields. We use the Platform library methods to accomplish this. Otherwise, the new preconditions work similar to the corresponding CPUFeature preconditions.Testing: T1-T3, GHA.
Additional testing: Tweaked SW test succeeds with removed
@requires
field and added IR platform precondition, but fails with just removed@requires
field on 32-bit Linux. Performed a few spot tests with incorrectly formatted preconditions, and with valid platform checks but invalid counts.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15938/head:pull/15938
$ git checkout pull/15938
Update a local copy of the PR:
$ git checkout pull/15938
$ git pull https://git.openjdk.org/jdk.git pull/15938/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15938
View PR using the GUI difftool:
$ git pr show -t 15938
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15938.diff
Webrev
Link to Webrev Comment