Skip to content

Commit

Permalink
Format all shell scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed Feb 17, 2021
1 parent 2e2218d commit d59a3ad
Show file tree
Hide file tree
Showing 78 changed files with 4,525 additions and 4,511 deletions.
16 changes: 10 additions & 6 deletions tools/autotools/autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
rm -rf autom4te.cache
rm -f aclocal.m4 ltmain.sh

echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS -I m4 || exit 1
echo "Running autoheader..." ; autoheader || exit 1
echo "Running autoconf..." ; autoconf || exit 1
echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1
echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1

echo "Running aclocal..."
aclocal $ACLOCAL_FLAGS -I m4 || exit 1
echo "Running autoheader..."
autoheader || exit 1
echo "Running autoconf..."
autoconf || exit 1
echo "Running libtoolize..."
(libtoolize --copy --automake || glibtoolize --automake) || exit 1
echo "Running automake..."
automake --add-missing --copy --gnu || exit 1
90 changes: 44 additions & 46 deletions tools/autotune_grid/generate_makefile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@

source config.in




(
echo FC_comp=$FC_comp
echo FCFLAGS_OPT=$FCFLAGS_OPT
echo FCFLAGS_NATIVE=$FCFLAGS_NATIVE
echo FC_tune=\$\(FC_comp\) \$\(FCFLAGS_OPT\)
echo FC_native=\$\(FC_comp\) \$\(FCFLAGS_NATIVE\)
echo FC_comp=$FC_comp
echo FCFLAGS_OPT=$FCFLAGS_OPT
echo FCFLAGS_NATIVE=$FCFLAGS_NATIVE
echo FC_tune=\$\(FC_comp\) \$\(FCFLAGS_OPT\)
echo FC_native=\$\(FC_comp\) \$\(FCFLAGS_NATIVE\)
) > config.mk

# Write a makefile to generate all different combinations

(

printf "########## DO NOT EDIT THIS FILE
printf "########## DO NOT EDIT THIS FILE
include config.mk
Expand Down Expand Up @@ -52,7 +49,8 @@ objfiles: \$(OBJ_FILES)
libtest.a: objfiles
\tar r libtest.a \$(OBJ_FILES)
" ) > $makefile_name
"
) > $makefile_name

printf "
include ../config.mk
Expand All @@ -73,37 +71,37 @@ test.x: main.o qs_integrate_potential.o qs_collocate_density.o integrate_fast.o

#7 ! generate up to l = l_max_a + l_max_b
#1 ! use the best of three timings
Ncomb=$(( 2**$Nopt ))
Ncomb=$((2 ** $Nopt))
TARGETS_EXE=""
TARGETS_RUN=""

# For each value of l and iopt
for l in `seq 0 $lmax`; do
# First optimisation starts at ONE (all_options[0] is not initialised and generate does not produces valid code)
for iopt in `seq 1 $Ncomb`;do
TARGETS_EXE="gen_${l}_${iopt}.exists $TARGETS_EXE"
TARGETS_RUN="run_${l}_${iopt}_0.exists run_${l}_${iopt}_1.exists $TARGETS_RUN"
DIRECTORIES="out_${l}_${iopt} $TMPBASE/TMP_${l}_${iopt} $DIRECTORIES"

icollo=1
is_icollo_1=""
is_icollo_0=""

if [[ $icollo -eq 1 ]]; then
is_icollo_1="echo -1;"
fi

if [[ $icollo -eq 0 ]]; then
is_icollo_0="echo -1;"
fi

# Makefile entries for this case
printf "
for l in $(seq 0 $lmax); do
# First optimisation starts at ONE (all_options[0] is not initialised and generate does not produces valid code)
for iopt in $(seq 1 $Ncomb); do
TARGETS_EXE="gen_${l}_${iopt}.exists $TARGETS_EXE"
TARGETS_RUN="run_${l}_${iopt}_0.exists run_${l}_${iopt}_1.exists $TARGETS_RUN"
DIRECTORIES="out_${l}_${iopt} $TMPBASE/TMP_${l}_${iopt} $DIRECTORIES"

