X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=fast_make.sh;h=38d94a187816b9820e034c420a9a910976b88886;hb=3451be2e38ff6603113fb95f7498e127707de370;hp=249ca5e0935abba525ac93275dec368de69e2303;hpb=c324c54e19ace253a5a8f318a0c44cb771cf50c6;p=clitk.git diff --git a/fast_make.sh b/fast_make.sh index 249ca5e..38d94a1 100755 --- a/fast_make.sh +++ b/fast_make.sh @@ -3,39 +3,38 @@ vv_dir=$(dirname $(readlink -e $(which $0))) echo clitk3 directory: $vv_dir cd ${vv_dir}/build -nice -n 19 ionice -c3 make -j4 #is this good enough? -# -#function handle_exit -#{ -# rm mem_use 2>>/dev/null -# killall -s SIGCONT make -# killall make -# killall cc1plus -# echo "Terminated, exiting..." -# echo -# echo -# exit -#} -# -#trap handle_exit SIGINT -#available_mem=$(cat /proc/meminfo | grep MemTotal | grep -o [0-9]*) -#if [ -a "memory_exhausted_lock" ] -#then -# echo "Running in memory conservation mode..." -# max_cpp_process_mem_use=1600000 -# cpus=$(( $available_mem / $max_cpp_process_mem_use )) -# echo "Using $cpus cpu(s) should be safe..." -# sleep 1 -# make -j${cpus} -#else #use all the available computing power by default -# cpus=$(( $(cat /proc/cpuinfo | grep -c ^processor) + 0 )) -#fi -# -#nice -n12 ionice -c3 make -j ${cpus} $@ & -#make_pid=$(jobs -p %nice) -# -##watch memory use to avoid crashes +function handle_exit +{ + rm mem_use 2>>/dev/null + killall -s SIGCONT make + killall make + killall cc1plus + echo "Terminated, exiting..." + echo + echo + exit +} + +trap handle_exit SIGINT +available_mem=$(cat /proc/meminfo | grep MemTotal | grep -o [0-9]*) +if [ -a "memory_exhausted_lock" ] +then + echo "Running in memory conservation mode..." + max_cpp_process_mem_use=1600000 + cpus=$(( $available_mem / $max_cpp_process_mem_use )) + echo "Using $cpus cpu(s) should be safe..." + sleep 1 + make -j${cpus} +else #use all the available computing power by default + cpus=$(( $(cat /proc/cpuinfo | grep -c ^processor) + 0 )) + echo "Building with ${cpus} cpus..." +fi + +nice -n12 ionice -c3 make -j ${cpus} $@ & +make_pid=$(jobs -p %nice) + +#watch memory use to avoid crashes #while ps $make_pid >>/dev/null #do # if [ x"$(ps aux | grep cc1plus | grep -v grep | wc -l)" != x0 ] @@ -69,5 +68,6 @@ nice -n 19 ionice -c3 make -j4 #is this good enough? # sleep 1 #done #rm memory_exhausted_lock 2>>/dev/null -#echo Done! -#echo +wait +echo Done! +echo