Skip to content

Adapt HIPRT compilation for TheRock wheel builds#66

Open
jammm wants to merge 1 commit into
GPUOpen-LibrariesAndSDKs:mainfrom
jammm:jam/hip
Open

Adapt HIPRT compilation for TheRock wheel builds#66
jammm wants to merge 1 commit into
GPUOpen-LibrariesAndSDKs:mainfrom
jammm:jam/hip

Conversation

@jammm

@jammm jammm commented Jun 27, 2026

Copy link
Copy Markdown

This PR makes HIPRT usable from the ROCm Python wheel SDK layout on Windows without relying on machine-local hard-coded paths.

  • Resolves ROCm LLVM, HIPRTC, bitcode, include, and library paths from the wheel-provided SDK layout.
  • Dynamically discovers HIP/HIPRTC DLLs from ROCM_HOME, ROCM_PATH, HIP_PATH, and active VIRTUAL_ENV layouts such as Lib/site-packages/_rocm_sdk_devel/bin.
  • Keeps changes scoped to ROCm SDK discovery/runtime setup needed by the Mitsuba/Dr.Jit AMD backend integration.

Validation

  • Built as the HIPRT submodule in the Mitsuba AMD Release build with clang-cl and the ROCm wheel SDK.
  • Verified mitsuba.set_variant("amd_rgb") and a small drjit.amd array work with ROCm bin removed from PATH, using only ROCM_HOME/VIRTUAL_ENV discovery.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and VIRTUAL_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_RTIP for 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 thread hiprt/impl/Context.cpp
Comment on lines +996 to +997
if ( const char* forceRtip = std::getenv( "HIPRT_FORCE_RTIP" ) )
return static_cast<uint32_t>( std::atoi( forceRtip ) );
Comment thread hiprt/impl/Compiler.cpp
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 thread hiprt/impl/Compiler.cpp
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 thread hiprt/hiprt_libpath.h
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 thread hiprt/impl/Compiler.cpp
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__" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants