Skip to content

Commit

Permalink
Merge pull request #1650 from emankov/HIPIFY
Browse files Browse the repository at this point in the history
[HIPIFY][#1474][Linux][feature] Added a filtering ability for the supplementary hipification scripts - Part 1 - hipconvertinplace-perl.sh
  • Loading branch information
emankov authored Sep 16, 2024
2 parents d47ddd0 + b3ab733 commit ce15684
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,18 @@ if (NOT HIPIFY_CLANG_TESTS_ONLY)
PATTERN "hipify-perl"
PATTERN "*.sh"
PATTERN "findcode.sh" EXCLUDE
PATTERN "findcode_headers.sh" EXCLUDE
PATTERN "findcode_sources.sh" EXCLUDE
PATTERN "findcode_custom.sh" EXCLUDE
PATTERN "finduncodep.sh" EXCLUDE)

set(HIPIFY_LIBEXEC_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}/hipify")

install(
PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bin/findcode.sh
PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bin/findcode_headers.sh
PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bin/findcode_sources.sh
PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bin/findcode_custom.sh
PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bin/finduncodep.sh
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/hipify)

Expand Down
4 changes: 2 additions & 2 deletions bin/findcode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ find $SEARCH_DIRS -name '*.cu' -o -name '*.CU'
find $SEARCH_DIRS -name '*.cpp' -o -name '*.cxx' -o -name '*.c' -o -name '*.cc'
find $SEARCH_DIRS -name '*.CPP' -o -name '*.CXX' -o -name '*.C' -o -name '*.CC'
find $SEARCH_DIRS -name '*.cuh' -o -name '*.CUH'
find $SEARCH_DIRS -name '*.h' -o -name '*.hpp' -o -name '*.inc' -o -name '*.inl' -o -name '*.hxx' -o -name '*.hdl'
find $SEARCH_DIRS -name '*.H' -o -name '*.HPP' -o -name '*.INC' -o -name '*.INL' -o -name '*.HXX' -o -name '*.HDL'
find $SEARCH_DIRS -name '*.h' -o -name '*.hpp' -o -name '*.hh' -o -name '*.inc' -o -name '*.inl' -o -name '*.hxx' -o -name '*.hdl'
find $SEARCH_DIRS -name '*.H' -o -name '*.HPP' -o -name '*.HH' -o -name '*.INC' -o -name '*.INL' -o -name '*.HXX' -o -name '*.HDL'
6 changes: 6 additions & 0 deletions bin/findcode_custom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

SEARCH_DIRS=$@

find $SEARCH_DIRS -name '*.cu' -and -not -name '*.cuh'
find $SEARCH_DIRS -name '*.CU' -and -not -name '*.CUH'
7 changes: 7 additions & 0 deletions bin/findcode_headers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

SEARCH_DIRS=$@

find $SEARCH_DIRS -name '*.cuh' -o -name '*.CUH'
find $SEARCH_DIRS -name '*.h' -o -name '*.hpp' -o -name '*.hh' -o -name '*.inc' -o -name '*.inl' -o -name '*.hxx' -o -name '*.hdl'
find $SEARCH_DIRS -name '*.H' -o -name '*.HPP' -o -name '*.HH' -o -name '*.INC' -o -name '*.INL' -o -name '*.HXX' -o -name '*.HDL'
8 changes: 8 additions & 0 deletions bin/findcode_sources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

SEARCH_DIRS=$@

find $SEARCH_DIRS -name '*.cu' -and -not -name '*.cuh'
find $SEARCH_DIRS -name '*.CU' -and -not -name '*.CUH'
find $SEARCH_DIRS -name '*.cpp' -o -name '*.cxx' -o -name '*.c' -o -name '*.cc'
find $SEARCH_DIRS -name '*.CPP' -o -name '*.CXX' -o -name '*.C' -o -name '*.CC'
22 changes: 20 additions & 2 deletions bin/hipconvertinplace-perl.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

#usage : hipconvertinplace-perl.sh DIRNAME [hipify-perl options]
#usage : hipconvertinplace-perl.sh DIRNAME [-filter=all|headers|sources|custom] [hipify-perl options]

#hipify "inplace" all code files in specified directory.
# This can be quite handy when dealing with an existing CUDA code base since the script
Expand All @@ -12,7 +12,25 @@
# (this is useful for testing improvements to the hipify-perl toolset).

SCRIPT_DIR="$(dirname "$(realpath "$0")")"
SCRIPT_NAME=findcode.sh
PRIV_SCRIPT_DIR="$SCRIPT_DIR/../libexec/hipify"
SEARCH_DIR=$1
if [ "$2" = "-filter=all" ]
then
shift
$SCRIPT_DIR/hipify-perl -inplace -print-stats "$@" `$PRIV_SCRIPT_DIR/findcode.sh $SEARCH_DIR`
elif [ "$2" = "-filter=headers" ]
then
SCRIPT_NAME=findcode_headers.sh
shift
elif [ "$2" = "-filter=sources" ]
then
SCRIPT_NAME=findcode_sources.sh
shift
elif [ "$2" = "-filter=custom" ]
then
SCRIPT_NANE=findcode_custom.sh
shift
fi
shift