icollo=1
is_icollo_1=""
is_icollo_0=""

if [[ $icollo -eq 1 ]]; then
is_icollo_1="echo -1;"
fi

if [[ $icollo -eq 0 ]]; then
is_icollo_0="echo -1;"
fi

# Makefile entries for this case
printf "
gen_${l}_${iopt}.exists: libtest.a generate.x
\t-mkdir out_${l}_${iopt}
\t(${is_icollo_1} printf \"${l}\\\n\"; yes ${iopt} | head -n $((${l}+1)); ${is_icollo_0}) > generate_${l}_${iopt}.in
\t(${is_icollo_1} printf \"${l}\\\n\"; yes ${iopt} | head -n $((${l} + 1)); ${is_icollo_0}) > generate_${l}_${iopt}.in
\t./generate.x < generate_${l}_${iopt}.in
\t(${is_icollo_0} printf \"${l}\\\n\"; yes ${iopt} | head -n $((${l}+1)); ${is_icollo_1}) > generate_${l}_${iopt}.in
\t(${is_icollo_0} printf \"${l}\\\n\"; yes ${iopt} | head -n $((${l} + 1)); ${is_icollo_1}) > generate_${l}_${iopt}.in
\t./generate.x < generate_${l}_${iopt}.in
\t-rm generate_${l}_${iopt}.in
\tcp qs_collocate_density.F qs_integrate_potential.F main.F out_${l}_${iopt}/
Expand All @@ -114,13 +112,13 @@ gen_${l}_${iopt}.exists: libtest.a generate.x
\ttouch gen_${l}_${iopt}.exists
" >> $makefile_name

#printf """
#gen_${l}_${iopt}: libtest.a
#
#""" >> /dev/null # $makefile_name #/dev/null
#printf """
#gen_${l}_${iopt}: libtest.a
#
#""" >> /dev/null # $makefile_name #/dev/null

icollo=0
printf "
icollo=0
printf "
run_${l}_${iopt}_${icollo}.exists: gen_${l}_${iopt}.exists
\tprintf \" ${icollo}\\\\n T\\\\n ${l} 0 0 0\\\\n ${Nrun}\\\n\" > out_${l}_${iopt}/run_${l}_${iopt}_T_${icollo}.in
\ttest -f out_${l}_${iopt}/out_test_${l}_${iopt}_T_${icollo} || ./out_${l}_${iopt}/test.x < out_${l}_${iopt}/run_${l}_${iopt}_T_${icollo}.in > out_${l}_${iopt}/out_test_${l}_${iopt}_T_${icollo}
Expand All @@ -129,8 +127,8 @@ run_${l}_${iopt}_${icollo}.exists: gen_${l}_${iopt}.exists
\ttouch run_${l}_${iopt}_${icollo}.exists
" >> $makefile_name

icollo=1
printf "
icollo=1
printf "
run_${l}_${iopt}_${icollo}.exists: run_${l}_${iopt}_0.exists
\tprintf \" ${icollo}\\\\n T\\\\n ${l} 0 0 0\\\\n ${Nrun}\\\n\" > out_${l}_${iopt}/run_${l}_${iopt}_T_${icollo}.in
\ttest -f out_${l}_${iopt}/out_test_${l}_${iopt}_T_${icollo} ||./out_${l}_${iopt}/test.x < out_${l}_${iopt}/run_${l}_${iopt}_T_${icollo}.in > out_${l}_${iopt}/out_test_${l}_${iopt}_T_${icollo}
Expand All @@ -139,12 +137,12 @@ run_${l}_${iopt}_${icollo}.exists: run_${l}_${iopt}_0.exists
\ttouch run_${l}_${iopt}_${icollo}.exists
" >> $makefile_name

done

done
done

(
printf "
printf "
all: libgrid.a
generate.x:
Expand Down Expand Up @@ -174,5 +172,5 @@ libgrid.a: gen_best xyz_to_vab.o
\tar r libgrid.a out_best/collocate_fast.o out_best/integrate_fast.o xyz_to_vab_optimised.o
"


) >> $makefile_name
) \
>> $makefile_name
101 changes: 50 additions & 51 deletions tools/autotune_grid/get_results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,73 +10,72 @@
source config.in

# Number of combinations with the existing options
Ncomb=$(( 2**$Nopt ))
Ncomb=$((2 ** $Nopt))

# Error tolerance
err_tol="1.0E-10"

# For both collocate (0) and integrate (1)
for icollo in 0 1; do
echo "$icollo"
echo "l - Time - Best Opt"
echo "l Time Opt" > best_timings
for l in `seq 0 $lmax`; do
bsf=999999.0
# First optimisation starts at ONE (all_options[0] is not initialised and generate does not produces valid code)
for iopt in `seq 1 $Ncomb`;do
# Extract the error
tmp=$(cat out_${l}_${iopt}/out_test_${l}_${iopt}_F_${icollo} | tr -s ' ' | grep "largest error" | cut -f 5 -d ' ')
test "$tmp" || continue
error=$(python -c "print $err_tol>$tmp")
# Skip if error is too big
if [[ $error == "False" ]]; then
# echo "($error) Error $tmp was too big for $iopt"
continue
fi
# echo "($error) Error was $tmp , accepted $iopt"
# Extract the time of the combination
tmp=$(cat out_${l}_${iopt}/out_test_${l}_${iopt}_T_${icollo} | tr -s ' ' | grep "best time" | cut -f 5 -d ' ')
echo "$icollo"
echo "l - Time - Best Opt"
echo "l Time Opt" > best_timings
for l in $(seq 0 $lmax); do
bsf=999999.0
# First optimisation starts at ONE (all_options[0] is not initialised and generate does not produces valid code)
for iopt in $(seq 1 $Ncomb); do
# Extract the error
tmp=$(cat out_${l}_${iopt}/out_test_${l}_${iopt}_F_${icollo} | tr -s ' ' | grep "largest error" | cut -f 5 -d ' ')
test "$tmp" || continue
error=$(python -c "print $err_tol>$tmp")
# Skip if error is too big
if [[ $error == "False" ]]; then
# echo "($error) Error $tmp was too big for $iopt"
continue
fi
# echo "($error) Error was $tmp , accepted $iopt"
# Extract the time of the combination
tmp=$(cat out_${l}_${iopt}/out_test_${l}_${iopt}_T_${icollo} | tr -s ' ' | grep "best time" | cut -f 5 -d ' ')

test "$tmp" || continue
dif=$(python -c "print $bsf>$tmp")
test "$tmp" || continue
dif=$(python -c "print $bsf>$tmp")

if [[ $dif == "True" ]]; then
# echo " New bsf is $tmp from $bsf "
bsf=$tmp
bsf_iopt=$iopt
#else
# echo " $bsf is lower than $tmp ($dif, print $bsf>$tmp)"
fi
done # for iopt
if [[ $dif == "True" ]]; then
# echo " New bsf is $tmp from $bsf "
bsf=$tmp
bsf_iopt=$iopt
#else
# echo " $bsf is lower than $tmp ($dif, print $bsf>$tmp)"
fi
done # for iopt

bsf_global[$l]=$bsf
bsf_iopt_global[$l]=$bsf_iopt
bsf_global[$l]=$bsf
bsf_iopt_global[$l]=$bsf_iopt

echo $l -- ${bsf_global[$l]} -- ${bsf_iopt_global[$l]}
echo $l ${bsf_global[$l]} ${bsf_iopt_global[$l]} >> best_timings
echo $l -- ${bsf_global[$l]} -- ${bsf_iopt_global[$l]}
echo $l ${bsf_global[$l]} ${bsf_iopt_global[$l]} >> best_timings

done # for l
done # for l

if [[ $icollo -eq 0 ]]; then
bsf_global_0=("${bsf_global[@]}")
bsf_iopt_global_0=("${bsf_iopt_global[@]}")
else
bsf_global_1=("${bsf_global[@]}")
bsf_iopt_global_1=("${bsf_iopt_global[@]}")
fi
if [[ $icollo -eq 0 ]]; then
bsf_global_0=("${bsf_global[@]}")
bsf_iopt_global_0=("${bsf_iopt_global[@]}")
else
bsf_global_1=("${bsf_global[@]}")
bsf_iopt_global_1=("${bsf_iopt_global[@]}")
fi

done # for icollo

# Generate the input file for generate.x with the optimal combinations for each problem size
echo " Generating optimal combination "
(
echo $lmax
for l in `seq 0 $lmax`; do
echo ${bsf_iopt_global_0[$l]}
done
echo $lmax
for l in `seq 0 $lmax`; do
echo ${bsf_iopt_global_1[$l]}
done
echo $lmax
for l in $(seq 0 $lmax); do
echo ${bsf_iopt_global_0[$l]}
done
echo $lmax
for l in $(seq 0 $lmax); do
echo ${bsf_iopt_global_1[$l]}
done
) > generate_best

28 changes: 14 additions & 14 deletions tools/conventions/test_conventions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ date --utc --rfc-3339=seconds
set -e # abort if error is encountered
cd ../../
make -j ARCH=Linux-x86-64-gfortran VERSION="dumpast" > make_conventions1.out
make -j ARCH=local_warn VERSION="psmp" > make_conventions2.out
make -j ARCH=local_warn VERSION="psmp" > make_conventions2.out
)
MAKE_EXIT_CODE=$?

if (( $MAKE_EXIT_CODE )); then
cd ../../obj/local_warn/psmp/
echo ""
grep -B 2 Error *.warn
echo ""
echo "Summary: Compilation failed."
echo "Status: FAILED"
if (($MAKE_EXIT_CODE)); then
cd ../../obj/local_warn/psmp/
echo ""
grep -B 2 Error *.warn
echo ""
echo "Summary: Compilation failed."
echo "Status: FAILED"
else
rm -f *.issues
rm -f *.issues

set -o errexit
set -o errexit

./analyze_gfortran_ast.py ../../obj/Linux-x86-64-gfortran/dumpast/*.ast > ast.issues
./analyze_gfortran_warnings.py ../../obj/local_warn/psmp/*.warn > warn.issues
./analyze_src.py -b ../../ > src.issues
./summarize_issues.py --suppressions=conventions.supp *.issues
./analyze_gfortran_ast.py ../../obj/Linux-x86-64-gfortran/dumpast/*.ast > ast.issues
./analyze_gfortran_warnings.py ../../obj/local_warn/psmp/*.warn > warn.issues
./analyze_src.py -b ../../ > src.issues
./summarize_issues.py --suppressions=conventions.supp *.issues
fi
8 changes: 4 additions & 4 deletions tools/docker/build_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

# author: Ole Schuett

if (( $# < 1 )); then
echo "usage: build_test.sh <test_name> [additional-args]"
echo "example: build_test.sh python"
exit 1
if (($# < 1)); then
echo "usage: build_test.sh <test_name> [additional-args]"
echo "example: build_test.sh python"
exit 1
fi

set -e
Expand Down
8 changes: 4 additions & 4 deletions tools/docker/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

# author: Ole Schuett

if (( $# < 1 )); then
echo "usage: run_test.sh <test_name> [additional-docker-run-args]"
echo "example: run_test.sh python"
exit 1
if (($# < 1)); then
echo "usage: run_test.sh <test_name> [additional-docker-run-args]"
echo "example: run_test.sh python"
exit 1
fi

set -e
Expand Down
9 changes: 4 additions & 5 deletions tools/docker/run_test_master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

# author: Ole Schuett

if (( $# < 1 )); then
echo "usage: run_test_master.sh <test_name> [additional-docker-run-args]"
echo "example: run_test_master.sh python"
exit 1
if (($# < 1)); then
echo "usage: run_test_master.sh <test_name> [additional-docker-run-args]"
echo "example: run_test_master.sh python"
exit 1
fi

set -e
Expand All @@ -23,5 +23,4 @@ ${DOCKER:-docker} run -i --init --rm --cap-add=SYS_PTRACE \
-e "GIT_BRANCH=${GIT_BRANCH}" -e "GIT_REF=${GIT_REF}" \
"$@" "img_cp2k_test_${TESTNAME}"


#EOF

0 comments on commit d59a3ad

Please sign in to comment.