Skip to content

Conversation

@mur47x111
Copy link
Contributor

@mur47x111 mur47x111 commented Aug 3, 2023

This PR exports vmIntrinsic::is_intrinsic_available, Compiler::is_intrinsic_supported, and C2Compiler::is_intrinsic_supported results to JVMCI compiler. This allows JVMCI compiler to comply with -XX:DisableIntrinsic, -XX:ControlIntrinsic, -XX:-UseXXXIntrinsic, and is essential for running test that depends on these flags, e.g., java/lang/Float/Binary16ConversionNaN that returns different result in the interpreter with -XX:DisableIntrinsic=_float16ToFloat,_floatToFloat16.
This PR also attempts to fix some of the is_intrinsic_available results. Please see the inlined comments.


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-8313372: [JVMCI] Export vmIntrinsics::is_intrinsic_available results to JVMCI compilers. (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15133

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 3, 2023

👋 Welcome back yzheng! 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 Aug 3, 2023
@openjdk
Copy link

openjdk bot commented Aug 3, 2023

@mur47x111 The following labels will be automatically applied to this pull request:

  • graal
  • 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 graal graal-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Aug 3, 2023
@mlbridge
Copy link

mlbridge bot commented Aug 3, 2023

Webrevs

break;
case vmIntrinsics::_electronicCodeBook_encryptAESCrypt:
case vmIntrinsics::_electronicCodeBook_decryptAESCrypt:
case vmIntrinsics::_galoisCounterMode_AESCrypt:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Stubs for these intrinsics are generated with the following CPU features.
See

if (VM_Version::supports_avx512_vaes() && VM_Version::supports_avx512vl() && VM_Version::supports_avx512dq() ) {
StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptVectorAESCrypt();
StubRoutines::_electronicCodeBook_encryptAESCrypt = generate_electronicCodeBook_encryptAESCrypt();
StubRoutines::_electronicCodeBook_decryptAESCrypt = generate_electronicCodeBook_decryptAESCrypt();
StubRoutines::_galoisCounterMode_AESCrypt = generate_galoisCounterMode_AESCrypt();
} else {
StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt_Parallel();
}

}
break;
case vmIntrinsics::_bigIntegerRightShiftWorker:
case vmIntrinsics::_bigIntegerLeftShiftWorker:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See

if (VM_Version::supports_avx512_vbmi2()) {
StubRoutines::_bigIntegerRightShiftWorker = generate_bigIntegerRightShift();
StubRoutines::_bigIntegerLeftShiftWorker = generate_bigIntegerLeftShift();
}

}
break;
case vmIntrinsics::_dcopySign:
case vmIntrinsics::_fcopySign:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See

jdk/src/hotspot/cpu/x86/x86.ad

Lines 1601 to 1609 in 53ca75b

case Op_CopySignD:
case Op_CopySignF:
if (UseAVX < 3 || !is_LP64) {
return false;
}
if (!VM_Version::supports_avx512vl()) {
return false;
}
break;

case vmIntrinsics::_maxF_strict:
case vmIntrinsics::_minF_strict:
case vmIntrinsics::_maxD_strict:
case vmIntrinsics::_minD_strict:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See

jdk/src/hotspot/cpu/x86/x86.ad

Lines 1534 to 1543 in 53ca75b

#ifdef _LP64
case Op_MaxD:
case Op_MaxF:
case Op_MinD:
case Op_MinF:
if (UseAVX < 1) { // enabled for AVX only
return false;
}
break;
#endif

break;
case vmIntrinsics::_electronicCodeBook_decryptAESCrypt:
if (StubRoutines::electronicCodeBook_decryptAESCrypt() == nullptr) return false;
break;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These two intrinsics were marked as supported on non-x86 platforms where the underlying stubs are not generated

Copy link
Contributor

Choose a reason for hiding this comment

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

good catch