$SCRIPT_DIR/hipify-perl -inplace -print-stats "$@" `$PRIV_SCRIPT_DIR/$SCRIPT_NAME $SEARCH_DIR`
3 changes: 3 additions & 0 deletions packaging/hipify-clang.postinst
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ case "$1" in
ln -r -s -f @HIPBINDIR@/hipexamine-perl.sh @ROCMBINDIR@/hipexamine-perl.sh
ln -r -s -f @HIPBINDIR@/hipexamine.sh @ROCMBINDIR@/hipexamine.sh
ln -r -s -f @HIPBINDIR@/findcode.sh @ROCMBINDIR@/findcode.sh
ln -r -s -f @HIPBINDIR@/findcode_headers.sh @ROCMBINDIR@/findcode_headers.sh
ln -r -s -f @HIPBINDIR@/findcode_sources.sh @ROCMBINDIR@/findcode_sources.sh
ln -r -s -f @HIPBINDIR@/findcode_custom.sh @ROCMBINDIR@/findcode_custom.sh
ln -r -s -f @HIPBINDIR@/finduncodep.sh @ROCMBINDIR@/finduncodep.sh
cd $CURRENTDIR
;;
Expand Down
3 changes: 3 additions & 0 deletions packaging/hipify-clang.prerm
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ case "$1" in
rm -f @ROCMBINDIR@/hipexamine-perl.sh
rm -f @ROCMBINDIR@/hipexamine.sh
rm -f @ROCMBINDIR@/findcode.sh
rm -f @ROCMBINDIR@/findcode_headers.sh
rm -f @ROCMBINDIR@/findcode_sources.sh
rm -f @ROCMBINDIR@/findcode_custom.sh
rm -f @ROCMBINDIR@/finduncodep.sh
rmdir --ignore-fail-on-non-empty @ROCMBINDIR@
;;
Expand Down
3 changes: 3 additions & 0 deletions packaging/hipify-clang.rpm_post
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ ln -r -s -f @HIPBINDIR@/hipconvertinplace.sh @ROCMBINDIR@/hipconvertinplace.sh
ln -r -s -f @HIPBINDIR@/hipexamine-perl.sh @ROCMBINDIR@/hipexamine-perl.sh
ln -r -s -f @HIPBINDIR@/hipexamine.sh @ROCMBINDIR@/hipexamine.sh
ln -r -s -f @HIPBINDIR@/findcode.sh @ROCMBINDIR@/findcode.sh
ln -r -s -f @HIPBINDIR@/findcode_headers.sh @ROCMBINDIR@/findcode_headers.sh
ln -r -s -f @HIPBINDIR@/findcode_sources.sh @ROCMBINDIR@/findcode_sources.sh
ln -r -s -f @HIPBINDIR@/findcode_custom.sh @ROCMBINDIR@/findcode_custom.sh
ln -r -s -f @HIPBINDIR@/finduncodep.sh @ROCMBINDIR@/finduncodep.sh
cd $CURRENTDIR
3 changes: 3 additions & 0 deletions packaging/hipify-clang.rpm_postun
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ if [ $1 -le 1 ]; then
rm -f @ROCMBINDIR@/hipexamine-perl.sh
rm -f @ROCMBINDIR@/hipexamine.sh
rm -f @ROCMBINDIR@/findcode.sh
rm -f @ROCMBINDIR@/findcode_headers.sh
rm -f @ROCMBINDIR@/findcode_sources.sh
rm -f @ROCMBINDIR@/findcode_custom.sh
rm -f @ROCMBINDIR@/finduncodep.sh
rmdir --ignore-fail-on-non-empty @ROCMBINDIR@
rmdir --ignore-fail-on-non-empty @HIPBINDIR@
Expand Down
3 changes: 3 additions & 0 deletions packaging/hipify-clang.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ set(CMAKE_INSTALL_PREFIX @CMAKE_INSTALL_PREFIX@)
install(PROGRAMS @HIPIFY_BIN_INSTALL_PATH@/hipify-clang DESTINATION @CMAKE_INSTALL_BINDIR@)
install(PROGRAMS @HIPIFY_BIN_INSTALL_PATH@/hipify-perl DESTINATION @CMAKE_INSTALL_BINDIR@)
install(PROGRAMS @HIPIFY_LIBEXEC_INSTALL_PATH@/findcode.sh DESTINATION @CMAKE_INSTALL_LIBEXECDIR@/hipify)
install(PROGRAMS @HIPIFY_LIBEXEC_INSTALL_PATH@/findcode_headers.sh DESTINATION @CMAKE_INSTALL_LIBEXECDIR@/hipify)
install(PROGRAMS @HIPIFY_LIBEXEC_INSTALL_PATH@/findcode_sources.sh DESTINATION @CMAKE_INSTALL_LIBEXECDIR@/hipify)
install(PROGRAMS @HIPIFY_LIBEXEC_INSTALL_PATH@/findcode_custom.sh DESTINATION @CMAKE_INSTALL_LIBEXECDIR@/hipify)
install(PROGRAMS @HIPIFY_LIBEXEC_INSTALL_PATH@/finduncodep.sh DESTINATION @CMAKE_INSTALL_LIBEXECDIR@/hipify)
install(PROGRAMS @HIPIFY_BIN_INSTALL_PATH@/hipconvertinplace-perl.sh DESTINATION @CMAKE_INSTALL_BINDIR@)
install(PROGRAMS @HIPIFY_BIN_INSTALL_PATH@/hipconvertinplace.sh DESTINATION @CMAKE_INSTALL_BINDIR@)
Expand Down

0 comments on commit ce15684

Please sign in to comment.