-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8265403: consolidate definition of CPU features #3558
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
Conversation
|
👋 Welcome back dnsimon! A progress list of the required criteria for merging this PR into |
| } | ||
|
|
||
| Map<String, Long> constants = config.getStore().getConstants(); | ||
| Function<String, CPUFeature> nameToFeature = name -> name.equals("3DNOW_PREFETCH") ? CPUFeature.AMD_3DNOW_PREFETCH : CPUFeature.valueOf(name); |
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.
The AMD_3DNOW_PREFETCH enum constant has to keep its old name to preserve backward compatibility.
| if (_features & CPU_LSE) strcat(buf, ", lse"); | ||
| if (_features & CPU_SVE) strcat(buf, ", sve"); | ||
| if (_features & CPU_SVE2) strcat(buf, ", sve2"); | ||
| #define ADD_FEATURE_IF_SUPPORTED(id, name, bit) if (_features & CPU_##id) strcat(buf, ", " name); |
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.
I'm not sure why only some of the supported AArch64 CPU features were being added to _features_string but I assume there's no harm in adding them all.
| static const char* _features_names[]; | ||
|
|
||
| // NB! When adding new CPU feature detection consider updating vmStructs_x86.hpp, vmStructs_jvmci.hpp, and VM_Version::get_processor_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.
No need for this comment any more as the derivative declarations are now automatically kept up to date.
Webrevs
|
|
/label add hotspot-compiler |
|
@vnkozlov |
|
/label add hotspot-runtime |
|
@vnkozlov |
|
/label remove hotspot |
|
@vnkozlov The |
|
@vnkozlov |
vnkozlov
left a comment
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.
Please, update copyright years in files you touched.
| decl(AVX512_VBMI2, "avx512_vbmi2", 44) /* VBMI2 shift left double instructions */ \ | ||
| decl(AVX512_VBMI, "avx512_vbmi", 45) /* Vector BMI instructions */ \ | ||
| decl(HV, "hv", 46) /* Hypervisor instructions */ | ||
| #define DECLARE_CPU_FEATURE_FLAG(id, name, bit) CPU_##id = (1ULL << bit), |
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.
Add empty line before it to separate CPU_FEATURE_FLAGS macro more clear.
| decl(SVE2, "sve2", 28) \ | ||
| decl(STXR_PREFETCH, "stxr_prefetch", 29) \ | ||
| decl(A53MAC, "a53mac", 30) | ||
| #define DECLARE_CPU_FEATURE_FLAG(id, name, bit) CPU_##id = (1 << bit), |
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.
Add empty line before to separate CPU_FEATURE_FLAGS macro.
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.
Ok.
| #define VM_LONG_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant) | ||
|
|
||
| #define DECLARE_LONG_CPU_FEATURE_CONSTANT(id, name, bit) GENERATE_VM_LONG_CONSTANT_ENTRY(VM_Version::CPU_##id) | ||
| #define VM_LONG_CPU_FEATURE_CONSTANTS CPU_FEATURE_FLAGS(DECLARE_LONG_CPU_FEATURE_CONSTANT) |
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.
Do we need to keep VM_LONG_CONSTANTS_CPU after you removed its body here and in vmStructs_jvmci.cpp?
What about VM_INT_CONSTANTS_CPU here? vmStructs_jvmci.cpp duplicates it.
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.
vmStructs.cpp and vmStructs_jvmci.cpp are disjoint. This file (i.e. vmStructs_x86.hpp) is only used by vmStructs.cpp.
vmStructs.cpp expects all macros such as VM_LONG_CONSTANTS_CPU to be defined.
vmStructs_jvmci.cpp will provide a dummy definition for missing macros.
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.
Got it. Even so they are empty everywhere :(
| declare_constant(VM_Version::CPU_STXR_PREFETCH) \ | ||
| declare_constant(VM_Version::CPU_A53MAC) | ||
| #define DECLARE_INT_CPU_FEATURE_CONSTANT(id, name, bit) GENERATE_VM_INT_CONSTANT_ENTRY(VM_Version::CPU_##id) | ||
| #define VM_INT_CPU_FEATURE_CONSTANTS CPU_FEATURE_FLAGS(DECLARE_INT_CPU_FEATURE_CONSTANT) |
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.
Missing #undef DECLARE_INT_CPU_FEATURE_CONSTANT.
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.
No, it must stay defined up to the point VM_INT_CPU_FEATURE_CONSTANTS is used. Since this is a .cpp file, it's ok to leave it defined.
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.
I see.
| declare_constant(VM_Version::CPU_AVX512_VBMI) \ | ||
| declare_constant(VM_Version::CPU_HV) | ||
| #define DECLARE_LONG_CPU_FEATURE_CONSTANT(id, name, bit) GENERATE_VM_LONG_CONSTANT_ENTRY(VM_Version::CPU_##id) | ||
| #define VM_LONG_CPU_FEATURE_CONSTANTS CPU_FEATURE_FLAGS(DECLARE_LONG_CPU_FEATURE_CONSTANT) |
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.
Missing #undef DECLARE_LONG_CPU_FEATURE_CONSTANT.
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.
Same comment as for DECLARE_INT_CPU_FEATURE_CONSTANT.
| for (Entry<String, Long> e : constants.entrySet()) { | ||
| long bitMask = e.getValue(); | ||
| String key = e.getKey(); | ||
| if (key.startsWith("VM_Version::CPU_")) { |
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.
As I understand this code, it goes over constants values passed from VM and Trying to map them to enumType. It catches cases when a value is missing in enumType. What about case when enumType has extra value which is not defined in constants?
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 could warn about that but cannot remove it without breaking backwards capability for JVMCI wrt Graal. Such a deleted capability will simply be seen as "not supported" by Graal.
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.
Okay.
vnkozlov
left a comment
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.
You need review from Runtime group too.
|
@dougxc 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 105 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. ➡️ To integrate this PR with the above commit message to the |
iklam
left a comment
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.
LGTM
|
/integrate |
|
@dougxc Since your change was applied there have been 112 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 5aed446. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
While porting JDK-8224974 to Graal, I noticed that new CPU features were defined for x86 and AArch64 without being exposed via JVMCI. To avoid this problem in future, this PR updates x86 and AArch64 to define CPU features with a single macro that is used to generate enum declarations as well as vmstructs entries.
In addition, the JVMCI API is updated to exposes the new CPU feature constants and now has a check that ensure these constants are in sync with the underlying macro definition.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3558/head:pull/3558$ git checkout pull/3558Update a local copy of the PR:
$ git checkout pull/3558$ git pull https://git.openjdk.java.net/jdk pull/3558/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 3558View PR using the GUI difftool:
$ git pr show -t 3558Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3558.diff