Skip to content

Commit ce15684

Browse files
authored
Merge pull request #1650 from emankov/HIPIFY
[HIPIFY][#1474][Linux][feature] Added a filtering ability for the supplementary hipification scripts - Part 1 - hipconvertinplace-perl.sh
2 parents d47ddd0 + b3ab733 commit ce15684

11 files changed

+64
-4
lines changed

CMakeLists.txt

100644100755
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,18 @@ if (NOT HIPIFY_CLANG_TESTS_ONLY)
184184
PATTERN "hipify-perl"
185185
PATTERN "*.sh"
186186
PATTERN "findcode.sh" EXCLUDE
187+
PATTERN "findcode_headers.sh" EXCLUDE
188+
PATTERN "findcode_sources.sh" EXCLUDE
189+
PATTERN "findcode_custom.sh" EXCLUDE
187190
PATTERN "finduncodep.sh" EXCLUDE)
188191

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

191194
install(
192195
PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bin/findcode.sh
196+
PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bin/findcode_headers.sh
197+
PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bin/findcode_sources.sh
198+
PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bin/findcode_custom.sh
193199
PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/bin/finduncodep.sh
194200
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/hipify)
195201

bin/findcode.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ find $SEARCH_DIRS -name '*.cu' -o -name '*.CU'
66
find $SEARCH_DIRS -name '*.cpp' -o -name '*.cxx' -o -name '*.c' -o -name '*.cc'
77
find $SEARCH_DIRS -name '*.CPP' -o -name '*.CXX' -o -name '*.C' -o -name '*.CC'
88
find $SEARCH_DIRS -name '*.cuh' -o -name '*.CUH'
9-
find $SEARCH_DIRS -name '*.h' -o -name '*.hpp' -o -name '*.inc' -o -name '*.inl' -o -name '*.hxx' -o -name '*.hdl'
10-
find $SEARCH_DIRS -name '*.H' -o -name '*.HPP' -o -name '*.INC' -o -name '*.INL' -o -name '*.HXX' -o -name '*.HDL'
9+
find $SEARCH_DIRS -name '*.h' -o -name '*.hpp' -o -name '*.hh' -o -name '*.inc' -o -name '*.inl' -o -name '*.hxx' -o -name '*.hdl'
10+
find $SEARCH_DIRS -name '*.H' -o -name '*.HPP' -o -name '*.HH' -o -name '*.INC' -o -name '*.INL' -o -name '*.HXX' -o -name '*.HDL'

bin/findcode_custom.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
SEARCH_DIRS=$@
4+
5+
find $SEARCH_DIRS -name '*.cu' -and -not -name '*.cuh'
6+
find $SEARCH_DIRS -name '*.CU' -and -not -name '*.CUH'

bin/findcode_headers.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
SEARCH_DIRS=$@
4+
5+
find $SEARCH_DIRS -name '*.cuh' -o -name '*.CUH'
6+
find $SEARCH_DIRS -name '*.h' -o -name '*.hpp' -o -name '*.hh' -o -name '*.inc' -o -name '*.inl' -o -name '*.hxx' -o -name '*.hdl'
7+
find $SEARCH_DIRS -name '*.H' -o -name '*.HPP' -o -name '*.HH' -o -name '*.INC' -o -name '*.INL' -o -name '*.HXX' -o -name '*.HDL'

bin/findcode_sources.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
SEARCH_DIRS=$@
4+
5+
find $SEARCH_DIRS -name '*.cu' -and -not -name '*.cuh'
6+
find $SEARCH_DIRS -name '*.CU' -and -not -name '*.CUH'
7+
find $SEARCH_DIRS -name '*.cpp' -o -name '*.cxx' -o -name '*.c' -o -name '*.cc'
8+
find $SEARCH_DIRS -name '*.CPP' -o -name '*.CXX' -o -name '*.C' -o -name '*.CC'

bin/hipconvertinplace-perl.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

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

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

