-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenaccSetup.sh
executable file
·199 lines (172 loc) · 4.55 KB
/
OpenaccSetup.sh
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
#!/bin/sh
#
# Build GCC with support for offloading to NVIDIA GPUs.
#
#fix PATH
export PATH=$(echo $PATH | sed -e "s,/usr/local/bin:,,"):/usr/local/bin
dest_dir=""
work_dir="$PWD/wrk"
prefix_dir="$PWD/install"
# Location of the installed CUDA toolkit
cuda=/usr/local/cuda
echo "OpenACC build script for NVIDIA GPUs patched to suport sm_20 (Fermi GPUs)"
echo
if [ "$1" == "--help" ] ; then
echo " Usage:"
echo " $0 --help for help"
echo " $0 --pull to pull from git and force install"
echo " $0 --forcemake to force make files an install"
echo " $0 --forceinstall"
echo " $0 --makeporteusxzm"
echo " $0 --makeslackware"
echo " $0 --makebinrelease"
exit 0
fi
if [ "$1" == "--makeporteusxzm" -o "$1" == "--makeslackware" -o "$1" == "--makebinrelease" ] ; then
dest_dir="$PWD/package"
work_dir="$PWD/wrk"
prefix_dir="/usr"
rm -fr $work_dir/build-*
echo " Building package to $dest_dir$prefix_dir"
fi
echo " Checking cuda dir $cuda"
if [ -e $cuda ] ; then
echo "ok."
echo
else
echo "Cuda dir not found, please fix cuda dir."
exit -1
fi
echo " Installed gcc version:"
gcc -v
echo
echo "Ctrl-c to stop (continuing in 5 secs)"
sleep 5
echo
mkdir -p $work_dir
cd $work_dir
echo " Downloading Patched Sources..."
if [ ! -e nvptx-tools ] ; then
git clone https://github.com/RodrigoOt/nvptx-tools
elif [ "$1" == "--pull" ] ; then
cd nvptx-tools
git pull
cd ..
fi
if [ ! -e nvptx-newlib ] ; then
git clone https://github.com/RodrigoOt/nvptx-newlib
elif [ "$1" == "--pull" ] ; then
cd nvptx-newlib
git pull
cd ..
fi
if [ ! -e gcc-9.1.0 ] ; then
git clone https://github.com/RodrigoOt/gcc-9.1.0
elif [ "$1" == "--pull" ] ; then
cd gcc-9.1.0
git pull
cd ..
fi
echo
echo "Ctrl-c to stop (continuing in 5 secs)"
sleep 5
echo
echo " Building: "
if [ ! -e build-nvptx-tools/config.status ] ; then
test -e build-nvptx-tools || mkdir build-nvptx-tools
cd build-nvptx-tools
../nvptx-tools/configure \
--with-cuda-driver-include=$cuda/include \
--with-cuda-driver-lib=$cuda/lib64 \
--prefix=$prefix_dir
make
make install DESTDIR=${dest_dir}
cd ..
elif [ "$1" == "--forceinstall" -o "$1" == "--pull" ] ; then
cd build-nvptx-tools
make install DESTDIR=${dest_dir}
cd ..
else
echo " build-nvptx-tools compiled (to force use --forceinstall"
fi
if [ -e gcc-9.1.0 ] ; then
echo Set up the GCC source tree
cd gcc-9.1.0
if [ ! -e gmp-4.3.2.tar.bz2 ] ; then
./contrib/download_prerequisites
fi
test -L newlib || ln -s ../nvptx-newlib/newlib newlib
cd ..
fi
target=$(gcc-9.1.0/config.guess)
if [ ! -e build-nvptx-gcc ] ; then
echo " Building gcc accelerator with nvptx "
test -e build-nvptx-gcc || mkdir build-nvptx-gcc
cd build-nvptx-gcc
../gcc-9.1.0/configure \
--target=nvptx-none --with-build-time-tools=${dest_dir}/$prefix_dir/nvptx-none/bin \
--enable-as-accelerator-for=$target \
--disable-checking \
--disable-libstdcxx \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
--enable-languages="c,c++,lto" \
--prefix=$prefix_dir
make -j4
make install DESTDIR=${dest_dir}
cd ..
elif [ -e build-nvptx-gcc -a "$1" == "--forcemake" ] ; then
echo Make Forced in build-nvptx-gcc
cd build-nvptx-gcc
make -j4
make install DESTDIR=${dest_dir}
cd ..
elif [ "$1" == "--forceinstall" -o "$1" == "--pull" ] ; then
cd build-nvptx-gcc
make install DESTDIR=${dest_dir}
cd ..
else
echo " build-nvptx-gcc compiled (to force use --forcemake or --forceinstall"
fi
if [ ! -e build-host-gcc ] ; then
echo " Building gcc "
test -e build-host-gcc || mkdir build-host-gcc
cd build-host-gcc
../gcc-9.1.0/configure \
--enable-offload-targets=nvptx-none \
--with-cuda-driver-include=$cuda/include \
--with-cuda-driver-lib=$cuda/lib64 \
--disable-libstdcxx \
--disable-bootstrap \
--disable-multilib \
--enable-languages="c,c++,lto" \
--prefix=$prefix_dir
make -j4
make install DESTDIR=${dest_dir}
cd ..
elif [ -e build-host-gcc -a "$1" == "--forcemake" ] ; then
echo Make Forced in build-host-gcc
cd build-host-gcc
make -j4
make install DESTDIR=${dest_dir}
cd ..
elif [ "$1" == "--forceinstall" -o "$1" == "--pull" ] ; then
cd build-host-gcc
make install DESTDIR=${dest_dir}
cd ..
else
echo " build-host-gcc compiled (to force use --forcemake or --forceinstall"
fi
cd ..
if [ "$1" == "--makeporteusxzm" ] ; then
dir2xzm package Gcc-9.1.0-nvptx-x86_64.xzm
fi
if [ "$1" == "--makeslackware" ] ; then
cp slackware/* package
dir2txz package gcc-9.1.0-nvptx-x86_64.tar.gz
fi
if [ "$1" == "--makebinrelease" ] ; then
cd package
tar xzvf ../gcc-9.1.0-nvptx-x86_64.tar.gz *
cd ..
fi