Skip to content
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

8309894: compiler/vectorapi/VectorLogicalOpIdentityTest.java fails on SVE system with UseSVE=0 #14533

Closed
wants to merge 2 commits into from

Conversation

XiaohongGong
Copy link

@XiaohongGong XiaohongGong commented Jun 19, 2023

This test fails with several IR check failures when run on ARM SVE systems with vm option -XX:UseSVE=0. Here is one of the failed IR rule:

@IR(counts = {IRNode.AND_V, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
public static void testAndMaskSameValue1()

The specified IR in the test depends on the platform's predicate feature. Hence the IR check can be applied only on ARM SVE or X86 AVX512 systems. But with -XX:UseSVE=0 on ARM SVE machines, JVM will disable SVE feature for compiler. But the CPU feature is not changed. To guarantee the IR rule is run with SVE as expected, it has to add another condition like applyIf = {"UseSVE", ">0"}. Consider UseSVE is an ARM specific option, it can be used only on ARM CPUs. So the right IR rules should be:

@IR(counts = {IRNode.AND_V, "1"}, applyIfCPUFeature = {"sve", "true"}, applyIf = {"UseSVE", "> 0"})
@IR(counts = {IRNode.AND_V, "1"}, applyIfCPUFeature = {"avx512", "true"})
public static void testAndMaskSameValue1()

This patch also changes the check order of conditions for a IR rule. It's better to check applyIfCPUFeature before applyIf, in case the vm option is invalid on running hardware, which makes test throw exception and abort.

Verified on X86 systems with UseAVX=1/2/3 by removing the test from ProblemList.txt, and SVE systems with UseSVE=0/1.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8309894: compiler/vectorapi/VectorLogicalOpIdentityTest.java fails on SVE system with UseSVE=0 (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14533/head:pull/14533
$ git checkout pull/14533

Update a local copy of the PR:
$ git checkout pull/14533
$ git pull https://git.openjdk.org/jdk.git pull/14533/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14533

View PR using the GUI difftool:
$ git pr show -t 14533

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14533.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 19, 2023

👋 Welcome back xgong! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 19, 2023
@openjdk
Copy link

openjdk bot commented Jun 19, 2023

@XiaohongGong The following label will be automatically applied to this pull request:

  • hotspot-compiler

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.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Jun 19, 2023
@mlbridge
Copy link

mlbridge bot commented Jun 19, 2023

Webrevs

@eme64
Copy link
Contributor

eme64 commented Jun 21, 2023

@XiaohongGong Thanks for looking into this. But it seems to me this is not the same approach as we are taking with x86 SSE and AVX, where the UseAVX and UseSSE flags affect both the VM features and also the applyIfCPUFeature from the IR framework. We check in all sorts of places for sve feature, so why do you now only change it for this particular test?

if (UseAVX < 2)
_features &= ~CPU_AVX2;

Can you do a similar thing in src/hotspot/cpu/aarch64/vm_version_aarch64.cpp ?

It would be nice not to have to check for the flag and the features in every test, but just for the features. And the features should depend on what is present on the hardware, minus the restrictions by the flags.

@XiaohongGong
Copy link
Author

@XiaohongGong Thanks for looking into this. But it seems to me this is not the same approach as we are taking with x86 SSE and AVX, where the UseAVX and UseSSE flags affect both the VM features and also the applyIfCPUFeature from the IR framework. We check in all sorts of places for sve feature, so why do you now only change it for this particular test?

if (UseAVX < 2)
_features &= ~CPU_AVX2;

Can you do a similar thing in src/hotspot/cpu/aarch64/vm_version_aarch64.cpp ?

It would be nice not to have to check for the flag and the features in every test, but just for the features. And the features should depend on what is present on the hardware, minus the restrictions by the flags.

Thanks for looking at this PR @eme64 ! Yes, that's the main difference between aarch64 and x86 platforms. It actually makes things simpler that changing the CPU features based on the vm option. But per my understanding, CPU features are the hardware's feature which is the objective fact, while the UseSVE are the JVM's option that people can set different values. And they cannot be mixed. Besides, x86 just mask off the CPU features for JVM instead of really changing the hardware's features. I'm not sure, but I'm afraid doing such changes like x86 may have some risks in current aarch64's backend.

We check in all sorts of places for sve feature, so why do you now only change it for this particular test?

For each SVE test, we have tried to add flag UseSVE=1 in the test's main function to make sure this option is not changed by others, and current test is run with the expected sve feature. For example:

    public static void main(String[] args) {
        TestFramework.runWithFlags("--add-modules=jdk.incubator.vector",
                                   "-XX:UseSVE=1");
    }

For this test, we cannot add such an option in the test file, since it is also used to test other platforms like x86.

@eme64
Copy link
Contributor

eme64 commented Jun 21, 2023

@XiaohongGong I see, you are worried that it would take a lot of work in the aarch64 code? So in the backend you are using the UseSVE flag instead of feature support?

Are you going to add the UseSVE flag to all these cases too?

emanuel@emanuel-oracle:/oracle-work/jdk-fork8/open$ grep sve test/hotspot/jtreg/compiler/ -r
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java:    @IR(failOn = IRNode.AND_VB, applyIfCPUFeatureAnd = {"asimd", "true", "sve", "false"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java:    @IR(failOn = IRNode.AND_VS, applyIfCPUFeatureAnd = {"asimd", "true", "sve", "false"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java:    @IR(counts = {IRNode.AND_VI, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java:    @IR(counts = {IRNode.AND_VL, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java:    @IR(counts = {IRNode.AND_VI, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java:    @IR(failOn = IRNode.OR_VB, applyIfCPUFeatureAnd = {"asimd", "true", "sve", "false"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java:    @IR(failOn = IRNode.OR_VB, applyIfCPUFeatureAnd = {"asimd", "true", "sve", "false"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java:    @IR(counts = {IRNode.OR_VI, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java:    @IR(counts = {IRNode.OR_VL, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java:    @IR(counts = {IRNode.OR_VI, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java:    @IR(failOn = IRNode.XOR_VS, applyIfCPUFeatureAnd = {"asimd", "true", "sve", "false"})
test/hotspot/jtreg/compiler/vectorization/runner/LoopArrayIndexComputeTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/LoopArrayIndexComputeTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/LoopArrayIndexComputeTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/LoopArrayIndexComputeTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayTypeConvertTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx512dq", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayTypeConvertTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayTypeConvertTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayTypeConvertTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayTypeConvertTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/BasicLongOpTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx512dq", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/BasicLongOpTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "sse4.1", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/BasicLongOpTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "sse4.1", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/BasicLongOpTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "sse4.1", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/LoopReductionOpTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/LoopReductionOpTest.java:    @IR(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},

I just really don't like the duplication of IR rules, and the checking of both the flag and the cpu feature.

Another solution: we filter out the sve feature at the IR framework, if we have UseSVE=0? But to that just smells like an workaround that should be fixed and made consistent at a lower level.

@eme64
Copy link
Contributor

eme64 commented Jun 21, 2023

Besides, x86 just mask off the CPU features for JVM instead of really changing the hardware's features.

That is the question: what is the ground truth. On x86, the idea is to keep the flags and the cpu features in sync. So if the hardware does not support a flag value to be larger (eg trying to set UseAVX=3 if only avx2 is available, we force it down to UseAVX=2). And if a flag restricts cpu features, we mask them off.

Of course, the hardware may support more features than the VM assumes. But still, that allows us to do some "cross cpu" testing - we can simulate avx1 features on a avx2 machine for example.

I discussed it with @chhagedorn and @TobiHartmann . They also think it is better to have flags and cpu features in sync. Because the flags really should restrict what the VM uses everywhere. We want to make sure the restrictions apply in the VM, if we check for features or flags.

@eme64
Copy link
Contributor

eme64 commented Jun 23, 2023

@fg1417 @jatin-bhateja What do you think about the consistency of arm / intel hardware flags for SVE and AVX?

@XiaohongGong
Copy link
Author

XiaohongGong commented Jun 25, 2023

@XiaohongGong I see, you are worried that it would take a lot of work in the aarch64 code? So in the backend you are using the UseSVE flag instead of feature support?

Yes, that may need more overhead on AArch64 code. I think the changing should not only limit to UseSVE flag and the sve cpu feature, but also to all other flags. We have to keep the design consistent.

And yes, for the current backend, we're almost using UseSVE flag instead of the cpu feature check.

test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java: @ir(failOn = IRNode.AND_VB, applyIfCPUFeatureAnd = {"asimd", "true", "sve", "false"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java: @ir(failOn = IRNode.AND_VS, applyIfCPUFeatureAnd = {"asimd", "true", "sve", "false"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java: @ir(counts = {IRNode.AND_VI, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java: @ir(counts = {IRNode.AND_VL, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java: @ir(counts = {IRNode.AND_VI, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java: @ir(failOn = IRNode.OR_VB, applyIfCPUFeatureAnd = {"asimd", "true", "sve", "false"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java: @ir(failOn = IRNode.OR_VB, applyIfCPUFeatureAnd = {"asimd", "true", "sve", "false"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java: @ir(counts = {IRNode.OR_VI, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java: @ir(counts = {IRNode.OR_VL, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java: @ir(counts = {IRNode.OR_VI, "1"}, applyIfCPUFeatureOr = {"sve", "true", "avx512", "true"})
test/hotspot/jtreg/compiler/vectorapi/VectorLogicalOpIdentityTest.java: @ir(failOn = IRNode.XOR_VS, applyIfCPUFeatureAnd = {"asimd", "true", "sve", "false"})
test/hotspot/jtreg/compiler/vectorization/runner/LoopArrayIndexComputeTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/LoopArrayIndexComputeTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/LoopArrayIndexComputeTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/LoopArrayIndexComputeTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayTypeConvertTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx512dq", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayTypeConvertTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayTypeConvertTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayTypeConvertTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayTypeConvertTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/BasicLongOpTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx512dq", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/BasicLongOpTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "sse4.1", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/BasicLongOpTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "sse4.1", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/BasicLongOpTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "sse4.1", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/ArrayIndexFillTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/LoopReductionOpTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"},
test/hotspot/jtreg/compiler/vectorization/runner/LoopReductionOpTest.java: @ir(applyIfCPUFeatureOr = {"sve", "true", "avx2", "true"}

I'm afraid we have to modify all these tests, and what I know is my colleague @pfustc will take charge of the vectorization tests once this PR is merged. Besides, we have to only care about the rules that sve is true like "@IR(applyIfCPUFeatureOr = {"sve", "true", ...}. If the sve feature is false, UseSVE is always 0 in the VM, which is synced.

Another solution: we filter out the sve feature at the IR framework, if we have UseSVE=0? But to that just smells like an workaround that should be fixed and made consistent at a lower level.

Thanks for the advice! Yeah, this seems a workaround. Besides, adding such specific handling for UseSVE in IR framework looks weird for me, which may also be not easier to maintain in future. And keeping the same behavior with VM is better for me.

@pfustc
Copy link
Member

pfustc commented Jun 25, 2023

I discussed it with @chhagedorn and @TobiHartmann . They also think it is better to have flags and cpu features in sync. Because the flags really should restrict what the VM uses everywhere. We want to make sure the restrictions apply in the VM, if we check for features or flags.

Hi @eme64,

Having flags and cpu features in sync sounds a good idea. However, of all platforms supported by HotSpot, only x86 does in this way. Even on x86, only AVX & SSE related features have such sync at present. There is no sync for other feature strings and flags, like UseSHA, UseAES and etc. That's the reason we think current approach of x86 is more like a workaround for IR tests only. If you believe keeping this kind of sync is a better approach, I'd suggest doing this for all CPU features on all platforms in another RFE.

@theRealAph
Copy link
Contributor

theRealAph commented Jun 25, 2023

Thanks for looking at this PR @eme64 ! Yes, that's the main difference between aarch64 and x86 platforms. It actually makes things simpler that changing the CPU features based on the vm option. But per my understanding, CPU features are the hardware's feature which is the objective fact, while the UseSVE are the JVM's option that people can set different values. And they cannot be mixed. Besides, x86 just mask off the CPU features for JVM instead of really changing the hardware's features. I'm not sure, but I'm afraid doing such changes like x86 may have some risks in current aarch64's backend.

It might, but it sounds like it's the right thing to do as soon as possible after the JDK 21 fork.

@theRealAph
Copy link
Contributor

I discussed it with @chhagedorn and @TobiHartmann . They also think it is better to have flags and cpu features in sync. Because the flags really should restrict what the VM uses everywhere. We want to make sure the restrictions apply in the VM, if we check for features or flags.

I agree.

Having flags and cpu features in sync sounds a good idea. However, of all platforms supported by HotSpot, only x86 does in this way. Even on x86, only AVX & SSE related features have such sync at present. There is no sync for other feature strings and flags, like UseSHA, UseAES and etc. That's the reason we think current approach of x86 is more like a workaround for IR tests only. If you believe keeping this kind of sync is a better approach, I'd suggest doing this for all CPU features on all platforms in another RFE.

That's an interesting suggestion, but having to keep all of the back ends in lock-step is an intolerable constraint.

@XiaohongGong
Copy link
Author

XiaohongGong commented Jun 26, 2023

Thanks for looking at this PR @eme64 ! Yes, that's the main difference between aarch64 and x86 platforms. It actually makes things simpler that changing the CPU features based on the vm option. But per my understanding, CPU features are the hardware's feature which is the objective fact, while the UseSVE are the JVM's option that people can set different values. And they cannot be mixed. Besides, x86 just mask off the CPU features for JVM instead of really changing the hardware's features. I'm not sure, but I'm afraid doing such changes like x86 may have some risks in current aarch64's backend.

It might, but it sounds like it's the right thing to do as soon as possible after the JDK 21 fork.

Thanks for looking at this issue @theRealAph. Sounds a good suggestion! I will take an investigation for this, and try to make a change.

@XiaohongGong
Copy link
Author

Hi there, I'v filed the vm option and cpu feature sync issue here for AArch64: https://bugs.openjdk.org/browse/JDK-8311130, and will address the comment with it. Thanks again for the advice!

Hi @eme64 , besides the sync issue, does the change to IR framework make sense to you? Currently, if we use an architecture specific vm options with applyIf for an IR check, and run the test on another different architecture, the whole test will fail by throwing exceptions, even if we add the applyIfCPUFeature to do the cpu check. The changes in the IR framework can fix this issue.

If that part seems fine to you, maybe we can let this PR in first? Since the test failure will noise our internal ci testing. WDYT? Thanks!

@eme64
Copy link
Contributor

eme64 commented Jun 30, 2023

@XiaohongGong I totally agree with the changes to the IR framework (having applyIfCPUFeature before applyIf).

Otherwise, using both UseSVE=0 and sve, false is a temporary fix that should be reverted after JDK-8311130. I'm accepting it as a temporary fix only. Who will do the real fix?

I was a bit afraid not keeping the CPU feature and the VM flag in sync could also lead to issues in the backend of aarch64. But it does indeed seem that we only use UseSVE, and never VM_Version::supports_sve(). Still, someone might use them synonymous in the future and expect that they are in sync.

Actually, since there are only so few uses of VM_Version::supports_sve(), is the risk not very low to just mask off the feature now directly with this fix? That fix does not look so complicated as I feared. What do you think?

Anyway, I just launched testing for commit 1: tier1-6 plus stress testing. Will report back on Monday probably.

@XiaohongGong
Copy link
Author

@XiaohongGong I totally agree with the changes to the IR framework (having applyIfCPUFeature before applyIf).

Thanks a lot!

Otherwise, using both UseSVE=0 and sve, false is a temporary fix that should be reverted after JDK-8311130. I'm accepting it as a temporary fix only. Who will do the real fix?

We (Arm) will do the real fix. UseSVE=0 is needed when sve, true, which only affects this test now. And yes, I can revert these IR checks once the real fix is in.

I was a bit afraid not keeping the CPU feature and the VM flag in sync could also lead to issues in the backend of aarch64. But it does indeed seem that we only use UseSVE, and never VM_Version::supports_sve(). Still, someone might use them synonymous in the future and expect that they are in sync.

Agree, although we only use UseSVE in backend now.

Actually, since there are only so few uses of VM_Version::supports_sve(), is the risk not very low to just mask off the feature now directly with this fix? That fix does not look so complicated as I feared. What do you think?

I prefer fixing that in a separate patch. One reason is syncing the vm options and cpu features is a refactory to AArch64 backend for me. It has other relative cpu features specific to different SVE systems besides sve. For example, the svebitperm which exists after sve2. We have to take a consideration for them as well. Besides, although the changes is not so big, we have to do more testing to make sure no regressions are involved.

And besides the UseSVE, do you think it's necessary to sync other options as well?

Anyway, I just launched testing for commit 1: tier1-6 plus stress testing. Will report back on Monday probably.

Thanks for doing this!

@eme64
Copy link
Contributor

eme64 commented Jul 3, 2023

@XiaohongGong Testing for commit 1 looks good.

I don't have the expertise on the other CPU features. But from a distance, I'd say yes. The idea with all the CPU features is that we can simulate less powerful machines with more powerful machines. But I would first fix the SVE features, and handle the others separately. Maybe for those a separate discussion needs to happen first.
@vnkozlov What do you think about syncing CPU features with their VM Flags? Only relevant for AVX and SVE, or more generally? What about UseSHA, UseAES for example?

Copy link
Contributor

@eme64 eme64 left a comment

Choose a reason for hiding this comment

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

Accepted as a temporary fix that has to be reverted with JDK-8311130.

Thanks again for fixing the order of CPU features and VM flags in the IR rules!

@openjdk
Copy link

openjdk bot commented Jul 3, 2023

@XiaohongGong 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:

8309894: compiler/vectorapi/VectorLogicalOpIdentityTest.java fails on SVE system with UseSVE=0

Reviewed-by: epeter, chagedorn

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 269 new commits pushed to the master branch:

  • 87c79c0: 8309302: java/net/Socket/Timeouts.java fails with AssertionError on test temporal post condition
  • 8e0ca8e: 8310331: JitTester: Exclude java.lang.Math.random
  • 055b4b4: 8310948: Fix ignored-qualifiers warning in Hotspot
  • 2c29705: 8309660: C2: failed: XMM register should be 0-15 (UseKNLSetting and ConvF2HF)
  • 52ee570: 8309209: C2 failed "assert(_stack_guard_state == stack_guard_reserved_disabled) failed: inconsistent state"
  • faf1b82: 8310656: RISC-V: __builtin___clear_cache can fail silently.
  • 0e3d91d: 8311215: [BACKOUT] JDK-8047998 Abort the vm if MaxNewSize is not the same as NewSize when MaxHeapSize is the same as InitialHeapSize
  • 09a4924: 8311145: Remove check_with_errno duplicates
  • 8abb9f5: 8047998: Abort the vm if MaxNewSize is not the same as NewSize when MaxHeapSize is the same as InitialHeapSize
  • d2e1159: 8311125: Remove unused parameter 'phase' in AllocateNode::Ideal_allocation
  • ... and 259 more: https://git.openjdk.org/jdk/compare/57fc9a3e968cafe3b618a216630e703a39d5676e...master

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 3, 2023
@XiaohongGong
Copy link
Author

Accepted as a temporary fix that has to be reverted with JDK-8311130.

Thanks for the review and testing! I will revert the IR test part with JDK-8311130.

Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

Accepted as a temporary fix that has to be reverted with JDK-8311130.

I agree with this temporary fix and reverting it again when syncing the flags with the CPU features in JDK-8311130.

@XiaohongGong
Copy link
Author

Thanks for the review @chhagedorn ! I'v addressed the comments in latest commit.

Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

Thanks for the update, looks good!

@XiaohongGong
Copy link
Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 4, 2023

Going to push as commit 60544f9.
Since your change was applied there have been 276 commits pushed to the master branch:

  • 0916e6a: 8311092: Please disable runtime/jni/nativeStack/TestNativeStack.java on armhf
  • d8a0121: 8311109: tautological-compare warning in awt_Win32GraphicsDevice.cpp
  • b9198f9: 8254566: Clarify the spec of ClassLoader::getClassLoadingLock for non-parallel capable loader
  • f393975: 8310743: assert(reserved_rgn != nullptr) failed: Add committed region, No reserved region found
  • ba974d5: 8310661: JFR: Replace JVM.getJVM() with JVM
  • 496f94b: 8311086: Remove jtreg/gc/startup_warnings
  • 9d2e0b2: 8307934: JRobot.moveMouseTo must access component on EDT
  • 87c79c0: 8309302: java/net/Socket/Timeouts.java fails with AssertionError on test temporal post condition
  • 8e0ca8e: 8310331: JitTester: Exclude java.lang.Math.random
  • 055b4b4: 8310948: Fix ignored-qualifiers warning in Hotspot
  • ... and 266 more: https://git.openjdk.org/jdk/compare/57fc9a3e968cafe3b618a216630e703a39d5676e...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 4, 2023
@openjdk openjdk bot closed this Jul 4, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 4, 2023
@openjdk
Copy link

openjdk bot commented Jul 4, 2023

@XiaohongGong Pushed as commit 60544f9.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@XiaohongGong XiaohongGong deleted the JDK-8309894 branch July 4, 2023 01:35
pfustc pushed a commit to pfustc/jdk that referenced this pull request Jul 17, 2023
As discussed in PR openjdk#14533, keeping AArch64 flag `UseSVE` and its related
CPU features in sync helps to simplify rules in IR tests. In this patch,
we mask SVE related CPU features off if specified SVE level in VM option
is lower than the hardware supported. Also, to support this change, we
move the features string construction to the end of the `initialize()`
function.

We also revert IR rule changes in PR openjdk#14533 and fix some code styles. We
tested almost full jtreg on SVE, SVE2 and non-SVE CPUs and no new issue
is found after this patch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
5 participants