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

8309893: Integrate ReplicateB/S/I/L/F/D nodes to Replicate node #14830

Closed
wants to merge 6 commits into from

Conversation

e1iu
Copy link
Member

@e1iu e1iu commented Jul 11, 2023

This patch creates ReplicateNode to replace ReplicateB/S/I/L/F/DNode, like other vector nodes introduced recently, e.g., PopulateIndexNode and ReverseVNode, etc. This refers from:
https://mail.openjdk.org/pipermail/panama-dev/2020-April/008484.html

After merging these nodes, code will be easier to maintain. E.g., matching rules can be simplified.

Besides AArch64, this patch tries to keep other ad files as the same before, only supplies some necessary predicate. E.g., for matching rules using ReplicateB before, they are now matching Replicate with a new predicate "Matcher::vector_element_basic_type(n) == T_BYTE". This would be easy for review and lower risks.

[TEST]
x86: Tested with option "-XX:UseAVX=0/1/2/3".
AArch64: Tested on SVE machine and Neon machine.

Full jtreg passed without new issue.


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-8309893: Integrate ReplicateB/S/I/L/F/D nodes to Replicate node (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14830

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

Using diff file

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

Webrev

Link to Webrev Comment

This patch creates ReplicateNode to replace ReplicateB/S/I/L/F/DNode,
like other vector nodes introduced recently, e.g., PopulateIndexNode and
ReverseVNode, etc. This refers from:
https://mail.openjdk.org/pipermail/panama-dev/2020-April/008484.html

After merging these nodes, code will be easier to maintain. E.g.,
matching rules can be simplified.

Besides AArch64, this patch tries to keep other ad files as the same
before, only supplies some necessary predicate. E.g., for matching rules
using ReplicateB before, they are now matching Replicate with a new
predicate "Matcher::vector_element_basic_type(n) == T_BYTE". This would
be easy for review and lower risks.

[TEST]
x86:     Tested with option "-XX:UseAVX=0/1/2/3".
AArch64: Tested on SVE machine and Neon machine.

Full jtreg passed without new issue.

Change-Id: Icb16084e3909177ab302f0ba33c2216c860a5da6
@bridgekeeper
Copy link

bridgekeeper bot commented Jul 11, 2023

👋 Welcome back eliu! 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 Jul 11, 2023
@openjdk
Copy link

openjdk bot commented Jul 11, 2023

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

  • hotspot

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 hotspot-dev@openjdk.org label Jul 11, 2023
@e1iu
Copy link
Member Author

e1iu commented Jul 11, 2023

/label remove hotspot
/label add hotspot-compiler

@openjdk openjdk bot removed the hotspot hotspot-dev@openjdk.org label Jul 11, 2023
@openjdk
Copy link

openjdk bot commented Jul 11, 2023

@e1iu
The hotspot label was successfully removed.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Jul 11, 2023
@openjdk
Copy link

openjdk bot commented Jul 11, 2023

@e1iu
The hotspot-compiler label was successfully added.

@mlbridge
Copy link

mlbridge bot commented Jul 11, 2023

Webrevs

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 21, 2023

@e1iu This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 18, 2023

@e1iu This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

@bridgekeeper bridgekeeper bot closed this Sep 18, 2023
@e1iu
Copy link
Member Author

e1iu commented Oct 11, 2023

/open

@openjdk openjdk bot reopened this Oct 11, 2023
@openjdk
Copy link

openjdk bot commented Oct 11, 2023

@e1iu This pull request is now open

@eme64
Copy link
Contributor

eme64 commented Oct 20, 2023

@e1iu would you mind resolving the merge conflict? I will then send this to testing and review it afterwards.

Eric Liu added 2 commits October 23, 2023 02:01
Change-Id: I4df10ba7290e9af02deeac5a931234a07be7c207
Change-Id: I121a8c1ad75e88c0af41f2c1ef00289a3d61f400
@e1iu
Copy link
Member Author

e1iu commented Oct 24, 2023

@eme64 Hi Peter, I resolved the conflicts. They are mainly in jtreg test cases. Full jtreg passed on x86 machine (with option "-XX:UseAVX=0/1/2/3") and arm machines (SVE and NEON).

Please help to review, thanks.

@eme64
Copy link
Contributor

eme64 commented Oct 24, 2023

@e1iu thanks, I have testing running for v01 / commit 3... will get back to you.
Update: tests seem to be passing. I'll review this tomorrow.

Copy link
Member

@jatin-bhateja jatin-bhateja left a comment

Choose a reason for hiding this comment

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

Hi @e1iu, Nice cleanup!. There is still some refactoring possible around x86 broadcast instruction patterns with similar operands.

Comment on lines 4161 to 4162
predicate(UseAVX >= 2);
match(Set dst (ReplicateB src));
predicate(UseAVX >= 2 && Matcher::vector_element_basic_type(n) == T_BYTE);
match(Set dst (Replicate src));
Copy link
Member

Choose a reason for hiding this comment

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

Integral replicate patterns can be merged by folding predicates into macro assembler.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jatin-bhateja can you spell out a bit what you mean?
And when you mention broadcast instructions, do you mean any non Replicate instructions?

Copy link
Member

Choose a reason for hiding this comment

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

@eme64, I see an opportunity for merging some integral broadcast patterns which share the operand definitions and matcher pattern, by moving predicates into macro assembler layer.

Copy link
Contributor

Choose a reason for hiding this comment

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

#14830 (comment)
@e1iu have you addressed this? What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jatin-bhateja @eme64 I think it's very x86 specifically. I don't have too much confidence changing other platforms' code. So as I mention at beginning, this patch only adds predicate on each rules to pursue lower risks. I think This's a workable way to refactor some shared code.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jatin-bhateja would it be ok if you did this as a follow-up RFE? Or otherwise could you give very clear instructions about what exactly you want to see, @jatin-bhateja ?

Copy link
Member

Choose a reason for hiding this comment

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

replicate_cleanup_x86..txt
@e1iu , I meant something on these lines, at the minimal combine the byte / short patterns having same operands.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jatin-bhateja I understand now. Would it be ok if we did this in a separate RFE? Then we can limit this to x86.

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.

Generally looks really good, thanks for the work!
I left a few small comments.

I also did not really review:
src/hotspot/cpu/aarch64/aarch64_vector_ad.m4
I don't understand those parts enough to review it.

src/hotspot/share/opto/matcher.cpp Show resolved Hide resolved
@@ -629,17 +607,7 @@ bool VectorNode::is_vshift_cnt(Node* n) {
// Check if input is loop invariant vector.
bool VectorNode::is_invariant_vector(Node* n) {
// Only Replicate vector nodes are loop invariant for now.
Copy link
Contributor

Choose a reason for hiding this comment

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

Random discovery: does this not sound fishy? Can Replicate nodes never be used in a loop variant way? For example with the VectorAPI?

Copy link
Member Author

Choose a reason for hiding this comment

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

Replicate can be variant in Vector API. E.g., we can create an IntVector in loop by IntVector.broadcast (https://github.com/openjdk/jdk/blob/master/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java). We also have such matching rules supporting register as Replicate input.

I only find the use point of this method in Superword, I'm not sure if auto-vectorization has any special handle in vectorizing Replicate.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this method has no value now. I would remove it and use n->Opcode() == Op_Replicate at the two use cases:
VectorNode::degenerate_vector_rotate and SuperWord::output
That would be more understandable.

In SuperWord, we so far only add Replicate nodes if we have a vector-op that has one arg-slot as all the same input (eg some_invariant_value below).

for (int i = ...) {
  a[i] = b[i] * some_invariant_value;
}

So I guess the assumption is that the Replicate node can always float out of the loop, and hence it would be good to have it on the "right side" (second slot) of the Add/Mul node. This supposedly reduces register pressure. If that is still true I do not know. Hence, I would do this:

        if (in1->Opcode() == Op_Replicate && (node_isa_reduction == false) && (n->is_Add() || n->is_Mul())) {
          // We have a Replicate node on in1. Since the input to the Replicate node is expected to be outside
          // the loop, also the Replicate node can float out of the loop. To reduce register pressure, we swap
          // the invariant inpus to the second slot.
          Node* tmp = in1;
          in1 = in2;
          in2 = tmp;
        }

Additionally, it would be interesting to add an assert to see if the input of Replicate is indeed loop invariant.

VectorNode::degenerate_vector_rotate talks about doing something to replicate nodes anyway, so talking about "invariant" is not helpful.

Copy link
Contributor

Choose a reason for hiding this comment

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

@e1iu what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree! I removed this in the latest commit. I'm running full JTReg for it.

Eric Liu added 2 commits October 31, 2023 09:57
Change-Id: I892e532ea7b6d884cfbeaf9e55d5c9a26a27ab3a
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.

This now looks quite good.
I will run testing one more time, and then approve it from my side.

But I want that at least someone from intel (e.g. @jatin-bhateja) and someone from arm (e.g. @fg1417 ) reviews this.

Depending on how safe you feel about the changes in the other platforms you may want to ask people to at least build and test this.

Comment on lines 4161 to 4162
predicate(UseAVX >= 2);
match(Set dst (ReplicateB src));
predicate(UseAVX >= 2 && Matcher::vector_element_basic_type(n) == T_BYTE);
match(Set dst (Replicate src));
Copy link
Contributor

Choose a reason for hiding this comment

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

#14830 (comment)
@e1iu have you addressed this? What do you think?

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.

Testing passed for commit 5 / v03.
Tested on x64 and aarch64 without SVE.

I can approve this from a compiler perspective.
Again, I want that at least someone from Intel (e.g. @jatin-bhateja) and someone from ARM (e.g. @fg1417 ) to reviews this.

You will need other people to review, or at least run the tests for:
arm, ppc, riscv, s390.

@openjdk
Copy link

openjdk bot commented Nov 6, 2023

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

8309893: Integrate ReplicateB/S/I/L/F/D nodes to Replicate node

Reviewed-by: jbhateja, epeter, fgao

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

  • 439ed04: 8319233: AArch64: Build failure with clang due to -Wformat-nonliteral warning
  • e4803e0: 8318580: "javax/swing/MultiMonitor/MultimonVImage.java failing with Error. Can't find library: /open/test/jdk/java/awt/regtesthelpers" after JDK-8316053
  • cdf3373: 8319316: Clarify text around which layouts a linker supports
  • 1696603: 8308453: Convert JKS test keystores in test/jdk/javax/net/ssl/etc to PKCS12
  • b3126b6: 8319455: Test compiler/print/CompileCommandMemLimit.java times out
  • 1c2ea1d: 8319153: Fix: Class is a raw type in ProcessTools
  • 96e6e67: 4365952: Cannot disable JFileChooser
  • 2d4bbf4: 8319465: Typos in javadoc of com.sun.management.OperatingSystemMXBean methods
  • 8fb94fd: 8319379: G1: gc/logging/TestUnifiedLoggingSwitchStress.java crashes after JDK-8318894
  • b5c863b: 8316533: C2 compilation fails with assert(verify(phase)) failed: missing Value() optimization
  • ... and 183 more: https://git.openjdk.org/jdk/compare/ecd25e7d6f9d69f9dbdbff0a4a9b9d6b19288593...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 Nov 6, 2023
Change-Id: I62328bc9c60e0131784ca441840e51ee103a15a3
@e1iu
Copy link
Member Author

e1iu commented Nov 6, 2023

I triggered full jtreg testing for latest patchset on arm and x86 machines. I will give feedback in time.

@e1iu
Copy link
Member Author

e1iu commented Nov 7, 2023

I triggered full jtreg testing for latest patchset on arm and x86 machines. I will give feedback in time.

Full JTreg passed on AArch64 and x86 machines with -XX:UseAVX=(/0/1/2/3).

Please help to review @fg1417 @jatin-bhateja @pron @AlanBateman @RealFYang

Copy link
Member

@jatin-bhateja jatin-bhateja left a comment

Choose a reason for hiding this comment

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

Thanks @e1iu , LGTM.

Copy link

@fg1417 fg1417 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 your great work! LGTM.

@zifeihan
Copy link
Member

zifeihan commented Nov 8, 2023

Hi, I have performed tier1-3 test on linux-riscv64 using QEMU with -XX:+UseRVV. Result looks good.

@e1iu
Copy link
Member Author

e1iu commented Nov 10, 2023

Thanks all kindly review. I would like to integrate this patch if no other comment.

@e1iu
Copy link
Member Author

e1iu commented Nov 13, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Nov 13, 2023

Going to push as commit 50f41d6.
Since your change was applied there have been 259 commits pushed to the master branch:

  • caf7181: 8318189: ChoiceFormat::format throws undocumented AIOOBE
  • 9938b3f: 8319314: NMT detail report slow or hangs for large number of mappings
  • c9077b8: 8319339: Internal error on spurious markup in a hybrid snippet
  • ea1ffa3: 8318895: Deoptimization results in incorrect lightweight locking stack
  • c9657ca: 8319882: SequenceLayout::toString throws ArithmeticException
  • 6b21ff6: 8319828: runtime/NMT/VirtualAllocCommitMerge.java may fail if mixing interpreted and compiled native invocations
  • a64fc48: 8319174: Enhance robustness of some j.m.BigInteger constructors
  • 9cce9fe: 8319256: Print more diagnostic information when an unexpected user is found in a Phi
  • a95062b: 8319670: Improve comments describing system properties for TLS server and client for max chain length
  • 38745ec: 8319649: inline_boxing_calls unused gvn variable
  • ... and 249 more: https://git.openjdk.org/jdk/compare/ecd25e7d6f9d69f9dbdbff0a4a9b9d6b19288593...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Nov 13, 2023

@e1iu Pushed as commit 50f41d6.

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

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
6 participants