Skip to content

[hipFile] Defer static init to first API call.#4864

Open
systems-assistant[bot] wants to merge 9 commits intodevelopfrom
import/develop/ROCm_hipFile/pr-235
Open

[hipFile] Defer static init to first API call.#4864
systems-assistant[bot] wants to merge 9 commits intodevelopfrom
import/develop/ROCm_hipFile/pr-235

Conversation

@systems-assistant
Copy link
Copy Markdown
Contributor

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

🔁 Imported from ROCm/hipFile#235
🧑‍💻 Originally authored by @jordan-turbofish

jordan-turbofish and others added 9 commits April 7, 2026 13:59
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.
Add an interface for StatsServer, so that a mock doesn't need to call
StatsServer constructor. Adds specialization to ContextDefaultImpl so
that StatsServer is used as default implementation for IStatsServer.
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.
Moves current static init to a hipFileInit function. It will be called
from any public API function.
Allows use when compiled in C++20 for better type checking, but left out
when compiled in C++17 mode.
@jordan-turbofish jordan-turbofish changed the title Defer static init to first API call. [hipFile] Defer static init to first API call. Apr 9, 2026
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.

1 participant