-
Notifications
You must be signed in to change notification settings - Fork 0
/
aomp_common_vars
executable file
·316 lines (282 loc) · 12.8 KB
/
aomp_common_vars
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
#!/bin/bash
#
# aomp_common_vars: FIle sourced by all AOMP build scripts.
# This script is stored in aomp/ bin directory of aomp repo
#
# Set the AOMP VERSION STRING.
# After a release, this is changed to the next release under development
AOMP_VERSION=${AOMP_VERSION:-"0.7"}
AOMP_VERSION_MOD=${AOMP_VERSION_MOD:-"6"}
AOMP_VERSION_STRING=${AOMP_VERSION_STRING:-"$AOMP_VERSION-$AOMP_VERSION_MOD"}
export AOMP_VERSION_STRING AOMP_VERSION AOMP_VERSION_MOD ROCM_VERSION
# set install directory and the link directory
# AOMP will be a symbolic link AOMP_INSTALL_DIR is the versioned dir name
AOMP=${AOMP:-$HOME/rocm/aomp}
AOMP_INSTALL_DIR=${AOMP}_${AOMP_VERSION_STRING}
# Set the directory location where all local AOMP git repos are stored
# For exampe the aomp main repo is typically stored in $HOME/git/aomp/aomp
# Clang repo is $HOME/aomp/clang
AOMP_REPOS=${AOMP_REPOS:-$HOME/git/aomp}
AOMP_REPOS_TEST=${AOMP_REPOS_TEST:-$HOME/git/aomp-test}
# To build aomp from the release source taball, set these to 0
# See build_from_release_tarball.sh
AOMP_CHECK_GIT_BRANCH=${AOMP_CHECK_GIT_BRANCH:-1}
AOMP_APPLY_ROCM_PATCHES=${AOMP_APPLY_ROCM_PATCHES:-1}
CUDA=${CUDA:-/usr/local/cuda}
CUDAT=${CUDAT:-$CUDA/targets}
CUDAINCLUDE=${CUDAINCLUDE:-$CUDA/include}
CUDABIN=${CUDABIN:-$CUDA/bin}
AOMP_CMAKE=${AOMP_CMAKE:-cmake}
AOMP_BUILD_HIP=${AOMP_BUILD_HIP:-1}
AOMP_PROC=`uname -p`
if [ "$AOMP_PROC" == "aarch64" ] ; then
AOMP_BUILD_CUDA=0
AOMP_BUILD_HIP=0
fi
if [ "$AOMP_PROC" == "ppc64le" ] ; then
AOMP_BUILD_HIP=0
fi
# Default is to NOT build for nvptx
# Set AOMP_BUILD_CUDA to 1 to override default
AOMP_BUILD_CUDA=${AOMP_BUILD_CUDA:-0}
# When default is changed to 1, still turn it off if no cuda installed
if [ ! -d "$CUDABIN" ] ; then
AOMP_BUILD_CUDA=0
fi
# Set list of default nvptx subarchitectures to build
# Only Cuda 9 and above supports sm_70
if [ "$AOMP_BUILD_CUDA" == 1 ] ; then
NVPTXGPUS_DEFAULT="30,32,35,50,60,61"
if [ -f $CUDA/version.txt ] ; then
if [ `head -1 /usr/local/cuda/version.txt | cut -d " " -f 3 | cut -d "." -f 1` -ge 9 ] ; then
NVPTXGPUS_DEFAULT+=",70"
fi
fi
# Developers should override NVPTXGPUS to shorten build time.
NVPTXGPUS=${NVPTXGPUS:-"${NVPTXGPUS_DEFAULT}"}
AOMP_NVPTX_TARGET="NVPTX;"
else
NVPTXGPUS_DEFAULT=""
NVPTXGPUS=""
AOMP_NVPTX_TARGET=""
fi
# Set list of default amdgcn subarchitectures to build
# Developers should override GFXLIST to shorten build time.
GFXLIST=${GFXLIST:-"gfx700 gfx701 gfx801 gfx803 gfx900 gfx902 gfx906"}
export GFXLIST
# Calculate the number of threads to use for make
NUM_THREADS=
if [ ! -z `which "getconf"` ]; then
NUM_THREADS=$(`which "getconf"` _NPROCESSORS_ONLN)
if [ "$AOMP_PROC" == "ppc64le" ] || [ "$AOMP_PROC" == "aarch64" ] ; then
NUM_THREADS=$(( NUM_THREADS / 4))
fi
fi
# These are the web sites where the AOMP git repos are pulled from
GITROC="https://github.com/radeonopencompute"
GITROCDEV="https://github.com/ROCm-Developer-Tools"
GITROCLIB="https://github.com/AMDComputeLibraries"
GITKHRONOS="https://github.com/KhronosGroup"
AOMP_INTERNAL_IP="gitlab1.amd.com"
GITINTERNAL="http://${AOMP_INTERNAL_IP}/dmcdouga" # This will change soon
AOMP_IAPPS_REPO_NAME=${AOMP_IAPPS_REPO_NAME:-Nekbone} # This will change soon
AOMP_IAPPS_REPO_BRANCH=${AOMP_IAPPS_REPO_BRANCH:-openmp_amd}
GITLLNL="https://github.com/llnl"
AOMP_RAJA_REPO_NAME=${AOMP_RAJA_REPO_NAME:-raja}
AOMP_RAJA_REPO_BRANCH=${AOMP_RAJA_REPO_BRANCH:-master}
# The git repos and branches that the AOMP build scripts will use
AOMP_REPO_NAME=${AOMP_REPO_NAME:-aomp}
AOMP_REPO_BRANCH=${AOMP_REPO_BRANCH:-master}
AOMP_PROJECT_REPO_NAME=${AOMP_PROJECT_REPO_NAME:-llvm-project}
AOMP_PROJECT_REPO_BRANCH=${AOMP_PROJECT_REPO_BRANCH:-AOMP-191029}
AOMP_LIBDEVICE_REPO_NAME=${AOMP_LIBDEVICE_REPO_NAME:-rocm-device-libs}
AOMP_LIBDEVICE_REPO_BRANCH=${AOMP_LIBDEVICE_REPO_BRANCH:-roc-ocl-2.9.x}
AOMP_HCC_REPO_NAME=${AOMP_HCC_REPO_NAME:-hcc}
AOMP_HCC_REPO_BRANCH=${AOMP_HCC_REPO_BRANCH:-roc-2.9.x}
AOMP_HIP_REPO_NAME=${AOMP_HIP_REPO_NAME:-hip}
AOMP_HIP_REPO_BRANCH=${AOMP_HIP_REPO_BRANCH:-roc-2.9.x}
AOMP_RINFO_REPO_NAME=${AOMP_RINFO_REPO_NAME:-rocminfo}
AOMP_RINFO_REPO_BRANCH=${AOMP_RINFO_REPO_BRANCH:-master}
AOMP_ROCT_REPO_NAME=${AOMP_ROCT_REPO_NAME:-roct-thunk-interface}
AOMP_ROCT_REPO_BRANCH=${AOMP_ROCT_REPO_BRANCH:-roc-2.9.x}
AOMP_ROCR_REPO_NAME=${AOMP_ROCR_REPO_NAME:-rocr-runtime}
AOMP_ROCR_REPO_BRANCH=${AOMP_ROCR_REPO_BRANCH:-roc-2.9.x}
AOMP_ATMI_REPO_NAME=${AOMP_ATMI_REPO_NAME:-atmi}
AOMP_ATMI_REPO_BRANCH=${AOMP_ATMI_REPO_BRANCH:-aomp-0.7-6}
AOMP_EXTRAS_REPO_NAME=${AOMP_EXTRAS_REPO_NAME:-aomp-extras}
AOMP_EXTRAS_REPO_BRANCH=${AOMP_EXTRAS_REPO_BRANCH:-0.7-6}
AOMP_APPS_REPO_NAME=${AOMP_APPS_REPO_NAME:-openmpapps}
AOMP_APPS_REPO_BRANCH=${AOMP_APPS_REPO_BRANCH:-AOMP-0.5}
AOMP_COMGR_REPO_NAME=${AOMP_COMGR_REPO_NAME:-rocm-compilersupport}
AOMP_COMGR_REPO_BRANCH=${AOMP_COMGR_REPO_BRANCH:-roc-2.9.x}
AOMP_F18_REPO_NAME=${AOMP_F18_REPO_NAME:-f18}
AOMP_F18_REPO_BRANCH=${AOMP_F18_REPO_BRANCH:-master}
AOMP_FLANG_REPO_NAME=${AOMP_FLANG_REPO_NAME:-flang}
AOMP_FLANG_REPO_BRANCH=${AOMP_FLANG_REPO_BRANCH:-AOMP-191025}
GITSOLVV="https://github.com/SOLLVE"
AOMP_SOLVV_REPO_NAME=${AOMP_SOLVV_REPO_NAME:-sollve_vv}
AOMP_SOLVV_REPO_BRANCH=${AOMP_SOLVV_REPO_BRANCH:-master}
STASH_BEFORE_PULL=${STASH_BEFORE_PULL:-YES}
# It is highly recommendded that developers set SUDO to disable and
# this have update access to install directory $AOMP. In the future
# we may set this default to disable
SUDO=${SUDO:-NO}
if [ "$SUDO" == "set" ] || [ "$SUDO" == "yes" ] || [ "$SUDO" == "YES" ] ; then
SUDO="sudo"
else
SUDO=""
fi
# The default for BUILD_AOMP is AOMP_REPOS.
# The cmake and make builds are actually done in
# BUILD_AOMP/build, not the actual repos.
BUILD_AOMP=${BUILD_AOMP:-$AOMP_REPOS}
BUILD_DIR=$BUILD_AOMP
# If you override BUILD_AOMP to something other than AOMP_REPOS
# then the scripts will copy the repository sources from AOMP_REPOS
# to the directory BUILD_AOMP. A developer would do this for a
# couple of reasons. 1) access to git repos is slow and
# access to BUILD_AOMP is fast or 2) lots of updates and test code
# is planned that are not desired in his git repository.
# This COPYSOURCE flag is used by build scripts to conditianlly rsync
# source code to the BUILD_AOMP/build/<component> directory.
if [ "$BUILD_DIR" != "$AOMP_REPOS" ] ; then
COPYSOURCE=true
fi
# Here is where we define different behaviors for STANDALONE build
# and the new ROCm integrated build. The default is STANDALONE build.
AOMP_STANDALONE_BUILD=${AOMP_STANDALONE_BUILD:-1}
if [ $AOMP_STANDALONE_BUILD == 1 ] ; then
# Standalone build gets ROCm components from the AOMP Installation.
# As a result their is an order to component builds.
ROCM_DIR=${ROCM_DIR:-$AOMP_INSTALL_DIR}
# We hardcode the ROCM_VERSION here for standalone builds
ROCM_VERSION="2.9.22"
else
# ROCm integrated build gets ROCm pieces from installed ROCm
ROCM_DIR=${ROCM_DIR:-/opt/rocm}
# Jenkins builds may not use the current development branches.
# So we turn off git branch checking.
AOMP_CHECK_GIT_BRANCH=0
# Jenkins build will set the build directory BUILD_DIR to its own work area.
# And since that is not $AOMP_REPOS/build COPYSOURCE will be turned on above.
# We don't want that. So for now, turn it off for ROCm integrated builds.
unset COPYSOURCE
# For Integrated ROCm build we do not install to versioned dir and create
# a symbolic link. Instead we install directly to /opt/rocm/aomp
AOMP_INSTALL_DIR=${AOMP}
# Find the ROCM_VERSION
vfile=$ROCM_DIR/.info/version-dev
if [ -f $vfile ] ; then
ROCM_VERSION=`cat $vfile | cut -d" " -f1`
echo ROCM_VERSION=$ROCM_VERSION
else
echo "ERROR: ROCM_DIR is missing version file $vfile"
exit 1
fi
fi
# Check the repositories exist and are on the correct branch
function checkrepo(){
if [ ! -d $REPO_DIR ] ; then
echo "ERROR: Missing repository directory $REPO_DIR"
exit 1
fi
if [ "$AOMP_CHECK_GIT_BRANCH" == 1 ] ; then
cd $REPO_DIR
COBRANCH=`git branch --list | grep "\*" | cut -d" " -f2`
if [ "$COBRANCH" != "$REPO_BRANCH" ] ; then
if [ "$COBRANCH" == "master" ] ; then
echo "EXIT: Repository $REPO_DIR is on development branch: master"
exit 1
else
echo "ERROR: The repository at $REPO_DIR is not on branch $REPO_BRANCH"
echo " It is on branch $COBRANCH"
exit 1
fi
fi
fi
}
# TO use this function set variables patchdir and patchfile
function patchrepo(){
if [ "$AOMP_APPLY_ROCM_PATCHES" == 1 ] ; then
cd $patchdir
echo "Testing patch $patchfile to $patchdir"
applypatch="yes"
patch -p1 -t -N --dry-run <$patchfile >/dev/null
if [ $? != 0 ] ; then
applypatch="no"
# Check to see if reverse patch applies cleanly
patch -p1 -R --dry-run -t <$patchfile >/dev/null
if [ $? == 0 ] ; then
echo "patch $patchfile was already applied to $patchdir"
else
echo
echo "ERROR: Patch $patchfile will not apply"
echo " cleanly to directory $patchdir"
echo " Check if it was already applied."
echo
exit 1
fi
fi
if [ "$applypatch" == "yes" ] ; then
echo "Applying patch $patchfile to $patchdir"
patch -p1 <$patchfile
fi
fi
}
function help_build_aomp(){
/bin/cat 2>&1 <<"EOF"
The build scripts in this directory are used to build AOMP.
Repositories:
Many repositories are used to build AOMP. The script clone_aomp.sh will
clone all the necessary repositories as subdirectories of the directory
$HOME/git/aomp . The web repository locations and the required branches
are set with the file aomp_common_vars
Build all components:
To build all components, run these commands:
./clone_aomp.sh
unset LD_LIBRARY_PATH
./build_aomp.sh
Component builds:
Developers can rebuild individual components by running the build script for
that component. Make sure dependent components are built first. You can run
build_aomp.sh to build call components in the correct order orsee the README.md
file in this directory for the required order.
Each build script can run with no arguments or with a single argument
"install" or "nocmake". Running with no options starts fresh with an empty
component build directory. It then runs cmake with the correct cmake options
then it runs make with a proper -j option.
Optional Arguments 'nocmake' and 'install' :
The 'nocmake' or 'install' options can only be used after your initial build
with no options. The 'nocmake' option is intended to restart make after
you fix code following a failed build. The 'install' option will run 'make'
and 'make install' causing installation into the directory $AOMP_INSTALL_DIR.
The 'install' option will also create a symbolic link to directory $AOMP.
Environment Variables:
You can set environment variables to override behavior of the build scripts
NAME DEFAULT DESCRIPTION
---- ------- -----------
AOMP $HOME/rocm/aomp Where the compiler will be installed
AOMP_REPOS $HOME/git/aomp Location of all aomp repos
BUILD_TYPE Release The CMAKE build type
BUILD_AOMP same as AOMP_REPOS Set a different build location than AOMP_REPOS
To build a debug version of the compiler, run this command before the build:
export BUILD_TYPE=debug
The BUILD_AOMP Envronment Variable:
The build scripts will always build with cmake and make outside your source git trees.
By default (without BUILD_AOMP) the build will occur in the "build" subdirectory of
AOMP_REPOS. For example build_llvm will build in $AOMP_REPOS/build/llvm
The BUILD_AOMP environment variable enables source development outside your git
repositories. By default, this feature is OFF. The BUILD_AOMP environment variable
can be used if access to your git repositories is very slow or you want to test
changes outside of your local git repositories (specified by AOMP_REPOS env var).
If BUILD_AOMP is set, your git repositories (specifed by AOMP_REPOS) will be
replicated to subdirectories of BUILD_AOMP using rsync. The subsequent build
(cmake and make) will occur in subdirectory BUILD_AOMP/build/llvm.
This replication only happens on your initial build, that is, if you specify no arguments.
The option 'nocmake' skips replication and then restarts make in the build directory.
The install option skips replication, skips cmake, runs 'make' and 'make install'.
Be careful to always use options nocmake or install if you made local changes in
BUILD_AOMP or your changes will be lost by a new replica of your git repositories.
EOF
exit 0
}