[hipFile] Defer static init to first API call.#4864
Merged
Conversation
b34f9d4 to
cf862ac
Compare
cf862ac to
b1218ae
Compare
6038cec to
191baf8
Compare
Adds ContextDefaultImpl, which has a type that defaults to the template type. Can be specialized to use different default type for a given template type.
If multiple interfaces are being mocked, the standard implementation may end up calling mocked functions when constructing. Return the replacement first, so we only construct the standard implementation when it is actually needed.
The interface allows us to create a MStatsServer without calling the StatsServer constructor. This will prevent MStatsServer from calling other functions that may be mocked at test time when init is deferred.
Moves current static init to a hipFileInit function. It will be called from any public API function.
With deferred init, we don't need special handling for the tests.
Allows use when compiled in C++20 for better type checking, but left out when compiled in C++17 mode.
191baf8 to
6761d51
Compare
zbyrne
approved these changes
Apr 24, 2026
systems-assistant Bot
pushed a commit
to ROCm/hipFile
that referenced
this pull request
Apr 24, 2026
MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR moves static initialization of hipFile objects to the first API call. This allows mocking of static objects that call mockable functions, as we can now mock the calls before they are initialized. Changes: - Context has been updated to handle setting the default type for an interface - StatsServer has been changed to use an interface - Context::get() will return a replacement before static initializing a default, if the replacement exists - hipFile static init has been moved to a function that gets called on any API call - Added a system test for calling hipFileRead/Write in a new thread - HIPFILE_STATIC has been removed, reverting to static - Added a concepts check which only occurs if built with C++20 - Added a C++20 build to CI AIHIPFILE-180 [rocm-systems] ROCm/rocm-systems#4864 (commit 8a01273)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR moves static initialization of hipFile objects to the first API call. This allows mocking of static objects that call mockable functions, as we can now mock the calls before they are initialized.
Changes:
AIHIPFILE-180
🔁 Imported from ROCm/hipFile#235
🧑💻 Originally authored by @jordan-turbofish