Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions clients/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,15 @@ endif()

if (NOT WIN32)
if (BUILD_WITH_ROCTX)
target_link_libraries(rocsparse-bench PRIVATE -lroctx64)
target_compile_definitions( rocsparse-bench PRIVATE ROCSPARSE_CLIENTS_WITH_ROCTX )

if(ROCTRACER_INCLUDE_DIR AND ROCTX_LIBRARY)
# Add the include directory
target_include_directories(rocsparse-bench PRIVATE ${ROCTRACER_INCLUDE_DIR})

# Link the rocTx lib
target_link_libraries(rocsparse-bench PRIVATE ${ROCTX_LIBRARY})
target_compile_definitions( rocsparse-bench PRIVATE ROCSPARSE_CLIENTS_WITH_ROCTX )
endif()
endif()
endif()

Expand Down
10 changes: 8 additions & 2 deletions clients/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,14 @@ endif()

if (NOT WIN32)
if (BUILD_WITH_ROCTX)
Copy link

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

[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.

Copilot uses AI. Check for mistakes.
target_link_libraries(rocsparse-test PRIVATE -lroctx64)
target_compile_definitions( rocsparse-test PRIVATE ROCSPARSE_CLIENTS_WITH_ROCTX )
if(ROCTRACER_INCLUDE_DIR AND ROCTX_LIBRARY)
# Add the include directory
target_include_directories(rocsparse-test PRIVATE ${ROCTRACER_INCLUDE_DIR})

# Link the rocTx lib
target_link_libraries(rocsparse-test PRIVATE ${ROCTX_LIBRARY})
target_compile_definitions( rocsparse-test PRIVATE ROCSPARSE_CLIENTS_WITH_ROCTX )
endif()
endif()
endif()

Expand Down
46 changes: 44 additions & 2 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,50 @@ endif()

if (NOT WIN32)
if (BUILD_SHARED_LIBS AND BUILD_WITH_ROCTX)
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)")
Copy link

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

Use CACHE TYPE PATH instead of STRING for ROCTX_PATH so CMake GUI tools recognize it as a filesystem path.

Suggested change
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)")

Copilot uses AI. Check for mistakes.

find_path(ROCTRACER_INCLUDE_DIR
NAMES roctracer/roctx.h
HINTS
${ROCTX_PATH}
${ROCTX_PATH}/include
/opt/rocm/include
${ROCTX_PATH}/../include
DOC "Path to the roctracer include directory containing roctx.h")

find_library(ROCTX_LIBRARY
NAMES roctx64
HINTS
${ROCTX_PATH} # User-provided path
${ROCTX_PATH}/lib
${ROCTX_PATH}/lib64
PATHS
/opt/rocm/lib # Default ROCm path
)

if(ROCTRACER_INCLUDE_DIR AND ROCTX_LIBRARY)
message(STATUS "Found roctracer include directory: ${ROCTRACER_INCLUDE_DIR}")
message(STATUS "Found roctx library: ${ROCTX_LIBRARY}")

# Add the include directory
target_include_directories(rocsparse PRIVATE ${ROCTRACER_INCLUDE_DIR})

# Link the rocTx lib
target_link_libraries(rocsparse PRIVATE ${ROCTX_LIBRARY})
target_compile_definitions( rocsparse PRIVATE ROCSPARSE_BUILT_WITH_ROCTX )
message(STATUS "ROCTX tracing support enabled for target rocsparse.")
else()
message(WARNING "ROCTX tracing will be disabled for target rocsparse.")

if(NOT ROCTRACER_INCLUDE_DIR)
message(WARNING "Header 'roctracer/roctx.h' not found.")
endif()

if(NOT ROCTX_LIBRARY)
message(WARNING "Library 'roctx64' not found. ROCTX_PATH: '${ROCTX_PATH}' Default PATH: '/opt/rocm/lib'.")
endif()
endif()
endif()
endif()

Expand Down