Skip to content

[hipDNN] [ALMIOPEN-2156] - Add runtime (dlopen) backend-loading mode#8792

Draft
mousdahl-amd wants to merge 1 commit into
developfrom
users/mousdahl-amd/hipdnn-backend-dynamic-load
Draft

[hipDNN] [ALMIOPEN-2156] - Add runtime (dlopen) backend-loading mode#8792
mousdahl-amd wants to merge 1 commit into
developfrom
users/mousdahl-amd/hipdnn-backend-dynamic-load

Conversation

@mousdahl-amd

Copy link
Copy Markdown
Contributor

Summary

Adds an opt-in runtime-load mode for the header-only hipDNN frontend. A new hipdnn_frontend_dynamic CMake interface target resolves the backend at runtime via dlopen/dlsym (Linux) or LoadLibrary/GetProcAddress (Windows), so consumers like libMIOpen.so can use the frontend without inheriting a hard DT_NEEDED on libhipdnn_backend. The consumer chooses at their own configure time by linking hipdnn_frontend (direct-link, existing behavior) or hipdnn_frontend_dynamic (runtime-load) — no hipDNN rebuild required to switch.

Risk Assessment

Medium risk. This adds a new feature path (opt-in consumer target) that touches the core frontend interface (IHipdnnBackend +3 methods), CMake packaging (two exported targets over shared headers), and logging routing. Default behavior is unchanged — existing consumers linking hipdnn_frontend are unaffected. Local unit coverage is strong (1522 tests), but Linux and GPU execution testing of the dynamic path are still pending.

ASIC Coverage

