Skip to content

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

Merged
jordan-turbofish merged 8 commits into
developfrom
import/develop/ROCm_hipFile/pr-235
Apr 24, 2026
Merged

[hipFile] Defer static init to first API call.#4864
jordan-turbofish merged 8 commits into
developfrom
import/develop/ROCm_hipFile/pr-235

Conversation

@systems-assistant
Copy link
Copy Markdown
Contributor

@systems-assistant systems-assistant Bot commented Apr 9, 2026

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


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

@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
@jordan-turbofish jordan-turbofish force-pushed the import/develop/ROCm_hipFile/pr-235 branch from b34f9d4 to cf862ac Compare April 15, 2026 18:04
@jordan-turbofish jordan-turbofish requested a review from a team as a code owner April 15, 2026 18:04
@github-actions github-actions Bot added the github actions Pull requests that update GitHub Actions code label Apr 15, 2026
@jordan-turbofish jordan-turbofish force-pushed the import/develop/ROCm_hipFile/pr-235 branch from cf862ac to b1218ae Compare April 15, 2026 18:14
@jordan-turbofish jordan-turbofish force-pushed the import/develop/ROCm_hipFile/pr-235 branch 2 times, most recently from 6038cec to 191baf8 Compare April 23, 2026 21: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.
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.
@jordan-turbofish jordan-turbofish force-pushed the import/develop/ROCm_hipFile/pr-235 branch from 191baf8 to 6761d51 Compare April 23, 2026 23:42
@jordan-turbofish jordan-turbofish merged commit 8a01273 into develop Apr 24, 2026
39 checks passed
@jordan-turbofish jordan-turbofish deleted the import/develop/ROCm_hipFile/pr-235 branch April 24, 2026 17:01
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants