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

8284960: Integration of JEP 426: Vector API (Fourth Incubator) #8425

Closed
wants to merge 20 commits into from

Conversation

jatin-bhateja
Copy link
Member

@jatin-bhateja jatin-bhateja commented Apr 27, 2022

Hi All,

Patch adds the planned support for new vector operations and APIs targeted for JEP 426: Vector API (Fourth Incubator).

Following is the brief summary of changes:-

  1. Extends the scope of existing lanewise API for following new vector operations.
  • VectorOperations.BIT_COUNT: counts the number of one-bits
  • VectorOperations.LEADING_ZEROS_COUNT: counts the number of leading zero bits
  • VectorOperations.TRAILING_ZEROS_COUNT: counts the number of trailing zero bits
  • VectorOperations.REVERSE: reversing the order of bits
  • VectorOperations.REVERSE_BYTES: reversing the order of bytes
  • compress and expand bits: Semantics are based on Hacker's Delight section 7-4 Compress, or Generalized Extract.
  1. Adds following new APIs to perform cross lane vector compress and expansion operations under the influence of a mask.
  • Vector.compress
  • Vector.expand
  • VectorMask.compress
  1. Adds predicated and non-predicated versions of following new APIs to load and store the contents of vector from foreign MemorySegments.
  • Vector.fromMemorySegment
  • Vector.intoMemorySegment
  1. C2 Compiler IR enhancements and optimized X86 and AARCH64 backend support for each newly added operation.

Patch has been regressed over AARCH64 and X86 targets different AVX levels.

Kindly review and share your feedback.

Best Regards,
Jatin


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
  • Change requires a JEP request to be targeted
  • Change requires a CSR request to be approved

Issues

  • JDK-8284960: Integration of JEP 426: Vector API (Fourth Incubator)
  • JDK-8284972: Integration of JEP 426: Vector API (Fourth Incubator) (CSR)
  • JDK-8280173: JEP 426: Vector API (Fourth Incubator) (JEP)

Reviewers

Contributors

  • Jatin Bhateja <jbhateja@openjdk.org>
  • Paul Sandoz <psandoz@openjdk.org>
  • Sandhya Viswanathan <sviswanathan@openjdk.org>
  • Smita Kamath <svkamath@openjdk.org>
  • Joshua Zhu <jzhu@openjdk.org>
  • Xiaohong Gong <xgong@openjdk.org>
  • John R Rose <jrose@openjdk.org>
  • Eric Liu <eliu@openjdk.org>
  • Ningsheng Jian <njian@openjdk.org>

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/8425/head:pull/8425
$ git checkout pull/8425

Update a local copy of the PR:
$ git checkout pull/8425
$ git pull https://git.openjdk.java.net/jdk pull/8425/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 8425

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/8425.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 27, 2022

👋 Welcome back jbhateja! 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
Copy link

openjdk bot commented Apr 27, 2022

@jatin-bhateja The following labels will be automatically applied to this pull request:

  • core-libs
  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added hotspot hotspot-dev@openjdk.org core-libs core-libs-dev@openjdk.org csr Pull request needs approved CSR before integration labels Apr 27, 2022
@jatin-bhateja
Copy link
Member Author

/contributor add @jatin-bhateja

@jatin-bhateja
Copy link
Member Author

/contributor add @PaulSandoz

@openjdk
Copy link

openjdk bot commented Apr 27, 2022

@jatin-bhateja
Contributor Jatin Bhateja <jbhateja@openjdk.org> successfully added.

@openjdk
Copy link

openjdk bot commented Apr 27, 2022

@jatin-bhateja
Contributor Paul Sandoz <psandoz@openjdk.org> successfully added.

@jatin-bhateja
Copy link
Member Author

/contributor add @sviswa7

@openjdk
Copy link

openjdk bot commented Apr 27, 2022

@jatin-bhateja
Contributor Sandhya Viswanathan <sviswanathan@openjdk.org> successfully added.

@jatin-bhateja
Copy link
Member Author

/contributor add @smita-kamath

@openjdk
Copy link

openjdk bot commented Apr 27, 2022

@jatin-bhateja
Contributor Smita Kamath <svkamath@openjdk.org> successfully added.

@jatin-bhateja
Copy link
Member Author

/contributor add @JoshuaZhuwj

@openjdk
Copy link

openjdk bot commented Apr 27, 2022

@jatin-bhateja
Contributor Joshua Zhu <jzhu@openjdk.org> successfully added.

@openjdk
Copy link

openjdk bot commented Apr 27, 2022