1414
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
15+
SCRIPT_NAME=findcode.sh
1516
PRIV_SCRIPT_DIR="$SCRIPT_DIR/../libexec/hipify"
1617
SEARCH_DIR=$1
18+
if [ "$2" = "-filter=all" ]
19+
then
1720
shift
18-
$SCRIPT_DIR/hipify-perl -inplace -print-stats "$@" `$PRIV_SCRIPT_DIR/findcode.sh $SEARCH_DIR`
21+
elif [ "$2" = "-filter=headers" ]
22+
then
23+
SCRIPT_NAME=findcode_headers.sh
24+
shift
25+
elif [ "$2" = "-filter=sources" ]
26+
then
27+
SCRIPT_NAME=findcode_sources.sh
28+
shift
29+
elif [ "$2" = "-filter=custom" ]
30+
then
31+
SCRIPT_NANE=findcode_custom.sh
32+
shift
33+
fi
34+
shift
35+
36+
$SCRIPT_DIR/hipify-perl -inplace -print-stats "$@" `$PRIV_SCRIPT_DIR/$SCRIPT_NAME $SEARCH_DIR`

packaging/hipify-clang.postinst

100644100755
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ case "$1" in
1919
ln -r -s -f @HIPBINDIR@/hipexamine-perl.sh @ROCMBINDIR@/hipexamine-perl.sh
2020
ln -r -s -f @HIPBINDIR@/hipexamine.sh @ROCMBINDIR@/hipexamine.sh
2121
ln -r -s -f @HIPBINDIR@/findcode.sh @ROCMBINDIR@/findcode.sh
22+
ln -r -s -f @HIPBINDIR@/findcode_headers.sh @ROCMBINDIR@/findcode_headers.sh
23+
ln -r -s -f @HIPBINDIR@/findcode_sources.sh @ROCMBINDIR@/findcode_sources.sh
24+
ln -r -s -f @HIPBINDIR@/findcode_custom.sh @ROCMBINDIR@/findcode_custom.sh
2225
ln -r -s -f @HIPBINDIR@/finduncodep.sh @ROCMBINDIR@/finduncodep.sh
2326
cd $CURRENTDIR
2427
;;

packaging/hipify-clang.prerm

100644100755
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ case "$1" in
1717
rm -f @ROCMBINDIR@/hipexamine-perl.sh
1818
rm -f @ROCMBINDIR@/hipexamine.sh
1919
rm -f @ROCMBINDIR@/findcode.sh
20+
rm -f @ROCMBINDIR@/findcode_headers.sh
21+
rm -f @ROCMBINDIR@/findcode_sources.sh
22+
rm -f @ROCMBINDIR@/findcode_custom.sh
2023
rm -f @ROCMBINDIR@/finduncodep.sh
2124
rmdir --ignore-fail-on-non-empty @ROCMBINDIR@
2225
;;

packaging/hipify-clang.rpm_post

100644100755
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@ ln -r -s -f @HIPBINDIR@/hipconvertinplace.sh @ROCMBINDIR@/hipconvertinplace.sh
1010
ln -r -s -f @HIPBINDIR@/hipexamine-perl.sh @ROCMBINDIR@/hipexamine-perl.sh
1111
ln -r -s -f @HIPBINDIR@/hipexamine.sh @ROCMBINDIR@/hipexamine.sh
1212
ln -r -s -f @HIPBINDIR@/findcode.sh @ROCMBINDIR@/findcode.sh
13+
ln -r -s -f @HIPBINDIR@/findcode_headers.sh @ROCMBINDIR@/findcode_headers.sh
14+
ln -r -s -f @HIPBINDIR@/findcode_sources.sh @ROCMBINDIR@/findcode_sources.sh
15+
ln -r -s -f @HIPBINDIR@/findcode_custom.sh @ROCMBINDIR@/findcode_custom.sh
1316
ln -r -s -f @HIPBINDIR@/finduncodep.sh @ROCMBINDIR@/finduncodep.sh
1417
cd $CURRENTDIR

packaging/hipify-clang.rpm_postun

100644100755
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ if [ $1 -le 1 ]; then
77
rm -f @ROCMBINDIR@/hipexamine-perl.sh
88
rm -f @ROCMBINDIR@/hipexamine.sh
99
rm -f @ROCMBINDIR@/findcode.sh
10+
rm -f @ROCMBINDIR@/findcode_headers.sh
11+
rm -f @ROCMBINDIR@/findcode_sources.sh
12+
rm -f @ROCMBINDIR@/findcode_custom.sh
1013
rm -f @ROCMBINDIR@/finduncodep.sh
1114
rmdir --ignore-fail-on-non-empty @ROCMBINDIR@
1215
rmdir --ignore-fail-on-non-empty @HIPBINDIR@

0 commit comments

Comments
 (0)