Handle ROCTX using find_path and find_library instead of Findroctx.cmake module#513
Handle ROCTX using find_path and find_library instead of Findroctx.cmake module#513jsandham merged 2 commits intoROCm:developfrom
Conversation
… use Findroctx.cmake modules
There was a problem hiding this comment.
Pull Request Overview
This PR replaces the custom Findroctx.cmake module with direct find_path/find_library calls to locate rocTX (roctracer) headers and library, aligning rocSPARSE with how other ROCm components integrate rocTX.
- Introduce
ROCTX_PATHcache variable and usefind_path/find_libraryinlibrary/CMakeLists.txt - Replace hardcoded
-lroctx64linking in tests and benchmarks with conditional linking to discovered library - Emit clear status and warning messages when rocTX components are found or missing
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| library/CMakeLists.txt | Added ROCTX_PATH, used find_path/find_library, conditional include/link logic and messages. |
| clients/tests/CMakeLists.txt | Updated rocsparse-test to include/link based on found rocTX, wrapped in additional guards. |
| clients/benchmarks/CMakeLists.txt | Updated rocsparse-bench similarly to use discovered rocTX include and library paths. |
Comments suppressed due to low confidence (4)
library/CMakeLists.txt:128
- [nitpick] Inconsistent casing in comment: change 'rocTx' to 'roctx' to match the actual library name.
# Link the rocTx lib
library/CMakeLists.txt:100
- ROCTX_PATH is introduced here but not mentioned in the project README or CMake usage docs; consider documenting its purpose and valid values.
set(ROCTX_PATH "" CACHE STRING "Path to the roctx library (directory containing libroctx64.so)")
clients/tests/CMakeLists.txt:428
- [nitpick] Indent this
endif()to align with the openingif(NOT WIN32)for clearer structure and readability.
endif()
clients/benchmarks/CMakeLists.txt:245
- [nitpick] Indent this
endif()to match its correspondingif(NOT WIN32)block for consistent formatting.
endif()
| target_link_libraries(rocsparse PRIVATE -lroctx64) | ||
| target_compile_definitions( rocsparse PRIVATE ROCSPARSE_BUILT_WITH_ROCTX ) | ||
|
|
||
| set(ROCTX_PATH "" CACHE STRING "Path to the roctx library (directory containing libroctx64.so)") |
There was a problem hiding this comment.
Use CACHE TYPE PATH instead of STRING for ROCTX_PATH so CMake GUI tools recognize it as a filesystem path.
| set(ROCTX_PATH "" CACHE STRING "Path to the roctx library (directory containing libroctx64.so)") | |
| set(ROCTX_PATH "" CACHE PATH "Path to the roctx library (directory containing libroctx64.so)") |
| @@ -416,8 +416,14 @@ endif() | |||
|
|
|||
| if (NOT WIN32) | |||
| if (BUILD_WITH_ROCTX) | |||
There was a problem hiding this comment.
[nitpick] The rocTX integration logic is duplicated between the tests and benchmarks; consider extracting it into a reusable CMake function or macro to reduce duplication.
TorreZuk
left a comment
There was a problem hiding this comment.
Note I thought what you had originally had was okay, but this mostly matches rocBLAS. Ruban can look but that will be next week, you probably don't want to wait. I guess if the ROCTX_PATH is set as documented then a lot of the hints are off for relative directories but that is fine if you cover most installs or fail gracefully.
rocm-cmake could have been good location for temporary common workaround too? @cgmb ? Expect too late for that.
Ignore any of my AI pair programmer review comments that don't make sense.
…ake module (ROCm#513) * Alternate way to handle building rocsparse with roctx since we cannot use Findroctx.cmake modules
Summary of proposed changes:
roctxConfig.cmakefile and so we cannot usefind_package(roctracer)from rocSPARSE.Findroctx.cmakemodule file included as part of rocSPARSE, but this was deemed not appropriate going forward. See Better handle building rocSPARSE with ROC-TX #484find_pathandfind_libraryto search for the roctracer header files and roctx shared library.