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

Replace CPU APIs on Power #5197

Merged
merged 1 commit into from
Jun 10, 2020
Merged

Conversation

harryyu1994
Copy link
Contributor

Issue: #4339

Signed-off-by: Harry Yu harryyu1994@gmail.com

compiler/env/OMRCPU.cpp Outdated Show resolved Hide resolved
compiler/env/OMRCPU.hpp Outdated Show resolved Hide resolved
@harryyu1994 harryyu1994 changed the title Replace CPU APIs on Power WIP: Replace CPU APIs on Power May 15, 2020
@gita-omr
Copy link
Contributor

@zl-wang @aviansie-ben fyi

@fjeremic fjeremic self-assigned this May 16, 2020
@harryyu1994
Copy link
Contributor Author

Will squash the new commits once my local tests pass.

compiler/p/env/OMRCPU.cpp Outdated Show resolved Hide resolved
compiler/p/env/OMRCPU.cpp Outdated Show resolved Hide resolved
compiler/p/env/OMRCPU.cpp Show resolved Hide resolved
compiler/p/env/OMRCPU.cpp Show resolved Hide resolved
@harryyu1994
Copy link
Contributor Author

@mpirvu FYI, processor detection work on Power

@harryyu1994 harryyu1994 changed the title WIP: Replace CPU APIs on Power Replace CPU APIs on Power May 20, 2020
@zl-wang
Copy link
Contributor

zl-wang commented May 20, 2020

Could you show the detected results from before and after this change? e.g. verbose log on a couple different hardwares (P7/P8/P9, LE/BE) Expected same results: CPU type, feature-set, and endian-ness.

Blind testing is not enough, that is.

compiler/env/OMRCompilerEnv.cpp Outdated Show resolved Hide resolved
compiler/env/OMRCompilerEnv.cpp Outdated Show resolved Hide resolved
@harryyu1994
Copy link
Contributor Author

harryyu1994 commented May 20, 2020

Could you show the detected results from before and after this change? e.g. verbose log on a couple different hardwares (P7/P8/P9, LE/BE) Expected same results: CPU type, feature-set, and endian-ness.

Blind testing is not enough, that is.

The way I tested it was to add fatal asserts for every query then launch the build in our pool of power machines. (That's how I did it for all the platforms). The assert is basically old api against new api so it ensures that the new api always return the same result as the old api. If you don't think that's enough testing, then we can do what you suggested but I may need assistance on getting these hardwares.

The test I have currently (as an example)

TR_ASSERT_FATAL((_processorDescription.processor == p) == (self()->id() == self()->get_old_processor_type_from_new_processor_type(p)), "is test %d failed, id() %d, _processorDescription.processor %d", p, self()->id(), _processorDescription.processor);

In this case new api is:

(_processorDescription.processor == p)

old api is:

self()->id() == self()->get_old_processor_type_from_new_processor_type(p)

and this is for cpu.is()

Everytime the new api is invoked, we will run the old api to verify if the new api output is correct.

@harryyu1994

This comment has been minimized.

@harryyu1994

This comment has been minimized.

@zl-wang
Copy link
Contributor

zl-wang commented May 21, 2020

we don't have any Atlas systems anywhere. old_processor (the old way) identifying Atlas seems something interestingly broken.

@harryyu1994
Copy link
Contributor Author

I corrected my comment, not an atlas but an OMR_PROCESSOR_PPC_P6 query which is pretty common in the codebase. The old processor returns 16 which seems to be a bogus value. (TR_s370gp14, 16, z processor somehow).

@harryyu1994

This comment has been minimized.

@fjeremic
Copy link
Contributor

@genie-omr build all

@fjeremic fjeremic requested a review from mpirvu May 22, 2020 16:54
@harryyu1994

This comment has been minimized.

@harryyu1994
Copy link
Contributor Author

Going to check if this change breaks OpenJ9..

@harryyu1994 harryyu1994 force-pushed the replaceCPUAPI_P branch 3 times, most recently from e7da235 to 88f08eb Compare June 8, 2020 15:11
@harryyu1994
Copy link
Contributor Author

harryyu1994 commented Jun 8, 2020

This is not safe to merge. As far as I can tell, the necessary changes for POWER10 support that I mentioned in my last review have not been made.

As it stands, P10 support will be enabled by default and the get_old_processor_type_from_new_processor_type method will assert-fail if run on POWER10, since it does not handle that processor type.

This is not true unless I switch the power10 queries to the new api form which I won't do in this PR and I put the reasons in the following paragraph. (The old api's test against cpu.id() so even if we have cpu._processorDescription.processor == OMR_PPC_P10 it's not going to break anything)

TR_EnableExperimentalPower10Support can't be checked that early when detect() is called. We do have similar issues on Z and they were handled in a method called applyUserOptions(). I'm planning to do the same for Power.
applyUserOptions() is called in OpenJ9 and we need to change it to be non Z specific. That will make this change dependent on OpenJ9 and we don't want that circular dependency as the OpenJ9 change already depends on this one.
So by leaving out the power10 queries, we can get this change in. Then I'll fix the applyUserOptions() call in OpenJ9. After all that is done, we can have a new PR to switch the power10 queries to the new form. (There is only 1 instance in OMR)

@harryyu1994 harryyu1994 force-pushed the replaceCPUAPI_P branch 2 times, most recently from 93c0f40 to 82933d6 Compare June 8, 2020 20:58
Copy link
Contributor

@aviansie-ben aviansie-ben left a comment

Choose a reason for hiding this comment

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

Alright, I'm happy with the current situation for POWER10 here, since a plan has been outlined for how this can be moved forward without breaking anything. Great work!

@fjeremic
Copy link
Contributor

fjeremic commented Jun 8, 2020

@genie-omr build all

@harryyu1994
Copy link
Contributor Author

All checks passed. I will need to rebase to master (there was an OpenJ9 build break on Z) and verify with OpenJ9 to make sure nothing breaks. Will update when test finishes.

Issue: eclipse-omr#4339

Signed-off-by: Harry Yu <harryyu1994@gmail.com>
@harryyu1994
Copy link
Contributor Author

OpenJ9 tests passed on all platforms. We are good to go!

@fjeremic
Copy link
Contributor

@genie-omr build all

@fjeremic
Copy link
Contributor

@harryyu1994 can you confirm eclipse-openj9/openj9#9571 will not break following this merge?

@harryyu1994
Copy link
Contributor Author

@harryyu1994 can you confirm eclipse/openj9#9571 will not break following this merge?

@fjeremic Just confirmed that eclipse-openj9/openj9#9571 works fine with this change. I assume you were asking this question to make sure no more omr dependencies is needed for eclipse-openj9/openj9#9571.

@fjeremic fjeremic merged commit 31fae28 into eclipse-omr:master Jun 10, 2020
@harryyu1994 harryyu1994 deleted the replaceCPUAPI_P branch June 10, 2020 19:03
harryyu1994 added a commit to harryyu1994/openj9 that referenced this pull request Sep 23, 2020
Summary of changes:
- Retire old version cpu detection code on Power
- Move `CPU::getProcessorDescription()` to base J9CPU class as the 3 platforms (X, Z, Power) share the same code. There is no need to have 3 copies
- Reasons for the removal:
  - We kept the old version because we wanted to make sure new version and old version give us the same behaviour
  - Now it's been a few month and we don't see any bugs with the new version there's no reason to keep the old version
  - Also we want to prevent developers from using the old version.

Old design
- Initializes the `TR_Processor` struct via j9port library
  - Initialization occurs in `TR_J9VM::initializeProcessorType()`
  - obtain cpu information using `CPU::TO_PORTLIB_getJ9ProcessorDesc()`
  - `TR::Compiler->target.cpu.setProcessor` to set processor
- Fields and methods associated with the old design live in `Class CPU`
- Common APIs:
  - `CPU::TO_PORTLIB_getJ9ProcessorDesc()`
  - `j9sysinfo_processor_has_feature(processorDesc, feature)` (j9port library API)
  - `CPU::id()`
  - `CPU::setProcessor(TR_Processor)`

New design
- Initializes the `OMRProcessorDesc` struct via omrport library
  - `CPU::detect()` to initialize `OMRProcessorDesc processorDescription`
  - `CPU::applyUserOptions()` to apply any debug options after initialization
  - `TR::Compiler->target.cpu` singleton variable that holds the CPU instance
  - `comp()->target().cpu` per compilation variable which is used for cross-cpu compilation support
    - For JIT we initialize `comp()->target().cpu` with `TR::Compiler->target.cpu` (Host CPU)
    - For AOT we initialize `comp()->target().cpu` with `TR::Compiler->relocatableTarget.cpu` (Portable CPU)
- Fields and methods associated with the new design live in `Class CPU`
- Common APIs:
  - `CPU::supportsFeature(feature)`
  - `CPU::isAtLeast(OMRProcessorArchitecture)`
- Benefits:
  - Common to all 3 platforms
  - Simpler interface
  - Cross-CPU compilation support (Use one cpu for AOT and another for JIT)
- The implementation for the new design is first introduced here eclipse-omr/omr#5197 and eclipse-openj9#9571

issue: eclipse-omr/omr#4339
depends on: eclipse-omr/omr#5547

Signed-off-by: Harry Yu <harryyu1994@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants