Skip to content

Latest commit

 

History

History
288 lines (246 loc) · 8.33 KB

File metadata and controls

288 lines (246 loc) · 8.33 KB

Os scripts a seguir contêm os comandos necessários para controle e registro de informações da plataforma. É conveniente manter os dados coletados juntamente com os logs dos experimentos de forma a facilitar a análise posterior dos resultados.

Desabilitar Turboboost (Processadores Intel)

#!/bin/bash
DIR=$(dirname $0)

if [ `lsmod | grep msr | wc -l` -ne 1 ]; then
    echo "The =msr= module is not loaded. It should be."
    exit 1;
fi

# Get the list of online cores
ONLINECPUS=$(for CPU in $(find /sys/devices/system/cpu/ | grep -v cpu0 | grep cpu[0-9]*$); do [[ $(cat $CPU/online) -eq 1 ]] && echo $CPU; done | grep cpu[0-9]*$ | sed 's/.*cpu//')

# Enable
for PU in ${ONLINECPUS}; do
    sudo zsh -c "/usr/sbin/wrmsr -p${PU} 0x1a0 0x850089"
done

# Disable & Check
for PU in ${ONLINECPUS}; do
    echo "Disabling turbo boost mode for PU $PU."
    sudo zsh -c "/usr/sbin/wrmsr -p${PU} 0x1a0 0x4000850089"
    TURBOBOOST=$(sudo zsh -c "/usr/sbin/rdmsr -p${PU} 0x1a0 -f 38:38")
    if [[ "0" = $TURBOBOOST ]]; then
       echo "Failed to disable turbo boost for PU number $cpu. Aborting."
       exit 1
    fi
done

Desabilitar Hyperthreading (Processadores Intel)

#!/bin/bash
DIR=$(dirname $0)

#First, enable all cores
for PU in `find /sys/devices/system/cpu/ |grep cpu[0-9]*$`; do
   echo "Enabling $PU now."
    sudo zsh -c "echo 1 > ${PU}/online"
done

HYPERTHREADING=`$DIR/hyperthreading.sh | grep -e "Hyperthreading is ON" | wc -l`
if [ $HYPERTHREADING -eq 0 ]; then
   echo "Hyperthreading is OFF, so disabling is not necessary."
   exit
else
    echo "Hyperthreading is ON."
fi
echo "The number of PUs now is $(hwloc-ls  --only PU | wc -l)."
echo "I will disable hyperthreading now."
# Disable hyperthreading
# Only run this if you are sure
# - Hyperthreading is enabled
# - Each physical core has two processing units (PU)
# - hwloc-ls is installed and reports two PU per physical core
for PU in `hwloc-ls --only PU | cat -n | grep -e "[[:space:]]*[0-9]*[02468][[:space:]]*PU" | sed -e "s/^[^(]*(P#\\([0-9]*\))/\1/"`; do
   echo "Disabling PU $PU now."
   sudo zsh -c "echo 0 > /sys/devices/system/cpu/cpu${PU}/online"
done
echo "The number of PUs now is $(hwloc-ls  --only PU | wc -l)."
#!/bin/bash
CPUFILE=/proc/cpuinfo
test -f $CPUFILE || exit 1
NUMPHYCPU=`grep "physical id" $CPUFILE | sort -u | wc -l`
NUMLOGCORE=`grep "processor" $CPUFILE | wc -l`
NUMPHYCORE=`grep "core id" $CPUFILE | sort -u | wc -l`
TOTALNUMPHYCORE=$(echo "$NUMPHYCPU * $NUMPHYCORE" | bc)
MODEL=`grep "model name" $CPUFILE | sort -u | cut -d : -f 2- | sed "s/^[[:space:]]*//"`
echo "This system has $NUMPHYCPU CPUs, of model \"$MODEL\"."
echo "Each physical CPU is equipped with $NUMPHYCORE physical cores (total is $TOTALNUMPHYCORE)."
if [ $TOTALNUMPHYCORE -ne $NUMLOGCORE ]; then
   echo "Hyperthreading is ON. So, there are $NUMLOGCORE logical cores."
else
   echo "Hyperthreading is OFF."
fi
exit

Detectar Driver ACPI

#!/bin/bash
DIR=$(dirname $0)

function usage()
{
    echo "Input: number of CPUs to be used"
    echo "Output: core identifiers (NUMA-aware)"
    echo "$0 <ncpus>";
}

PRESENT=$(cpufreq-info | grep driver | uniq | grep acpi-cpufreq | wc -l)
if [ $PRESENT -ne 1 ]; then
    exit 1;
fi

exit 0

Registro de Informações do Plataforma

#!/bin/bash
# Script for to get machine information before doing the experiment

set +e # Don't fail fast since some information is maybe not available

title="Experiment results"
inputfile=""
host="$(hostname | sed 's/[0-9]*//g' | cut -d'.' -f1)"
help_script()
{
    cat << EOF
Usage: $0 [options] outputfile.org

Script for to get machine information before doing the experiment

OPTIONS:
   -h      Show this message
   -t      Title of the output file
EOF
}
# Parsing options
while getopts "t:s:i:h" opt; do
    case $opt in
	t)
	    title="$OPTARG"
	    ;;
	h)
	    help_script
	    exit 4
	    ;;
	\?)
	    echo "Invalid option: -$OPTARG"
	    help_script
	    exit 3
	    ;;
    esac
done

shift $((OPTIND - 1))
filedat=$1
if [[ $# != 1 ]]; then
    echo 'ERROR!'
    help_script
    exit 2
fi

##################################################
# Preambule of the output file
echo "#+TITLE: $title" >> $filedat
echo "#+DATE: $(eval date)" >> $filedat
echo "#+AUTHOR: $(eval whoami)" >> $filedat
echo "#+MACHINE: $(eval hostname)" >> $filedat
echo "#+FILE: $(eval basename $filedat)" >> $filedat
if [[ -n "$inputfile" ]]; 
then
    echo "#+INPUTFILE: $inputfile" >> $filedat
fi
echo " " >> $filedat 

##################################################
# Collecting metadata
echo "* MACHINE INFO:" >> $filedat

echo "** PEOPLE LOGGED WHEN EXPERIMENT STARTED:" >> $filedat
who >> $filedat
echo "############################################" >> $filedat

echo "** ENVIRONMENT VARIABLES:" >> $filedat
env >> $filedat
echo "############################################" >> $filedat

echo "** HOSTNAME:" >> $filedat
hostname >> $filedat
echo "############################################" >> $filedat

if [[ -n $(command -v lstopo) ]];
then
    echo "** MEMORY HIERARCHY:" >> $filedat
    lstopo --of console >> $filedat
    echo "############################################" >> $filedat
fi

if [ -f /proc/cpuinfo ];
then
    echo "** CPU INFO:" >> $filedat
    cat /proc/cpuinfo >> $filedat
    echo "############################################" >> $filedat
fi

if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ];
then
    echo "** CPU GOVERNOR:" >> $filedat
    ONLINECPUS=$(for CPU in $(find /sys/devices/system/cpu/ | grep cpu[0-9]*$); do [[ $(cat $CPU/online) -eq 1 ]] && echo $CPU; done | grep cpu[0-9]*$ | sed 's/.*cpu//')
    for PU in ${ONLINECPUS}; do
	     echo -n "CPU frequency for cpu${PU}: " >> $filedat
       cat /sys/devices/system/cpu/cpu${PU}/cpufreq/scaling_governor >> $filedat
    done
    echo "############################################" >> $filedat
fi

if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq ];
then
    echo "** CPU FREQUENCY:" >> $filedat
    ONLINECPUS=$(for CPU in $(find /sys/devices/system/cpu/ | grep cpu[0-9]*$); do [[ $(cat $CPU/online) -eq 1 ]] && echo $CPU; done | grep cpu[0-9]*$ | sed 's/.*cpu//')
    for PU in ${ONLINECPUS}; do
	     echo -n "CPU frequency for cpu${PU}: " >> $filedat
	     cat /sys/devices/system/cpu/cpu${PU}/cpufreq/scaling_cur_freq >> $filedat
    done
    echo "############################################" >> $filedat
fi

if [ -f /usr/bin/cpufreq-info ];
then
    echo "** CPUFREQ_INFO" >> $filedat
    cpufreq-info >> $filedat
    echo "############################################" >> $filedat
fi

if [ -f /usr/bin/lspci ];
then
    echo "** LSPCI" >> $filedat
    lspci >> $filedat
    echo "############################################" >> $filedat
fi

if [ -f /usr/bin/ompi_info ];
then
    echo "** OMPI_INFO" >> $filedat
    ompi_info --all >> $filedat
    echo "############################################" >> $filedat
fi

if [ -f /sbin/ifconfig ];
then
    echo "** IFCONFIG" >> $filedat
    /sbin/ifconfig >> $filedat
    echo "############################################" >> $filedat
fi

if [[ -n $(command -v nvidia-smi) ]];
then
    echo "** GPU INFO FROM NVIDIA-SMI:" >> $filedat
    nvidia-smi -q >> $filedat
    echo "############################################" >> $filedat
fi 

if [ -f /proc/version ];
then
    echo "** LINUX AND GCC VERSIONS:" >> $filedat
    cat /proc/version >> $filedat
    echo "############################################" >> $filedat
fi

if [[ -n $(command -v module) ]];
then
    echo "** MODULES:" >> $filedat
    module list 2>> $filedat
    echo "############################################" >> $filedat
fi

echo "** TCP PARAMETERS" >> $filedat
FILES="/proc/sys/net/core/rmem_max \
/proc/sys/net/core/wmem_max \
/proc/sys/net/core/rmem_default \
/proc/sys/net/core/wmem_default \
/proc/sys/net/core/netdev_max_backlog \
/proc/sys/net/ipv4/tcp_rmem \
/proc/sys/net/ipv4/tcp_wmem \
/proc/sys/net/ipv4/tcp_mem"

for FILE in $FILES; do
    echo "cat $FILE"
    cat $FILE
done >> $filedat