static bool supports_avx256only() { return (supports_avx2() && !supports_evex()); }
static bool supports_avxonly() { return ((supports_avx2() || supports_avx()) && !supports_evex()); }
static bool supports_sha() { return (_features & CPU_SHA) != 0; }
static bool supports_fma() { return (_features & CPU_FMA) != 0 && supports_avx(); }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if (supports_fma() && UseSSE >= 2) { // Check UseSSE since FMA code uses SSE instructions
if (FLAG_IS_DEFAULT(UseFMA)) {
UseFMA = true;
}
} else if (UseFMA) {

implies fma intrinsic can be used without AVX

Copy link
Contributor

Choose a reason for hiding this comment

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

https://bugs.openjdk.org/browse/JDK-8181616 added support_avx() check because new Fma vectorization needs AVX: https://cr.openjdk.org/~vdeshpande/8181616/webrev.01/
Then we hit bug https://bugs.openjdk.org/browse/JDK-8182114 and bandaid it by restoring UseSSE check.
That change came before 8296168 which switch off UseAVX if UseSSE < 4:
https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/vm_version_x86.cpp#L908

This FMA check happens after UseSSE and UseAVX are set. I suggest to remove UseSSE check here instead and keep support_avx().

Copy link
Contributor

Choose a reason for hiding this comment

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

Saying that. You may remove support_avx() here but you need to add it to assembler vector instructions which have only support_fma() check now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the references! I have reverted this change and will adjust the Graal intrinsic accordingly.

@mur47x111
Copy link
Contributor Author

/label remove hotspot

@mur47x111
Copy link
Contributor Author

/label add hotspot-compiler

@openjdk openjdk bot removed the hotspot hotspot-dev@openjdk.org label Aug 3, 2023
@openjdk
Copy link

openjdk bot commented Aug 3, 2023

@mur47x111
The hotspot label was successfully removed.

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

openjdk bot commented Aug 3, 2023

@mur47x111
The hotspot-compiler label was successfully added.

Copy link
Member

@dougxc dougxc left a comment

Choose a reason for hiding this comment

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

The JVMCI changes look good to me but someone else still needs to review the C1, C2 and shared assembler changes.

@openjdk
Copy link

openjdk bot commented Aug 3, 2023

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

8313372: [JVMCI] Export vmIntrinsics::is_intrinsic_available results to JVMCI compilers.

Reviewed-by: dnsimon, kvn

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

  • 049b55f: 8314019: Add gc logging to jdk/jfr/event/gc/detailed/TestZAllocationStallEvent.java
  • a39ed10: 8314116: C2: assert(false) failed: malformed control flow after JDK-8305636
  • 1de5bf1: 8314106: C2: assert(is_valid()) failed: must be valid after JDK-8305636
  • 5c91622: 8314117: RISC-V: Incorrect VMReg encoding in RISCV64Frame.java
  • 6bbcef5: 8313948: Remove unnecessary static fields defaultUpper/defaultLower in sun.net.PortConfig
  • b88c273: 8313743: Make fields final in sun.nio.ch
  • ec0cc63: 8313904: [macos] All signing tests which verifies unsigned app images are failing
  • 7332502: 8314139: TEST_BUG: runtime/os/THPsInThreadStackPreventionTest.java could fail on machine with large number of cores
  • 8f1c134: 8313798: [aarch64] sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java sometimes times out on aarch64
  • 1232677: 8313244: NM flags handling in configure process
  • ... and 99 more: https://git.openjdk.org/jdk/compare/cff25dd574203d0840d11ce083a5b825fb26d61d...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.

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 (@dougxc, @vnkozlov) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 3, 2023
@dean-long
Copy link
Member

I don't having the same logic in two places, because then those two places need to be kept in sync. Either the stubs should be generated based on is_intrinsic_supported(), or is_intrinsic_supported() should check if the stub was generated.

@mur47x111
Copy link
Contributor Author

I don't having the same logic in two places, because then those two places need to be kept in sync. Either the stubs should be generated based on is_intrinsic_supported(), or is_intrinsic_supported() should check if the stub was generated.

I have dropped the redundant CPU feature checks, and for those intrinsics with stubs, I tested if the stub pointer is nullptr in C2Compiler::is_intrinsic_supported

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.

@vnkozlov
Copy link
Contributor

@mur47x111 please, rerun testing with latest version before integration.

@mur47x111
Copy link
Contributor Author

Passed tier1-3

@mur47x111
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Aug 14, 2023
@openjdk
Copy link

openjdk bot commented Aug 14, 2023

@mur47x111
Your change (at version 028aaf5) is now ready to be sponsored by a Committer.

@dougxc
Copy link
Member

dougxc commented Aug 14, 2023

/sponsor

@openjdk
Copy link

openjdk bot commented Aug 14, 2023

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

  • 049b55f: 8314019: Add gc logging to jdk/jfr/event/gc/detailed/TestZAllocationStallEvent.java
  • a39ed10: 8314116: C2: assert(false) failed: malformed control flow after JDK-8305636
  • 1de5bf1: 8314106: C2: assert(is_valid()) failed: must be valid after JDK-8305636
  • 5c91622: 8314117: RISC-V: Incorrect VMReg encoding in RISCV64Frame.java
  • 6bbcef5: 8313948: Remove unnecessary static fields defaultUpper/defaultLower in sun.net.PortConfig
  • b88c273: 8313743: Make fields final in sun.nio.ch
  • ec0cc63: 8313904: [macos] All signing tests which verifies unsigned app images are failing
  • 7332502: 8314139: TEST_BUG: runtime/os/THPsInThreadStackPreventionTest.java could fail on machine with large number of cores
  • 8f1c134: 8313798: [aarch64] sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java sometimes times out on aarch64
  • 1232677: 8313244: NM flags handling in configure process
  • ... and 99 more: https://git.openjdk.org/jdk/compare/cff25dd574203d0840d11ce083a5b825fb26d61d...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Aug 14, 2023

@dougxc @mur47x111 Pushed as commit 4164693.

💡 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

graal graal-dev@openjdk.org hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants