Repository navigation
[rocshmem] Add rocshmem_hipmodule_init API for CUDA graph compatibility - #3165
Conversation
This commit adds a new API rocshmem_hipmodule_init() that allows user-compiled HIP modules or device bitcode modules to be initialized with rocSHMEM device contexts. This is essential for CUDA graph compatibility. This API replaces manual rocshmem ctx management via rocshmem_get_device_ctx() during JIT compilation. Claude Code is used to assist in this change. Resolves: #2741 Signed-off-by: Dimple Prajapati <dimple.prajapati@amd.com>
Implementation:
- Add HipModuleInitTester class in hipmodule_init_tester.{hpp,cpp}
- Use HIPRTC for runtime kernel compilation
- Calls rocshmem_hipmodule_init() on the compiled module to initialize device symbol.
- Launches simple kernel to verify module initialization
Signed-off-by: Dimple Prajapati <dimple.prajapati@amd.com>
There was a problem hiding this comment.
Pull request overview
Adds a new rocSHMEM host API intended to initialize a user-loaded HIP module’s ROCSHMEM_CTX_DEFAULT symbol so dynamically-loaded device code can use rocSHMEM in CUDA/HIP graph-capture-friendly workflows.
Changes:
- Introduces public API
rocshmem_hipmodule_init(hipModule_t, hipStream_t)and implements it inrocshmem_gpu.cpp. - Adds a new functional test (
hipmodule_init) that HIPRTC-compiles a module definingROCSHMEM_CTX_DEFAULTand attempts to initialize it. - Wires the new test into the functional test harness (enum, factory, and driver mapping) and links
hiprtc.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/rocshmem/include/rocshmem/rocshmem.hpp | Adds the new public API declaration and documentation (removes prior API). |
| projects/rocshmem/src/rocshmem_gpu.cpp | Implements rocshmem_hipmodule_init() using HIP module symbol lookup and async memcpy. |
| projects/rocshmem/tests/functional_tests/hipmodule_init_tester.hpp | Declares new functional tester for HIP module init scenario. |
| projects/rocshmem/tests/functional_tests/hipmodule_init_tester.cpp | Implements HIPRTC compile/load + calls new API, then runs a simple module kernel. |
| projects/rocshmem/tests/functional_tests/tester.hpp | Adds new TestType enum entry for hipmodule init test. |
| projects/rocshmem/tests/functional_tests/tester.cpp | Registers and instantiates the new tester in the factory. |
| projects/rocshmem/tests/functional_tests/CMakeLists.txt | Adds build defines for source/binary include paths and links hiprtc. |
| projects/rocshmem/scripts/functional_tests/driver.sh | Adds CLI name → test number mapping for hipmodule_init. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Address review feedback - Fix rocshmem_hipmodule_init() API because previous implementation was using hipMemcpyFromSymbol() with legacy/default stream. During HIP graph capture, HIP rejects operations requiring legacy stream usage due to implicit sync rules with capturing stream. So API needs to use hipGetSymbolAddress + hipMemcpyAsync() to perform device-to-device copy of device global symbol.
Co-authored-by: Aurelien Bouteiller <abouteil@amd.com>
missing "
|
Looks like the hiprtc is missing a dependency to compile the dynamic code in the CI @drprajap |
yes, because local testing has rocm path set in environment, this was not exposed in my testing, I have explicitly included it now |
|
I think I'm somewhat confused as to why the compiled hiprtc kernel defines its own |
Current test is not using existing rocshmem device library kernels for hiprtc compilation because that requires pulling up lots of dependencies for kernel compilation, I tried that and with existing rocshmem device API definitions, it is not minimal effort. So I chose to orchestrate |
…ty (#3165) * Add rocshmem_hipmodule_init API for CUDA graph compatibility This commit adds a new API rocshmem_hipmodule_init() that allows user-compiled HIP modules or device bitcode modules to be initialized with rocSHMEM device contexts. This is essential for CUDA graph compatibility. This API replaces manual rocshmem ctx management via rocshmem_get_device_ctx() during JIT compilation. Claude Code is used to assist in this change. Resolves: #2741 Signed-off-by: Dimple Prajapati <dimple.prajapati@amd.com> * Add functional test for rocshmem_hipmodule_init API Implementation: - Add HipModuleInitTester class in hipmodule_init_tester.{hpp,cpp} - Use HIPRTC for runtime kernel compilation - Calls rocshmem_hipmodule_init() on the compiled module to initialize device symbol. - Launches simple kernel to verify module initialization Signed-off-by: Dimple Prajapati <dimple.prajapati@amd.com> * Enhance hipmodule_init test for CUDA graph capture validation - Address review feedback - Fix rocshmem_hipmodule_init() API because previous implementation was using hipMemcpyFromSymbol() with legacy/default stream. During HIP graph capture, HIP rejects operations requiring legacy stream usage due to implicit sync rules with capturing stream. So API needs to use hipGetSymbolAddress + hipMemcpyAsync() to perform device-to-device copy of device global symbol. * return ROCSHMEM_ERROR in failure * review feedback * Apply suggestions from code review - Execute moduleInit test in CI Co-authored-by: Aurelien Bouteiller <abouteil@amd.com> * Apply suggestions from code review missing " * add missing rocm path for hiprtc compilation --------- Signed-off-by: Dimple Prajapati <dimple.prajapati@amd.com> Co-authored-by: Aurelien Bouteiller <abouteil@amd.com>
This commit adds a new API rocshmem_hipmodule_init() that allows
user-compiled HIP modules or device bitcode modules to be initialized with
rocSHMEM device contexts. This is essential for CUDA graph compatibility.
This API replaces manual rocshmem ctx management via rocshmem_get_device_ctx()
during JIT compilation.
Resolves: #2741
Technical Details
JIRA ID
Resolves AIROCSHMEM-145
Test Plan
Functional test is added to verify module loading after successfully setting device global symbol.
Submission Checklist