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

Initialize/shutdown portlib in JitBuilder and Test Compiler #5798

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nbhuiyan
Copy link
Contributor

@nbhuiyan nbhuiyan commented Feb 8, 2021

This is one of the first steps towards enabling the use of the port lib in the OMR Compiler. The responsibilty of initializing and shutting down the port lib is assigned to the JitBuilder and Test Compiler initialization phases, as they do not currently run as part of a VM that uses the OMR Port Library.

In the future, JitBuilder and Test Compiler can have an added initialization API that would accept an initialized omrportlib that is handled as part of a larger VM or runtime init/shutdown should there be JitBuilder user that also uses the OMR Port Lib.

This flexible approach has the benefit of being able to rely on having the port library initialized in the OMR compiler and used throughout the component, while not requiring JitBuilder users to deal with the port library initialization/shutdown if they do not plan on using it in their project.

The port library is already built as a Compiler dependency. The initialized port lib provided to the CompilerEnv constructor is set in the omrPortLib field of the class, from where it can be accessed during the lifetime of the compilation. Currently, the only places using this field in the Compiler is for CPU feature detection, but a fallback mechanism is still in place if the omrPortLib member is not set. These checks and fallback mechanisms can be eliminated after we can ensure all OMR Compiler users are initializing the compiler with an initialized port lib. OpenJ9 already provides the OMR Port Lib during the CompilerEnv initialization, see J9CompilerEnv.cpp.

In draft state while I am yet to fix test failures in cases where JitBuilder is used in test cases that initialize thread and port libraries or initialize or shutdown the JIT more than once per ::testing::Test subclass. Thread library is required to be initialized to initialize port library, and the current set up would cause test failures when thread library is initialized more than once per process. This PR is meant to begin discussions and for me to get some feedback about the approach being proposed here.

Issue: #1644

Signed-off-by: Nazim Bhuiyan nubhuiyan@ibm.com

@nbhuiyan
Copy link
Contributor Author

nbhuiyan commented Feb 8, 2021

@0xdaryl @mstoodle @fjeremic FYI

@@ -298,6 +298,7 @@ function(create_omr_compiler_library)
target_link_libraries(${COMPILER_NAME}
PUBLIC
omr_base
${OMR_PORT_LIB}
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious where is this set exactly? Also @dnakamura any concerns?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mstoodle
Copy link
Contributor

Have you by any chance measured the change in the size of one of the JitBuilder samples, say, when this change is included? I don't think it will make a huge difference but I would like to verify that intuition.

@nbhuiyan
Copy link
Contributor Author

@mstoodle, with this change, I saw about a 4% increase in the on-disk size of the JitBuilder samples.

This change ensures that Port library is initialized and shutdown
when JitBuilder and testcompiler are initialized and shutdown.
This paves the way for using port library features within OMR
Compiler code and replace duplicated functionality through use
of the port library API.

Signed-off-by: Nazim Bhuiyan <nubhuiyan@ibm.com>
@nbhuiyan
Copy link
Contributor Author

nbhuiyan commented Aug 11, 2022

Revived this PR as a result of discussions in #4339. @0xdaryl, @r30shah FYI

On x86, there is a failed test as a result of a check performed as part of supportsFeature. There is a supports_feature_test called in that function that attempts to compare the results of the old vs the new API. However, for the last few AVX-related queries, supports_feature_test would return false if those features are not supported, and this will be interpreted as a mismatch in the old vs new API. @BradleyWood, is this the intended behaviour?

@BradleyWood
Copy link
Contributor

Revived this PR as a result of discussions in #4339. @0xdaryl, @r30shah FYI

On x86, there is a failed test as a result of a check performed as part of supportsFeature. There is a supports_feature_test called in that function that attempts to compare the results of the old vs the new API. However, for the last few AVX-related queries, supports_feature_test would return false if those features are not supported, and this will be interpreted as a mismatch in the old vs new API. @BradleyWood, is this the intended behaviour?

You are right. Might it be time to remove the old vs new comparison?

supports_feature_test should return whether feature checks using
the old and the new API match. However, for some AVX512-related
features, it returned whether a particular feature is supported
instead, resulting in a failed assertion.

Signed-off-by: Nazim Bhuiyan <nubhuiyan@ibm.com>
@nbhuiyan
Copy link
Contributor Author

Removing the old vs. new comparison may be beyond the scope of this PR. I fixed the cases where we may get the incorrect results from supports_feature_test so that the tests pass. This PR is now ready for review.

@nbhuiyan nbhuiyan marked this pull request as ready for review August 11, 2022 23:48
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.

5 participants