Skip to content

Conversation

@ScottTodd
Copy link
Member

@ScottTodd ScottTodd commented May 9, 2025

Fixes #526. Upstream PR: ROCm/hip#3789.

  • The find_path here is looking for the directory containing hipconfig. On Windows, hipconfig has the .exe suffix.
  • The _EXECUTABLE code has the option of .bat or exe suffixes for hipcc and hipconfig as both versions exist. CMake's find_program only finds the .exe versions, so that code should not append .bat onto the .exe (e.g. hipconfig.exe.bat).

@ScottTodd
Copy link
Member Author

cc @jammm

@ScottTodd
Copy link
Member Author

Tested more and PyTorch specifically wants the .exe versions of these scripts. It is not equipped to run the .bat versions.

  • With .exe, I get --hip-version=6.5.25183-d47861973 deep in TheRock\external-builds\pytorch\src\build\build.ninja.
  • With .bat, I get
    --hip-version=
    C�L�I�N�K� �(.venv) C�L�I�N�K� �D:\projects\TheRock3\external-builds\pytorch\src\build>"D:\backup\TheRock\2025_05_09_edits\dist\rocm\bin\hipconfig" --version 
    6.5.25183-d47861973 
    

Comment on lines 25 to 31
if(NOT UNIX)
get_filename_component(HIPCONFIG_EXECUTABLE_EXT ${HIP_HIPCONFIG_EXECUTABLE} EXT)
- if(NOT HIPCONFIG_EXECUTABLE_EXT STREQUAL ".bat")
+ if(NOT (HIPCONFIG_EXECUTABLE_EXT STREQUAL ".bat" OR HIPCONFIG_EXECUTABLE_EXT STREQUAL ".exe"))
set(HIP_HIPCONFIG_EXECUTABLE "${HIP_HIPCONFIG_EXECUTABLE}.bat")
set(HIP_HIPCC_EXECUTABLE "${HIP_HIPCC_EXECUTABLE}.bat")
endif()
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe we could remove this whole section of code and only use .exe? I guess we'd need to see if projects other than PyTorch are expecting the .bat file. Another fix would be to let it continue to use the .bat, but then teach PyTorch to run that instead of a regular executable.

        get_filename_component(HIPCONFIG_EXECUTABLE_EXT ${HIP_HIPCONFIG_EXECUTABLE} EXT)
        if(NOT HIPCONFIG_EXECUTABLE_EXT STREQUAL ".bat")
           set(HIP_HIPCONFIG_EXECUTABLE "${HIP_HIPCONFIG_EXECUTABLE}.bat")
           set(HIP_HIPCC_EXECUTABLE "${HIP_HIPCC_EXECUTABLE}.bat")
         endif()

Copy link
Member Author

@ScottTodd ScottTodd May 12, 2025

Choose a reason for hiding this comment

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

I don't understand the code at ROCm/hip@73b520a and ROCm/hip@952028a. Maybe those commits predate having .exe files and only having .bat or something? Can't tell from the empty commit messages. I'll propose we just remove this file extension code and take what find_program returns to us, which should be .exe.

Copy link
Member Author

Choose a reason for hiding this comment

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

I made that change and sent ROCm/hip#3789 upstream.

@ScottTodd ScottTodd changed the title Fix FindHIP.cmake search for hipconfig on Windows. [windows] Fix FindHIP.cmake search for hipconfig. May 12, 2025
@ScottTodd ScottTodd requested a review from marbre May 13, 2025 16:08
find_path(
HIP_ROOT_DIR
- NAMES bin/hipconfig
+ NAMES bin/hipconfig${CMAKE_EXECUTABLE_SUFFIX}
Copy link
Member

Choose a reason for hiding this comment

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

From the code below it seem one was looking for a .bat but following the docs CMAKE_EXECUTABLE_SUFFIX, refers to .exe on Windows. Is this the expected behavior then?

Copy link
Member

Choose a reason for hiding this comment

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

Ah I should have read the PR description more carefully, as it is!

Copy link
Member Author

Choose a reason for hiding this comment

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

I also added more context on the upstream PR I sent.

@ScottTodd ScottTodd merged commit c7f020f into main May 13, 2025
17 of 18 checks passed
@ScottTodd ScottTodd deleted the users/scotttodd/windows-findhip branch May 13, 2025 19:54
@github-project-automation github-project-automation bot moved this from TODO to Done in TheRock Triage May 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Windows] FindHIP.cmake should search for hipconfig.exe instead of hipconfig

4 participants