File: install

package info (click to toggle)
hipcub 6.4.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,528 kB
  • sloc: cpp: 56,703; python: 564; sh: 365; makefile: 118; xml: 26
file content (193 lines) | stat: -rwxr-xr-x 5,096 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/bin/bash


# #################################################
# helper functions
# #################################################
function display_help()
{
    echo "hipCUB build & installation helper script"
    echo "./install [-h|--help] "
    echo "    [-h|--help] prints this help message"
    echo "    [-i|--install] install after build"
    echo "    [-p|--package build package"
    echo "    [-r]--relocatable] create a package to support relocatable ROCm"
    echo "    [-b|--benchmark] builds and runs benchmark"
    echo "    [-d|--dependencies] install build dependencies"
    echo "    [-c|--clients] build library clients too (combines with -i & -d)"
    echo "    [-g|--debug] -DCMAKE_BUILD_TYPE=Debug (default is =Release)"
    echo "    [--hip-clang] build library for amdgpu backend using hip-clang"
    echo "    [--address-sanitizer] build with address sanitizer enabled"
    echo "    [--rm-legacy-include-dir] Remove legacy include dir Packaging added for file/folder reorg backward compatibility"
}


# #################################################
# global variables
# #################################################
install_package=false
build_package=false
build_clients=false
build_release=true
build_hip_clang=false
run_tests=false
rocm_path=/opt/rocm
build_relocatable=false
install_dependencies=false
build_address_sanitizer=false
build_benchmark=false
build_freorg_bkwdcomp=false

# #################################################
# Parameter parsing
# #################################################

# check if we have a modern version of getopt that can handle whitespace and long parameters
getopt -T
if [[ $? -eq 4 ]]; then
    GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,install,clients,debug,hip-clang,test,benchmark,package,relocatable,dependencies,address-sanitizer,rm-legacy-include-dir --options hicdtbpr -- "$@")
else
    echo "Need a new version of getopt"
    exit 1
fi

if [[ $? -ne 0 ]]; then
    echo "getopt invocation failed; could not parse the command line";
    exit 1
fi

eval set -- "${GETOPT_PARSE}"

check_exit_code( )
{
    if (( $1 != 0 )); then
    exit $1
    fi
}

while true; do
    case "${1}" in
    -h|--help)
        display_help
        exit 0
        ;;
    -i|--install)
        install_package=true
        shift ;;
    -p|--package)
        build_package=true
        shift ;;
    -c|--clients)
        build_clients=true
        shift ;;
    -r|--relocatable)
        build_relocatable=true
        shift ;;
    -g|--debug)
        build_release=false
        shift ;;
    -t|--test)
        run_tests=true
        shift ;;
    -b|--benchmark)
        build_benchmark=true
        shift ;;
    -d|--dependencies)
        install_dependencies=true
        shift ;;
    --hip-clang)
        build_hip_clang=true
        shift ;;
    --address-sanitizer)
        build_address_sanitizer=true
        shift ;;
    --rm-legacy-include-dir)
        build_freorg_bkwdcomp=false
        shift ;;
    --) shift ; break ;;
    *)  echo "Unexpected command line parameter received; aborting";
        exit 1
        ;;
    esac
    done

if [[ "${build_relocatable}" == true ]]; then
    if ! [ -z ${ROCM_PATH+x} ]; then
        rocm_path=${ROCM_PATH}
    fi
fi

# Install the pre-commit hook
bash .githooks/install


# Create and go to the build directory.
mkdir -p build; cd build

if ($build_release); then
    mkdir -p release; cd release
    build_type="-DCMAKE_BUILD_TYPE=Release"
else
    mkdir -p debug; cd debug
    build_type="-DCMAKE_BUILD_TYPE=Debug"
fi

# Configure hipCUB, setup options for your system.
# Build options:
#   BUILD_TEST - off by default,
#   BUILD_BENCHMARK - off by default.
#
cmake_executable="cmake"

cmake_common_options="--toolchain=toolchain-linux.cmake"

if [[ "${build_benchmark}" == true ]]; then
    build_benchmarks="-DBUILD_BENCHMARK=ON"
fi

if [[ "${build_clients}" == true ]]; then
    build_tests="-DBUILD_TEST=ON"
else
    build_tests="-DBUILD_TEST=OFF"
fi

if [[ "${build_address_sanitizer}" == true ]]; then
    cmake_common_options="$cmake_common_options -DBUILD_ADDRESS_SANITIZER=ON"
fi

if ($install_dependencies); then
    cmake_common_options="${cmake_common_options} -DDEPENDENCIES_FORCE_DOWNLOAD=ON"
fi

if [[ "${build_relocatable}" == true ]]; then
    ${cmake_executable} \
        -DCMAKE_INSTALL_PREFIX=${rocm_path} \
        -DCMAKE_MODULE_PATH="${rocm_path}/lib/cmake/hip ${rocm_path}/hip/cmake" \
        -Drocprim_DIR=${rocm_path}/rocprim \
        ${cmake_common_options} \
        ${build_tests} ${build_benchmarks} ${build_type} ../../. # or cmake-gui ../.
else
    ${cmake_executable} ${build_tests} ${build_benchmarks} ${build_type} ${cmake_common_options} ../../. # or cmake-gui ../.
fi
check_exit_code "$?"

# Build
make -j$(nproc)
check_exit_code "$?"

if ($run_tests); then
# Optionally, run tests if they're enabled.
ctest --output-on-failure
fi

if ($install_package); then
    # Install
    make install
    check_exit_code "$?"
fi

if ($build_package); then
    # Package
    make package -j$(nproc)
    check_exit_code "$?"
fi