Standard PR CI is sufficient. This is ASIC-independent frontend-to-backend wiring: it changes how backend symbols are resolved (linked vs. dlopen'd), not which kernels run or how ops dispatch. No kernel selection, support surface, or default behavior is affected.

Testing Summary

  • hipDNN frontend unit tests (1522 tests) verify the direct-link path is unaffected and the dynamic wrapper resolves symbols correctly.
  • Link-only static check confirms no backend symbol is referenced directly when compiled in runtime-load mode.
  • Compile-only validation of the dynamic sample confirms the installed hipdnn_frontend_dynamic target is consumable with zero backend symbol references.
  • Linux build/test and GPU execution of the dynamic sample are pending.

Testing Checklist

  • hipDNN frontend unit tests - cmake --build build --target hipdnn_frontend_tests - Status: Passed (1522/1522, Windows)
  • Runtime-load static check - cmake --build build --target hipdnn_frontend_runtime_load_static_check - Status: Passed (Windows)
  • Dynamic sample compile validation - clang++ compile against installed headers with HIPDNN_FRONTEND_RUNTIME_LOAD_BACKEND - Status: Passed (Windows)
  • Linux build and unit tests - Status: Pending
  • Dynamic sample GPU execution (Windows) - Status: Pending
  • Dynamic sample GPU execution (Linux) - Status: Pending
  • PR CI - GitHub PR checks - Status: Pending

Technical Changes

  • Adds HipdnnDynamicBackendWrapper, an IHipdnnBackend implementation that resolves all ~29 backend entry points via dlopen/dlsym at construction time, caching typed function pointers. decltype(&symbol) is used in an unevaluated context so no link-time reference is created.
  • Adds DynamicBackendLibrary.hpp with a call_once-guarded library handle opener and a resolveSymbol helper, reusing the cross-platform loader already in hipdnn_data_sdk::utilities.
  • Extracts the direct-link wrapper into HipdnnDirectBackendWrapper.hpp (renamed from HipdnnBackendWrapper) to mirror the dynamic wrapper's file structure. BackendWrapper.hpp now contains only the factory logic.
  • Extends IHipdnnBackend with 3 logging methods (setUserLogCallbackExt, backendSetGlobalLogLevelExt, backendGetGlobalLogLevelExt) so the user-facing logging APIs route through the interface instead of calling backend symbols directly. The logging callback pointer stays resolved via a standalone helper to avoid re-entering the loader during init.
  • Ships two installed CMake interface targets over the same headers: hipdnn_frontend (direct-link, unchanged) and hipdnn_frontend_dynamic (runtime-load). The dynamic target borrows backend compile usage requirements via $<TARGET_PROPERTY:...> generator expressions without linking the library.
  • Adds a link-only static-check test (hipdnn_frontend_runtime_load_static_check) that links the shipped hipdnn_frontend_dynamic target — a successful link proves no backend symbol leaks through in runtime-load mode.
  • Adds a post-install dynamic sample (samples/dynamic/ConvFpropDynamic.cpp) that links only hipdnn_frontend_dynamic, builds and verifies a deterministic convolution, proving the installed target is end-to-end consumable without the backend on the link line.

@mousdahl-amd mousdahl-amd changed the title [hipDNN] ALMIOPEN-2156 - Add runtime (dlopen) backend-loading mode [hipDNN] [ALMIOPEN-2156] - Add runtime (dlopen) backend-loading mode Jun 24, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.67971% with 169 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...nn_frontend/detail/HipdnnDynamicBackendWrapper.hpp 37.39% 136 Missing and 3 partials ⚠️
...dnn_frontend/detail/HipdnnDirectBackendWrapper.hpp 90.00% 12 Missing ⚠️
...ude/hipdnn_frontend/detail/IncompatibleBackend.hpp 0.00% 9 Missing ⚠️
...e/hipdnn_frontend/detail/DynamicBackendLibrary.hpp 76.00% 5 Missing and 1 partial ⚠️
.../include/hipdnn_frontend/detail/BackendWrapper.hpp 87.50% 0 Missing and 3 partials ⚠️

❌ Your project status has failed because the head coverage (77.90%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8792      +/-   ##
===========================================
- Coverage    65.01%   65.00%   -0.01%     
===========================================
  Files         2610     2613       +3     
  Lines       405621   405953     +332     
  Branches     60550    60587      +37     
===========================================
+ Hits        263692   263863     +171     
- Misses      122015   122169     +154     
- Partials     19914    19921       +7     
Flag Coverage Δ *Carryforward flag
TensileLite 31.04% <ø> (ø) Carriedforward from 74da4bc
hipBLAS 90.62% <ø> (ø) Carriedforward from 74da4bc
hipBLASLt 41.25% <ø> (ø) Carriedforward from 74da4bc
hipCUB 82.68% <ø> (ø) Carriedforward from 74da4bc
hipDNN 86.50% <58.68%> (-0.24%) ⬇️
hipFFT 50.88% <ø> (ø) Carriedforward from 74da4bc
hipRAND 76.12% <ø> (ø) Carriedforward from 74da4bc
hipSOLVER 69.18% <ø> (ø) Carriedforward from 74da4bc
hipSPARSE 86.55% <ø> (ø) Carriedforward from 74da4bc
rocBLAS 48.08% <ø> (ø) Carriedforward from 74da4bc
rocFFT 47.40% <ø> (ø) Carriedforward from 74da4bc
rocRAND 57.04% <ø> (ø) Carriedforward from 74da4bc
rocSOLVER 77.90% <ø> (ø) Carriedforward from 74da4bc
rocSPARSE 72.37% <ø> (ø) Carriedforward from 74da4bc
rocThrust 91.34% <ø> (ø) Carriedforward from 74da4bc

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...ipdnn/frontend/include/hipdnn_frontend/Logging.hpp 78.18% <100.00%> (+3.18%) ⬆️
.../hipdnn_frontend/detail/HipdnnBackendInterface.hpp 100.00% <ø> (ø)
.../include/hipdnn_frontend/detail/BackendWrapper.hpp 92.86% <87.50%> (+3.27%) ⬆️
...e/hipdnn_frontend/detail/DynamicBackendLibrary.hpp 76.00% <76.00%> (ø)
...ude/hipdnn_frontend/detail/IncompatibleBackend.hpp 61.63% <0.00%> (-7.20%) ⬇️
...dnn_frontend/detail/HipdnnDirectBackendWrapper.hpp 90.00% <90.00%> (ø)
...nn_frontend/detail/HipdnnDynamicBackendWrapper.hpp 37.39% <37.39%> (ø)

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants