rt_benchs/communication_techniques/lancement.sh

152 lines
4.9 KiB
Bash
Executable File

#! /bin/bash
#
# Copyright (C) 2009-2012 Thomas Preud'homme <thomas.preud-homme@lip6.fr>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set -u
LC_ALL=C
# Files and directories
binDir="bin"
calcDir="calculation"
# Param
binList="$(ls -1 "${binDir}"| sed '$!s/$/ /' | tr -d '\n')"
nbNodesList="2" # Nombre de noeuds chainés dans le pipeline
typeProdList="none useless_loop line matrice" # Methode pour produire les valeurs
typeCacheList="L2 Memory" # Niveau de cache partage
perfOpt="stat -B -r 10 -e cycles -e L1-dcache-loads -e L1-dcache-stores -e L1-dcache-load-misses -e L1-dcache-store-misses -e L1-dcache-prefetch-misses"
# Const
nbIter="500000768" # Nb de lignes produites (doit être un multiple de BUF_SIZE)
sizeBuf="1" # En nombre de lignes de cache
# Nom generique des fichiers de log
logFileName="\$perfDirName/cache_\$typeCache-nbNodes_\$nbNodes-typeProd_\$typeProd-argTypeProd_\$argTypeProd-nbIter_\$nbIter-\$bin.log"
expDirName="logs"
perfDirName="$expDirName/perfCommMulti-`date +'%F-%Hh%Mm%S'`"
perf --help stat | grep -- " -o"
perfOutput=$?
if [ $perfOutput -eq 0 ]
then
perfOpt="$perfOpt -o $logFileName.perf"
fi
export LD_LIBRARY_PATH
[ -d "$expDirName" ] || mkdir "$expDirName"
[ -d "$perfDirName" ] || mkdir "$perfDirName"
function_run () {
case $typeProd in
"none" ) optTypeProd="" ;;
"line" ) optTypeProd="-c lib/${calcDir}/libcalc_line.so ${argTypeProd}" ;;
"matrice" ) optTypeProd="-c lib/${calcDir}/libcalc_mat.so ${argTypeProd}" ;;
"useless_loop" ) optTypeProd="-c lib/${calcDir}/libcalc_useless_loop.so ${argTypeProd}" ;;
* ) exit 1 ;;
esac
case $typeCache in
"Memory" ) optTypeCache="" ;;
"L2" ) optTypeCache="-s" ;;
* ) exit 1 ;;
esac
nbNodes=$((nbNodes))
case $nbNodes in
"") exit 1 ;;
0|1 ) exit 1 ;;
2 ) optNbNodes="" ;;
[0-9]* ) optNbNodes="-l $nbNodes" ;;
*) exit 1 ;;
esac
make $binDir/$bin
if [ $perfOutput -eq 0 ]
then
cmdLineRun="eval perf $perfOpt $binDir/$bin $optTypeCache $optTypeProd $optNbNodes -n $nbIter"
else
cmdLineRun="eval script -c \"perf $perfOpt $binDir/$bin $optTypeCache $optTypeProd $optNbNodes -n $nbIter\" $logFileName"
fi
echo "On lance : \"$cmdLineRun\""
beginingDate=`date +%s`
if [ $perfOutput -eq 0 ]
then
( $cmdLineRun 2>&1 || echo "echec experience" ) | eval tee $logFileName
logFileNameVal="$(eval echo $logFileName)"
cat $logFileNameVal.perf >> $logFileNameVal
rm $logFileNameVal.perf
else
( $cmdLineRun 2>&1 || echo "echec experience" )
fi
endDate=`date +%s`
duration_sec=`expr \( $endDate - $beginingDate \) % 60`
duration_min=`expr \( $endDate - $beginingDate \) / 60`
duration_hrs=`expr $duration_min / 60`
duration_min=`expr $duration_min % 60`
echo "Fin de l'experience : `date +'%H:%M:%S (%d/%m/%y)'`"
echo "La duree est de : ${duration_hrs}hrs ${duration_min}min ${duration_sec}sec"
echo ""
}
eval echo \"# Describe what this experiment is about: \\\"what are the parameters evaluated?\\\"\" > "$perfDirName/description"
eval vim "$perfDirName/description"
echo -e "On commence les perfs\n"
globalBeginingDate=`date +%s`
for nbNodes in $nbNodesList ; do
for typeProd in $typeProdList; do
for typeCache in $typeCacheList ; do
for bin in $binList ; do
case $typeProd in
"useless_loop" )
for argTypeProd in 1 `seq 5 5 50` ; do
function_run ;
done ;;
"line" )
for argTypeProd in 1 2 4 8 16 32 64 ; do
function_run ;
done ;;
"matrice" )
argTypeProd=16 ;
function_run ;;
* )
argTypeProd=1 ;
function_run ;;
esac
done
done
done
done
globalEndDate=`date +%s`
globalDuration_sec=`expr \( $globalEndDate - $globalBeginingDate \) % 60`
globalDuration_min=`expr \( $globalEndDate - $globalBeginingDate \) / 60`
globalDuration_hrs=`expr $globalDuration_min / 60`
globalDuration_min=`expr $globalDuration_min % 60`
echo "Fin de la serie d'experience : `date +'%H:%M:%S (%d/%m/%y)'`"
echo "La duree totale est de : ${globalDuration_hrs}hrs ${globalDuration_min}min ${globalDuration_sec}sec"