-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathz-checker-install.sh
executable file
·438 lines (384 loc) · 12.9 KB
/
z-checker-install.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
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
#!/bin/bash
rootDir=`pwd`
if [[ $1 = "-h" ]]
then
echo "Usage: ./z-checker-installer [libpressio_opt_prefix_installation_path]"
echo "Hint: To use libpressio_opt, you need to install it using spack first; after installation, the libpressio_opt_prefix_installation_path contains include and lib64."
echo "Example without libpressio-opt: ./z-checker-install.sh"
echo "Example with libpressio-opt: ./z-checker-install.sh /lcrc/project/ECP-EZ/shdi/LibpressioOpt/libpressio_opt_example/.spack-env/view"
exit
fi
if [ $# -gt 0 ]
then
LibpressioOptPrefixDir=$1
#check if the libpressio_opt has been installed successfully
if [ ! -d $LibpressioOptPrefixDir ]
then
echo "Error: $LibpressioOptPrefixDir does not exsit."
exit
elif [ ! -f $LibpressioOptPrefixDir/include/libpressio_opt/pressio_search.h ]
then
echo "Error: missing libpressio_opt/pressio_search.h."
echo "Please make sure Libpressio_Opt has been installed correctly."
exit
fi
fi
#----------check gcc version----------------
cd zc-patches
g++ -std=c++17 foo.cc
if [[ $? == 1 ]]
then
echo "Fatal issue: too old gcc version! "
echo "Please update your gcc to gcc 7.3 or later version."
exit
fi
cd $rootDir
#----------check CMAKE----------------------
CMAKE_PATH=$(command -v cmake)
if ! [ -x "${CMAKE_PATH}" ]; then
echo "Error: cmake is missing; cmake must be installed beforehand."
exit
fi
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
return 2
fi
done
return 0
}
CMAKE_VERSION=$(cmake --version | head -n 1 | cut -d' ' -f3)
CMAKE_MINIMUM="3.13"
vercomp $CMAKE_VERSION $CMAKE_MINIMUM
case $? in
0) op='=';;
1) op='>';;
2) op='<';;
esac
if [[ $op == '<' ]]
then
echo "Error: CMAKE Version should be no lower than 3.13. Your current Cmake version is $CMAKE_VERSION"
exit
fi
#----------check X11------------------------
#X_PATH=$(command -v X)
#if [ ! -x "${X_PATH}" ];then
# echo "Error: missing X11!"
# echo "Please install X11 first (requiring root previlege)."
# exit
#fi
#----------check git and perl---------------
PERL_PATH=$(command -v perl)
if [ ! -x "${PERL_PATH}" ]; then
echo "Error: missing perl command; Please install perl."
exit
fi
#---------- download gnuplot ----------------
GNUPLOT_URL="https://downloads.sourceforge.net/project/gnuplot/gnuplot/5.0.6/gnuplot-5.0.6.tar.gz"
GNUPLOT_SRC_DIR=$rootDir/gnuplot-5.0.6
GNUPLOT_DIR=$rootDir/gnuplot-5.0.6-install
GNUPLOT_EXE_PATH=$(command -v gnuplot)
if [ ! -x "$GNUPLOT_EXE_PATH" ]; then
if [ ! -d "$GNUPLOT_DIR" ]; then
# download gnuplot source
curl -L $GNUPLOT_URL | tar zxf -
if [ ! -d "$GNUPLOT_SRC_DIR" ] ; then
echo "FATAL: cannot download and extract gnuplot source."
exit
fi
# compile gnuplot
cd $GNUPLOT_SRC_DIR
./configure --prefix=$GNUPLOT_DIR
make && make install
cd $rootDir
echo "export GNUPLOT_HOME=$GNUPLOT_DIR" > $rootDir/env_config.sh
echo "export PATH=\$PATH:\$GNUPLOT_HOME/bin" >> $rootDir/env_config.sh
fi
fi
#---------- download zlib and install it ---------------]
curl -L https://www.mcs.anl.gov/~shdi/download/zlib-1.2.13.tar.gz | tar zxf -
cd zlib-1.2.13
ZLIB_PREFIX=$rootDir/zlib-1.2.13/install
./configure --prefix=$ZLIB_PREFIX
make -j
make install
#---------- download and install libpng forcefully ------
if [ -f $LibpressioOptPrefixDir/include/png.h ]
then
LIBPNG_INSTALL_PATH=$LibpressioOptPrefixDir
else
LIBPNG_SRC_DIR=$rootDir/libpng
if [ ! -d "$LIBPNG_SRC_DIR" ]; then
# download libpng source
LIBPNG_INSTALL_PATH=$LIBPNG_SRC_DIR/libpng-1.6.37-install
LIBPNG_URL=http://www.mcs.anl.gov/~shdi/download/libpng-1.6.37.tar.gz
mkdir -p $LIBPNG_SRC_DIR
cd $LIBPNG_SRC_DIR
curl -L $LIBPNG_URL | tar zxf -
if [ ! -d "$LIBPNG_SRC_DIR" ] ; then
echo "FATAL: cannot download and extract libpng source."
exit
fi
# compile libpng
cd $LIBPNG_SRC_DIR/libpng-1.6.37
cd ..
CPPFLAGS="-I$ZLIB_PREFIX/include" LDFLAGS="-L$ZLIB_PREFIX/lib" ./configure --prefix=$LIBPNG_INSTALL_PATH
make -j 4
make install
fi
fi
#---------- download tif22pnm if missing ---------------
cd $rootDir
TIF22PNM_URL="https://github.com/pts/tif22pnm.git"
TIF22PNM_SRC_DIR=$rootDir/tif22pnm
TIF22PNM_EXE_PATH=$(command -v png22pnm)
if [ ! -x "$TIF22PNG_EXE_PATH" ]; then
if [ ! -d "$TIF22PNG_SRC_DIR" ]; then
# download tif22pnm source
git clone $TIF22PNM_URL
if [ ! -d "$TIF22PNM_SRC_DIR" ] ; then
echo "FATAL: cannot download and extract tif22pnm source."
exit
fi
# compile tif22pnm
cd $TIF22PNM_SRC_DIR
./configure
cp $rootDir/zc-patches/do.sh .
./do.sh fast $LIBPNG_INSTALL_PATH
cd $rootDir
echo "export PNG22PNM_HOME=$TIF22PNM_SRC_DIR" >> $rootDir/env_config.sh
echo "export PATH=\$PATH:\$PNG22PNM_HOME" >> $rootDir/env_config.sh
fi
fi
#---------- download sam2p --------------------
SAM2P_URL="https://github.com/pts/sam2p.git"
SAM2P_SRC_DIR=$rootDir/sam2p
SAM2P_EXE_PATH=$(command -v sam2p)
if [ ! -x "$SAM2P_EXE_PATH" ]; then
if [ ! -d "$SAM2P_SRC_DIR" ]; then
# download sam2p source
git clone $SAM2P_URL
if [ ! -d "$SAM2P_SRC_DIR" ] ; then
echo "FATAL: cannot download and extract sam2p source."
exit
fi
# compile sam2p
cd $SAM2P_SRC_DIR
#fix a potential bug (line:600)
cp $rootDir/zc-patches/gensio.cpp .
#compilation
./compile.sh
cd $rootDir
echo "export SAM2P_HOME=$SAM2P_SRC_DIR" >> $rootDir/env_config.sh
echo "export PATH=\$PATH:\$SAM2P_HOME" >> $rootDir/env_config.sh
fi
fi
#----------- download MGARD and libpressio and install -------
cd $rootDir
./libpressio_install.sh
cp $ZLIB_PREFIX/lib/libz.so compressor-install/lib/libZLIB.so
#--------- compile the codes in zc-patch ------------
cd $rootDir/zc-patches
gcc -O3 -o queryVarList queryVarList.c
#---------- download Z-checker --------------
cd $rootDir
git clone https://github.com/CODARcode/Z-checker.git
cd Z-checker
if [ -z "$LibpressioOptPrefixDir" ]
then
./configure --prefix=$rootDir/Z-checker/zc-install
else
./configure --enable-libpressioopt --with-libpressioopt-prefix=$LibpressioOptPrefixDir --prefix=$rootDir/Z-checker/zc-install
fi
make -j 4
make install
export PATH=$rootDir/Z-checker/zc-install/bin:$PATH
cp ../zc-patches/generateReport.sh ./examples/
cd $rootDir/zc-patches
if [ -z "$(LibpressioOptPrefixDir)" ]
then
gcc -O3 -o manageCompressor manageCompressor.c -fPIC -I../Z-checker/zc-install/include -L../Z-checker/zc-install/lib -lzc -lm -Wl,-rpath $rootDir/Z-checker/zc-install/lib
else
gcc -O3 -o manageCompressor manageCompressor.c -fPIC -I../Z-checker/zc-install/include -L../Z-checker/zc-install/lib -lzc -lm -Wl,-rpath $rootDir/Z-checker/zc-install/lib -I$(LibpressioOptPrefixDir)/include/libpressio -L$(LibpressioOptPrefixDir)/lib64 -llibpressio -Wl,-rpath,"$(LibpressioOptPrefixDir)/lib64"
fi
mv manageCompressor ..
#---------- download ZFP and set the configuration -----------
cd $rootDir
#git clone https://github.com/LLNL/zfp.git
#cd zfp
#make
#mkdir -p build
#cd build
#cmake .. -DCMAKE_INSTALL_PREFIX=$rootDir/zfp/zfp-install -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_LIBDIR=lib
#make -j$(nproc)
#make install
#cd ../..
cp zfp-patches/zfp-zc.c zfp/utils
cp zfp-patches/zfp-zc-vis.c zfp/utils
#cp zfp-patches/*.sh zfp/utils
cd zfp/utils/
#patch -p0 < ../../zfp-patches/Makefile-zc.patch
cp ../../zfp-patches/Makefile-zc ./Makefile
#cp ../../zc-patches/zc.config .
#modifyZCConfig ./zc.config checkingStatus PROBE_COMPRESSOR
make
#---------- download SZ and set the configuration -----------
cd $rootDir
#git clone https://github.com/disheng222/SZ
#cd SZ/sz/src
#patch -p1 < ../../../sz-patches/sz-src-hacc.patch
#cd ../..
#./configure --prefix=$rootDir/SZ/sz-install
#mkdir -p build
#cd build
#cmake .. -DCMAKE_INSTALL_PREFIX=$rootDir/SZ/sz-install -DCMAKE_INSTALL_LIBDIR=lib
#make -j $(nproc)
#make install
#cd ../zlib
#make
#make install
#cd ../zstd
#make
#make install
cd SZ/example
cp ../../sz-patches/testfloat_CompDecomp.c .
cp ../../sz-patches/testfloat_CompDecomp_libpressio.c .
cp ../../sz-patches/testdouble_CompDecomp.c .
cp ../../sz-patches/testdouble_CompDecomp_libpressio.c .
cp ../../sz-patches/sz-zc-vis.c .
cp ../../sz-patches/Makefile.bk .
#cp ../../sz-patches/sz-zc-ratedistortion.sh .
cp ../../sz-patches/testfloat_CompDecomp.sh .
cp ../../sz-patches/testdouble_CompDecomp.sh .
#---go back to SZ and compile testxxxxx_CompDecopm_libpressio.c
cd $rootDir
cd SZ/example
make -f Makefile.bk
cp ../../zc-patches/zc.config .
modifyZCConfig ./zc.config checkingStatus PROBE_COMPRESSOR
#---------- download MGARD and set the configuration ------------
cd $rootDir/mgard-patches
./compile-mgard-zchecker.sh
if [ -f ../libpressio/test/mgardfloat_CompDecomp ]
then
cp ../libpressio/test/mgardfloat_CompDecomp ../MGARD/build/bin
cp ../libpressio/test/mgarddouble_CompDecomp ../MGARD/build/bin
fi
cd ..
#---------- download bit_grooming and set the configuration -----------
cd $rootDir
cd BitGroomingZ/examples
cp ../../bg-patches/Makefile-bg .
cp ../../bg-patches/bgfloat_CompDecomp.cpp .
cp ../../bg-patches/bgdouble_CompDecomp.cpp .
cp ../../bg-patches/bg_CompDecomp.sh .
make -f Makefile-bg
cp ../../zc-patches/zc.config .
modifyZCConfig ./zc.config checkingStatus PROBE_COMPRESSOR
cd $rootDir
./manageCompressor -a bg -c manageCompressor-bg.cfg
Z-checker/examples/modifyZCConfig errBounds.cfg bitgrooming_ERR_BOUNDS "\"1 2 3 4 5\""
#---------- download digit_rounding and set the configuration -----------
cd $rootDir
cd digitroundingZ/examples
cp ../../dr-patches/Makefile-dr .
cp ../../dr-patches/drfloat_CompDecomp.cpp .
cp ../../dr-patches/drdouble_CompDecomp.cpp .
cp ../../dr-patches/dr_CompDecomp.sh .
make -f Makefile-dr
cp ../../zc-patches/zc.config .
modifyZCConfig ./zc.config checkingStatus PROBE_COMPRESSOR
cd $rootDir
./manageCompressor -a digitrounding -c manageCompressor-dr.cfg
Z-checker/examples/modifyZCConfig errBounds.cfg digitrounding_ERR_BOUNDS "\"3 4 5 6 7\""
#---------- download FPZIP and set the configuration -----------
cd $rootDir
cd fpzip/tests
cp ../../fpzip-patches/Makefile-zc .
cp ../../fpzip-patches/fpzipfloat_CompDecomp.c .
cp ../../fpzip-patches/fpzipdouble_CompDecomp.c .
cp ../../fpzip-patches/fpzip_CompDecomp.sh .
make -f Makefile-zc
cp ../../zc-patches/zc.config .
modifyZCConfig ./zc.config checkingStatus PROBE_COMPRESSOR
cd $rootDir
./manageCompressor -a fpzip -c manageCompressor-fpzip-fd.cfg
Z-checker/examples/modifyZCConfig errBounds.cfg fpzip_ERR_BOUNDS "\"8 10 12 14 18 22\""
#---------- download SZauto and set the configuration -----------
cd $rootDir
cd SZauto/test
cp ../../SZauto-patches/Makefile-SZauto .
cp ../../SZauto-patches/SZautofloat_CompDecomp.cpp .
cp ../../SZauto-patches/SZautodouble_CompDecomp.cpp .
cp ../../SZauto-patches/SZauto_CompDecomp.sh .
chmod +x SZauto_CompDecomp.sh
make -f Makefile-SZauto
cp ../../zc-patches/zc.config .
modifyZCConfig ./zc.config checkingStatus PROBE_COMPRESSOR
cd $rootDir
./manageCompressor -a SZauto -i 3 -c manageCompressor-SZauto.cfg
Z-checker/examples/modifyZCConfig errBounds.cfg sz_auto_ERR_BOUNDS "\"0.5 0.1 0.01 0.001\""
#----------- download latexmk --------------------------------
cd $rootDir
latexmk_url=http://ctan.math.utah.edu/ctan/tex-archive/support/latexmk.zip
latexmk_dir=latexmk
latexmk_exe_path=$(command -v latexmk)
if [ ! -x "$latexmk_exe_path" ]; then
if [ ! -d "$latexmk_dir" ]; then
curl -O $latexmk_url
unzip latexmk.zip
cd $latexmk_dir
ln -s "$rootDir/$latexmk_dir/latexmk.pl" latexmk
echo "export LATEXMK_HOME=$rootDir/$latexmk_dir" >> $rootDir/env_config.sh
echo "export PATH=\$PATH:\$LATEXMK_HOME" >> $rootDir/env_config.sh
cd $rootDir
rm -rf latexmk.zip
fi
fi
#----------- download ghost view (gsview) if necessary-----------
cd $rootDir
ghost_url="https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs921/ghostpdl-9.21.tar.gz"
ghost_src_dir=$rootDir/ghostpdl-9.21
ghost_dir=$rootDir/ghostpdl-9.21-install
PS2PDF_EXE_PATH=$(command -v ps2pdf)
if [ ! -x "$PS2PDF_EXE_PATH" ]; then
if [ ! -d "$ghost_dir" ]; then
# download ghost source
curl -L $ghost_url | tar zxf -
if [ ! -d "$ghost_src_dir" ] ; then
echo "FATAL: cannot download and extract ghost source."
exit
fi
# compile ghost
cd $ghost_src_dir
./configure --prefix=$ghost_dir
make && make install
cd $rootDir
echo "export GHOST_HOME=$ghost_dir" >> $rootDir/env_config.sh
echo "export PATH=\$PATH:\$GHOST_HOME/bin" >> $rootDir/env_config.sh
fi
fi
cd $rootDir
ln -s $rootDir/zc-patches/zc.config zc.config