Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update derecho gnu, add code coverage capability via lcov #510

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions configuration/scripts/machines/Macros.derecho_gnu
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@ FREEFLAGS := -ffree-form
FFLAGS := -fconvert=big-endian -fbacktrace -ffree-line-length-none -fallow-argument-mismatch
FFLAGS_NOOPT:= -O0

ifeq ($(ICE_COVERAGE), true)
FFLAGS += -O0 -g -fprofile-arcs -ftest-coverage
CFLAGS += -O0 -g -coverage
LDFLAGS += -g -ftest-coverage -fprofile-arcs
else
ifeq ($(ICE_BLDDEBUG), true)
FFLAGS += -O0 -g -fcheck=bounds -finit-real=nan -fimplicit-none -ffpe-trap=invalid,zero,overflow --std f2008
# FFLAGS += -O0 -g -fcheck=all -finit-real=snan -fimplicit-none -ffpe-trap=invalid,zero,overflow
CFLAGS += -O0
else
FFLAGS += -O2
CFLAGS += -O2
endif
endif

SCC := gcc
Expand Down
29 changes: 25 additions & 4 deletions configuration/scripts/machines/env.derecho_gnu
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ if ("$inp" != "-nomodules") then
source ${MODULESHOME}/init/csh

module --force purge
module load ncarenv/23.06
module load ncarenv/24.12
module load craype
module load gcc/12.2.0
module load gcc/12.4.0
module load ncarcompilers
#module load cray-mpich/8.1.25
#module load hdf5/1.12.2
module load netcdf/4.9.2
module load cray-libsci/23.02.1.1
module load cray-libsci/24.03.0
module load lcov

# For perftools with mpiexec
# module load perftools-base
Expand All @@ -38,7 +39,7 @@ setenv OMP_STACKSIZE 64M
setenv ICE_MACHINE_MACHNAME derecho
setenv ICE_MACHINE_MACHINFO "HPE Cray EX Milan Slingshot 11"
setenv ICE_MACHINE_ENVNAME gnu
setenv ICE_MACHINE_ENVINFO "gcc 12.2.0 20220819, netcdf4.9.2"
setenv ICE_MACHINE_ENVINFO "gcc 12.4.0, netcdf4.9.2"
setenv ICE_MACHINE_MAKE gmake
setenv ICE_MACHINE_WKDIR /glade/derecho/scratch/$user/ICEPACK_RUNS
setenv ICE_MACHINE_INPUTDATA /glade/campaign/cesm/development/pcwg
Expand All @@ -49,3 +50,23 @@ setenv ICE_MACHINE_QUEUE "develop"
setenv ICE_MACHINE_TPNODE 128
setenv ICE_MACHINE_BLDTHRDS 1
setenv ICE_MACHINE_QSTAT "qstat "

# For lcov
#set lcovpath = "/glade/u/home/tcraig/bin"
#set lcovp5l = "/glade/u/home/tcraig/usr/lib/perl5/site_perl/5.18.2/x86_64-linux-thread-multi"

#if ($?PATH) then
# if ("$PATH" !~ "*${lcovpath}*") then
# setenv PATH ${PATH}:$lcovpath
# endif
#else
# setenv PATH $lcovpath
#endif

#if ($?PERL5LIB) then
# if ("$PERL5LIB" !~ "*${lcovp5l}*") then
# setenv PERL5LIB ${PERL5LIB}:$lcovp5l
# endif
#else
# setenv PERL5LIB $lcovp5l
#endif
21 changes: 19 additions & 2 deletions configuration/scripts/tests/icepack.lcov.csh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,32 @@ lcov ${lcovalist} -o total.info

set lcovrepo = apcraig.github.io
set lcovhtmldir = lcov_icepack_${report_name}
genhtml -o ./${lcovhtmldir} --precision 2 -t "${report_name}" total.info
if ("${useparser}" =~ "true") then
#local parsing script
mkdir ./${lcovhtmldir}
./parse_lcov.sh >! ./${lcovhtmldir}/${lcovhtmldir}.txt
cat >! ./${lcovhtmldir}/index.html <<EOF

<embed type="text/plain" src="${lcovhtmldir}.txt" width="800" height="20000">

EOF
else
#genhtml
genhtml -o ./${lcovhtmldir} --precision 2 -t "${report_name}" total.info
endif

rm -r -f ${lcovrepo}
git clone https://github.com/apcraig/${lcovrepo}
cp -p -r ${lcovhtmldir} ${lcovrepo}/

cd ${lcovrepo}
set covp0 = `grep message coverage_icepack.json | cut -d : -f 2 | cut -d \" -f 2 | cut -d % -f 1`
set covp = `grep -i headerCovTableEntry ${lcovhtmldir}/index.html | grep % | head -1 | cut -d \> -f 2 | cut -d % -f 1`
if ("${useparser}" =~ "true") then
set covp = `grep "**TOTAL**" ${lcovhtmldir}/${lcovhtmldir}.txt | cut -d \% -f 1`
else
set covp = `grep -i headerCovTableEntry ${lcovhtmldir}/index.html | grep % | head -1 | cut -d \> -f 2 | cut -d \& -f 1`
set covp = "${covp}%"
endif
set covpi = `echo $covp | cut -d . -f 1`

set lcovhtmlname = "${covpi}%:${report_name}"
Expand Down
86 changes: 86 additions & 0 deletions configuration/scripts/tests/parse_lcov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/bin/sh

INFILE=total.info

file="ZZZ"
tfunc=0
thit=0
tfnd=0
dacnt=0
declare -a func
declare -a lines
declare -a linee
declare -a fhit
declare -a ffnd
echo " "

while read -r LINE
do
case $LINE in
SF:*)
file="${LINE##*/}"
;;
FN:*)
if [[ "$LINE" =~ ^FN:(.*),(.*),.*_MOD_(.*)$ ]]; then
func[$tfunc]="${BASH_REMATCH[3]}"
lines[$tfunc]="${BASH_REMATCH[1]}"
linee[$tfunc]="${BASH_REMATCH[2]}"
fhit[$tfunc]=0
ffnd[$tfunc]=0
tfunc=$(($tfunc + 1))
fi
;;
DA:*)
if [[ "$LINE" =~ ^DA:(.*),(.*)$ ]]; then
lnum="${BASH_REMATCH[1]}"
lhit="${BASH_REMATCH[2]}"
# echo "tcx3a ${linee[$dacnt]} $lnum $lhit $dacnt"
if [[ $lnum -lt ${lines[$dacnt]} || $lnum -gt ${linee[$dacnt]} ]]; then
cnt=0
while [ $cnt -lt $tfunc ]; do
if [[ $lnum -ge ${lines[$cnt]} && $lnum -le ${linee[$cnt]} ]]; then
dacnt=$cnt
fi
cnt=$(($cnt + 1))
done
fi
# echo "tcx3b $lnum $lhit $dacnt"
ffnd[$dacnt]=$((ffnd[$dacnt] + 1))
if [[ $lhit -gt 0 ]]; then
fhit[$dacnt]=$((fhit[$dacnt] + 1))
fi
fi
;;
LF:*)
fnd="${LINE##*:}"
;;
LH:*)
hit="${LINE##*:}"
;;
end_of_record)
thit=$(($thit + $hit))
tfnd=$(($tfnd + $fnd))
percent=`echo "scale=2; $hit * 100. / $fnd" | bc`
printf "%6.2f%% %-42s %5d %5d\n" $percent $file $hit $fnd
cnt=0
while [ $cnt -lt $tfunc ]; do
percent=`echo "scale=2; $((fhit[$cnt] * 100 / ffnd[$cnt]))" | bc`
# printf "%6.2f%% %-40s %5d %5d\n" 0 ${func[$cnt]} ${lines[$cnt]} ${linee[$cnt]}
printf "%12.2f%% %-36s %5d %5d\n" $percent ${func[$cnt]} ${fhit[$cnt]} ${ffnd[$cnt]}
cnt=$(($cnt + 1))
done
file="ZZZ"
tfunc=0
dacnt=0
;;
*)
;;
esac

done < "$INFILE"

echo " "
#echo "tcx1 $thit $tfnd"
percent=`echo "scale=2; $thit * 100. / $tfnd" | bc`
printf "%6.2f%% %-32s %10d %10d\n" $percent **TOTAL** $thit $tfnd
echo " "
21 changes: 19 additions & 2 deletions icepack.setup
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ else
cp -f ${ICE_SCRIPTS}/tests/report_results.csh ${tsdir}
cp -f ${ICE_SCRIPTS}/tests/timeseries.csh ${tsdir}
cp -f ${ICE_SCRIPTS}/tests/poll_queue.csh ${tsdir}
cp -f ${ICE_SCRIPTS}/tests/parse_lcov.sh ${tsdir}

cat >! ${tsdir}/suite.run << EOF0
#!/bin/csh -f
Expand Down Expand Up @@ -466,6 +467,21 @@ EOF0
cat >! ${tsdir}/report_codecov.csh << EOF0
#!/bin/csh -f

set useparser = false
if (\$#argv > 0) then
if (\$#argv > 1) then
echo "\${0}: ERROR, -parse is the only optional argument allowed"
exit 3
else
if ("\$argv[1]" =~ "-parse") then
set useparser = true
else
echo "\${0}: ERROR, -parse is the only optional argument allowed"
exit 3
endif
endif
endif

source ${ICE_SCRIPTS}/machines/env.${machcomp}

set rn0 = "${sdate}-${stime}:${shhash}:${testsuitecnt}:${testsuite}"
Expand Down Expand Up @@ -903,7 +919,7 @@ cp ${rundir}/compile/*.{gcno,gcda} ${testname_base}/codecov_output/
EOF

cat >> ${tsdir}/report_lcov.csh << EOF
lcov --gcov-tool gcov -c -d ${rundir}/compile -o ${testname_base}/lcov.info
lcov --gcov-tool gcov -c --rc geninfo_unexecuted_blocks=1 -d ${rundir}/compile -o ${testname_base}/lcov.info
if (-s ${testname_base}/lcov.info) then
set lcovalist = "\${lcovalist} -a ${testname_base}/lcov.info"
endif
Expand All @@ -917,7 +933,7 @@ echo "${testname_base}"
cd ${testname_base}
source ./icepack.settings
set md5chk = \`where md5sum\`
if ("\${md5chk}" != "") then
if ("\${md5chk}" != "" && "${coverage}" == "0") then
set md5file = icepack.settings.md5
grep -v " ICE_CASENAME " icepack.settings | grep -v " ICE_CASEDIR " | grep -v " ICE_RUNDIR " | grep -v " ICE_TESTNAME " | grep -v " ICE_TEST " >! \${md5file}
set icepsetmd5 = \` md5sum \${md5file} | cut -d " " -f 1 \`
Expand Down Expand Up @@ -987,6 +1003,7 @@ EOF0
if ($coverage == 1) then
echo "Generating coverage reports"
./poll_queue.csh
# ./report_lcov.csh -parse
./report_lcov.csh
# ./report_codecov.csh
endif
Expand Down