Adapt HIPRT compilation for TheRock wheel builds#66
Open
jammm wants to merge 1 commit into
Open
Conversation
PR description: Makes HIPRT usable from the ROCm Python wheel layout used by the Mitsuba/Dr.Jit AMD backend on Windows. - Resolves ROCm LLVM, HIPRTC, bitcode, include, and library paths from the wheel-provided SDK layout. - Adjusts the compiler path setup so embedded HIPRT compilation works without a system ROCm install. - Keeps the changes scoped to discovery/runtime setup needed by the AMD backend integration. Validation: - Built as the HIPRT submodule in the Mitsuba AMD Release build with clang-cl and the ROCm wheel SDK.
There was a problem hiding this comment.
Pull request overview
This PR updates HIPRT’s Windows/ROCm runtime setup to better support ROCm Python wheel SDK layouts by expanding DLL discovery and adjusting runtime compilation behavior, aiming to eliminate reliance on machine-local hard-coded paths.
Changes:
- Add Windows ROCm SDK path discovery for HIP/HIPRTC DLL loading via
ROCM_HOME,ROCM_PATH,HIP_PATH, andVIRTUAL_ENV. - Add AMD-specific runtime compilation path adjustments (HIPRTC usage, program naming, compiler options) and improved diagnostics for empty code objects.
- Add environment override
HIPRT_FORCE_RTIPfor forcing RTIP selection.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| hiprt/impl/hiprt.cpp | Ensures Orochi runtime initialization is performed before context creation. |
| hiprt/impl/Context.cpp | Adds an env-var override for RTIP selection. |
| hiprt/impl/Compiler.h | Extends compiler state/options to support new compilation parameters. |
| hiprt/impl/Compiler.cpp | Introduces Windows HIPRTC symbol loading and AMD compilation adjustments, plus more compile diagnostics and options. |
| hiprt/hiprt_libpath.h | Reworks Windows HIP/HIPRTC DLL search paths to include ROCm wheel SDK layouts. |
| contrib/Orochi/contrib/hipew/src/hipew.cpp | Extends hipew Windows library search to include ROCm wheel SDK layouts and env-based locations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+996
to
+997
| if ( const char* forceRtip = std::getenv( "HIPRT_FORCE_RTIP" ) ) | ||
| return static_cast<uint32_t>( std::atoi( forceRtip ) ); |
Comment on lines
+78
to
+87
| template <typename T> T hiprtcSymbol( const char* name ) | ||
| { | ||
| HMODULE module = GetModuleHandleA( "hiprtc07013.dll" ); | ||
| if ( !module ) | ||
| { | ||
| std::string path = Utility::getEnvVariable( "HIP_PATH" ); | ||
| if ( !path.empty() ) path += "\\bin\\hiprtc07013.dll"; | ||
| module = LoadLibraryA( path.empty() ? "hiprtc07013.dll" : path.c_str() ); | ||
| } | ||
| if ( !module ) throw std::runtime_error( "Could not load hiprtc07013.dll" ); |
Comment on lines
+105
to
+106
| throw std::runtime_error( | ||
| "HIPRT could not load HIPRTC. Make sure the ROCm HIPRTC DLL (for example hiprtc07013.dll) is on PATH." ); |
Comment on lines
+134
to
+135
| static const char** g_hip_paths = hiprt::detail::getHipPaths(); | ||
| static const char** g_hiprtc_paths = hiprt::detail::getHiprtcPaths(); |
Comment on lines
+696
to
+700
| opts.push_back( "-include" ); | ||
| opts.push_back( "hip/hip_runtime.h" ); | ||
| opts.push_back( "-D__HIP_PLATFORM_AMD__=1" ); | ||
| opts.push_back( "-D__USE_HIP__" ); | ||
| opts.push_back( "-D__KERNELCC__" ); |
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 makes HIPRT usable from the ROCm Python wheel SDK layout on Windows without relying on machine-local hard-coded paths.
ROCM_HOME,ROCM_PATH,HIP_PATH, and activeVIRTUAL_ENVlayouts such asLib/site-packages/_rocm_sdk_devel/bin.Validation
mitsuba.set_variant("amd_rgb")and a smalldrjit.amdarray work with ROCm bin removed fromPATH, using onlyROCM_HOME/VIRTUAL_ENVdiscovery.