@jatin-bhateja Could not parse @swati-sha as a valid contributor.
Syntax: /contributor (add|remove) [@user | openjdk-user | Full Name <email@address>]. For example:

  • /contributor add @openjdk-bot
  • /contributor add duke
  • /contributor add J. Duke <duke@openjdk.org>

@openjdk
Copy link

openjdk bot commented Apr 27, 2022

@jatin-bhateja Unknown command contributors - for a list of valid commands use /help.

@jatin-bhateja
Copy link
Member Author

/contributor add @XiaohongGong

@openjdk
Copy link

openjdk bot commented Apr 27, 2022

@jatin-bhateja
Contributor Xiaohong Gong <xgong@openjdk.org> successfully added.

@jatin-bhateja
Copy link
Member Author

/contributor add @rose00

@openjdk
Copy link

openjdk bot commented Apr 27, 2022

@jatin-bhateja
Contributor John R Rose <jrose@openjdk.org> successfully added.

@jatin-bhateja
Copy link
Member Author

/contributor add @theRealELiu

@jatin-bhateja
Copy link
Member Author

/contributor add @nsjian

@openjdk
Copy link

openjdk bot commented Apr 28, 2022

@jatin-bhateja
Contributor Eric Liu <eliu@openjdk.org> successfully added.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label May 13, 2022
@openjdk openjdk bot added ready Pull request is ready to be integrated and removed merge-conflict Pull request has merge conflict with target branch labels May 17, 2022
Jatin Bhateja added 2 commits May 19, 2022 14:10
@@ -46,6 +47,7 @@
import java.util.Map;
import java.util.Set;

import static com.sun.tools.javac.code.Flags.PREVIEW_API;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
import static com.sun.tools.javac.code.Flags.PREVIEW_API;

Redundant import (sorry i should have checked before i sent you updates to this area)

Copy link
Member Author

Choose a reason for hiding this comment

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

Merged

Comment on lines 124 to 132
/**
* Returns true if {@code s} is participating in the preview of {@code previewSymbol}, and
* therefore no warnings or errors will be produced.
*
* @param s the symbol depending on the preview symbol
* @param previewSymbol the preview symbol marked with @Preview
* @return true if {@code s} is participating in the preview of {@code previewSymbol}
*/
public boolean isPreviewParticipating(Symbol s, Symbol previewSymbol) {
Copy link
Member

Choose a reason for hiding this comment

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

Some feedback from a colleague:

Suggested change
/**
* Returns true if {@code s} is participating in the preview of {@code previewSymbol}, and
* therefore no warnings or errors will be produced.
*
* @param s the symbol depending on the preview symbol
* @param previewSymbol the preview symbol marked with @Preview
* @return true if {@code s} is participating in the preview of {@code previewSymbol}
*/
public boolean isPreviewParticipating(Symbol s, Symbol previewSymbol) {
/**
* Returns true if {@code s} is deemed to participate in the preview of {@code previewSymbol}, and
* therefore no warnings or errors will be produced.
*
* @param s the symbol depending on the preview symbol
* @param previewSymbol the preview symbol marked with @Preview
* @return true if {@code s} is participating in the preview of {@code previewSymbol}
*/
public boolean participatesInPreview(Symbol s, Symbol previewSymbol) {

Copy link
Member Author

Choose a reason for hiding this comment

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

Merged.

Copy link
Contributor

@mcimadamore mcimadamore left a comment

Choose a reason for hiding this comment

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

Javac changes look good

Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

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

The javac changes look OK to me.

@jatin-bhateja
Copy link
Member Author

Hi @iwanowww , your comments have been addressed. kindly let me know if you have other comments on x86 side changes.

Copy link

@iwanowww iwanowww left a comment

Choose a reason for hiding this comment

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

Looks good!

@@ -7894,6 +7930,30 @@ void Assembler::evprorvq(XMMRegister dst, XMMRegister src, XMMRegister shift, in
emit_int16(0x14, (unsigned char)(0xC0 | encode));
}

void Assembler::evplzcntd(XMMRegister dst, KRegister mask, XMMRegister src, bool merge, int vector_len) {
assert(VM_Version::supports_avx512cd() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), "");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, split assert as in other instructions - it will help to understand failure better.

}

void Assembler::evplzcntq(XMMRegister dst, KRegister mask, XMMRegister src, bool merge, int vector_len) {
assert(VM_Version::supports_avx512cd() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), "");
Copy link
Contributor

Choose a reason for hiding this comment

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

Split assert.

@@ -11555,6 +11715,79 @@ void Assembler::evpmovm2b(XMMRegister dst, KRegister src, int vector_len) {
int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F_38, &attributes);
emit_int16(0x28, (0xC0 | encode));
}

void Assembler::evpcompressb(XMMRegister dst, KRegister mask, XMMRegister src, bool merge, int vector_len) {
assert(VM_Version::supports_avx512_vbmi2() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), "");
Copy link
Contributor

Choose a reason for hiding this comment

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

Split assert in this and following new instructions.

Comment on lines -8035 to +8173
assert(VM_Version::supports_avx2(), "");
assert(VM_Version::supports_evex(), "");
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, did we never trigger this wrong assert because the use was guarded by correct check?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes.

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 something wrong with merge. vpadd() is removed. It was added by #8778 and still is used in x86.ad.

Hi @vnkozlov , after integration of PR 8778 there were there were two copies of vpadd with same signature, so removed one of them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay. Got it.

evcompresspd(dst, mask, src, merge, vec_enc);
break;
default:
fatal("Unsupported type");
Copy link
Contributor

Choose a reason for hiding this comment

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

Print wrong type: fatal("Unsupported type : %s", type2name(type));
Below too.

vpaddq(dst, src1, src2, vec_enc);
break;
default:
ShouldNotReachHere();
Copy link
Contributor

Choose a reason for hiding this comment

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

Use fatal and print type.

// should be succeeded by its corresponding vector IR and following
// special handling should be removed.
if (bt == T_LONG && rbt == T_INT) {
if (VM_Version::supports_avx512vl()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Predicate say !VM_Version::supports_avx512vl()

Comment on lines 1005 to 1006
// The node is a CountedLoopEnd with a mask annotation so as to emit a restore context
bool has_vector_mask_set() const { return (_flags & Flag_has_vector_mask_set) != 0; }
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see use of this flag.

@@ -82,7 +82,8 @@ bool LibraryCallKit::arch_supports_vector_rotate(int opc, int num_elem, BasicTyp
if (is_supported) {
// Check whether mask unboxing is supported.
if ((mask_use_type & VecMaskUseLoad) != 0) {
if (!Matcher::match_rule_supported_vector(Op_VectorLoadMask, num_elem, elem_bt)) {
if (!Matcher::match_rule_supported_vector(Op_VectorLoadMask, num_elem, elem_bt) ||
!Matcher::match_rule_supported_vector(Op_LoadVector, num_elem, T_BOOLEAN)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment explaining new check. In follow ing places too.

@@ -1775,6 +1775,8 @@
declare_c2_type(FmaVFNode, VectorNode) \
declare_c2_type(CMoveVFNode, VectorNode) \
declare_c2_type(CMoveVDNode, VectorNode) \
declare_c2_type(CompressVNode, VectorNode) \
declare_c2_type(ExpandVNode, VectorNode) \
Copy link
Contributor

Choose a reason for hiding this comment

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

Not all new nodes listed.

@jatin-bhateja
Copy link
Member Author

Hi @vnkozlov , Your comments have been addressed.

@vnkozlov
Copy link
Contributor

@jatin-bhateja something wrong with merge. vpadd() is removed. It was added by #8778 and still is used in x86.ad.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Good.

@jatin-bhateja
Copy link
Member Author

/integrate

@jatin-bhateja
Copy link
Member Author

Thanks reviewers for your comments.

@openjdk
Copy link

openjdk bot commented May 31, 2022

Going to push as commit 6f6486e.
Since your change was applied there have been 73 commits pushed to the master branch:

  • 171a7cd: 8286895: InternalError: Exception during analyze
  • 1b44f6c: 8287526: java/nio/channels/FileChannel/LargeMapTest.java fails on 32-bit systems
  • 7ef6993: 8276836: Error in javac caused by switch expression without result expressions: Internal error: stack sim error
  • c6e0416: 8282863: java/awt/FullScreen/FullscreenWindowProps/FullscreenWindowProps.java fails on Windows 10 with HiDPI screen
  • 6e55a72: 8287438: IGV: scheduling crashes on non-block-start Region with multiple predecessors
  • 8f59422: 8285558: IGV: scheduling crashes on control-unreachable CFG nodes
  • 8a9aeff: 8287497: Use String.contains() instead of String.indexOf() in java.naming
  • b2ba9fc: 8286180: Enable construction of LogStreamImpl from LogMessageImpl
  • 0c420e0: 8287430: MemorySessionImpl::addOrCleanupIfFail does not rethrow exceptions
  • 1606d55: 8286855: javac error on invalid jar should only print filename
  • ... and 63 more: https://git.openjdk.java.net/jdk/compare/742644e291039e4f2f30cf80718669c06da5809c...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented May 31, 2022

@jatin-bhateja Pushed as commit 6f6486e.

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

@jatin-bhateja jatin-bhateja deleted the JDK-8284960 branch January 20, 2023 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org hotspot hotspot-dev@openjdk.org hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
10 participants