fixed: properly probe for hipify-perl command

error out in configuration instead of surprising user during build
This commit is contained in:
Arne Morten Kvarving committed 2025-11-04 11:08:19 +01:00
1 parent a8c714e276
commit b8df2af8bc
3 files changed
+27 -5

No files matched your search

+13
View File
@@ -70,6 +70,19 @@ if (CONVERT_CUDA_TO_HIP AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.21")
find_package(hipsparse REQUIRED)
find_package(hipblas REQUIRED)
link_libraries(roc::hipblas roc::hipsparse)
find_program(HIPIFY_PERL_COMMAND
NAMES hipify-perl
HINTS
PATH /opt/rocm/bin
)
if(HIPIFY_PERL_COMMAND)
add_executable(hipify-perl IMPORTED GLOBAL)
set_target_properties(hipify-perl
PROPERTIES IMPORTED_LOCATION ${HIPIFY_PERL_COMMAND}
)
else()
message(FATAL_ERROR "hipify-perl required to convert CUDA to HIP not found")
endif()
elseif(CONVERT_CUDA_TO_HIP)
message("To generate HIP code for AMD GPUs run CMake with version >= 3.21")
endif()
+12 -4
View File
@@ -41,10 +41,18 @@ macro (ADD_CUDA_OR_HIP_FILE LIST DIR FILE)
# add a custom command that will hipify
add_custom_command(
OUTPUT ${hip_file_path}
COMMAND bash "${PROJECT_SOURCE_DIR}/bin/hipify_file.sh" ${cuda_file_path} ${hip_file_path}
DEPENDS ${cuda_file_path}
COMMENT "Rehipifying because of change in ${cuda_file_path}"
OUTPUT
${hip_file_path}
COMMAND
bash
${PROJECT_SOURCE_DIR}/bin/hipify_file.sh
${cuda_file_path}
${hip_file_path}
$<TARGET_FILE:hipify-perl>
DEPENDS
${cuda_file_path}
COMMENT
"Rehipifying because of change in ${cuda_file_path}"
)
# set_source_files_properties(${relpath} PROPERTIES LANGUAGE HIP)
+2 -1
View File
@@ -5,12 +5,13 @@ set -e # Make sure the script fails if a command fails
# it should be run automatically on the correct files through cmake
input_file=$1
output_file=$2
hipify_command=$3
# make sure the output folder exists
mkdir -p $(dirname $output_file)
# hipify out-of-place
hipify-perl $input_file > $output_file
$hipify_command $input_file > $output_file
# expand includes so we only need include_directories (path to hip)
sed -i 's/^#include <hipblas\.h>/#include <hipblas\/hipblas.h>/g' $output_file