#!/bin/bash # # Copyright (c) 2016-2017 Inria. All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow # # $HEADER$ # # # Author Clément Foyer # # This script launches the test_overhead test case for 2, 4, 8, 12, # 16, 20 and 24 processes, once with the monitoring component enabled, # and once without any monitoring. It then parses and aggregates the # results in order to create heatmaps. To work properly, this scripts # needs sqlite3, sed, awk and gnuplot. It also needs the rights to # write/create directories in the working path. Temporary files can be # found in $resdir/.tmp. They are cleaned between two executions fo # this script. # # This file create as an output one heatmap per operation # tested. Currently, tested operations are : # - MPI_Send (software overhead) # - MPI_Send (ping-pong, to measure the overhead with the communication time) # - MPI_Bcast # - MPI_Alltoall # - MPI_Put # - MPI_Get # exe=test_overhead # add common options if [ $# -ge 1 ] then mfile="-machinefile $1" fi common_opt="$mfile --bind-to core" # dir resdir=res tmpdir=$resdir/.tmp # files base_nomon=$resdir/unmonitored base_mon=$resdir/monitored dbfile=$tmpdir/base.db dbscript=$tmpdir/overhead.sql plotfile=$tmpdir/plot.gp # operations ops=(send a2a bcast put get sendpp) # no_monitoring(nb_nodes, exe_name, output_filename, error_filename) function no_monitoring() { mpiexec -n $1 $common_opt --mca pml ^monitoring --mca osc ^monitoring --mca coll ^monitoring $2 2> $4 > $3 } # monitoring(nb_nodes, exe_name, output_filename, error_filename) function monitoring() { mpiexec -n $1 $common_opt --mca pml_monitoring_enable 1 --mca pml_monitoring_enable_output 3 --mca pml_monitoring_filename "prof/toto" $2 2> $4 > $3 } # filter_output(filenames_list) function filter_output() { for filename in "$@" do # remove extra texts from the output sed -i '/--------------------------------------------------------------------------/,/--------------------------------------------------------------------------/d' $filename # create all sub files as $tmpdir/$filename file=$(sed -e "s|$resdir/|$tmpdir/|" -e "s/\.dat/.csv/" <<< $filename) # split in file, one per kind of operation monitored awk "/^# MPI_Send/ {out=\"$(sed "s/\.$nbprocs/.send&/" <<< $file)\"}; \ /^# MPI_Bcast/ {out=\"$(sed "s/\.$nbprocs/.bcast&/" <<< $file)\"}; \ /^# MPI_Alltoall/ {out=\"$(sed "s/\.$nbprocs/.a2a&/" <<< $file)\"}; \ /^# MPI_Put/ {out=\"$(sed "s/\.$nbprocs/.put&/" <<< $file)\"}; \ /^# MPI_Get/ {out=\"$(sed "s/\.$nbprocs/.get&/" <<< $file)\"}; \ /^# MPI_Send_pp/ {out=\"$(sed "s/\.$nbprocs/.sendpp&/" <<< $file)\"}; \ /^#/ { } ; !/^#/ {\$0=\"$nbprocs \"\$0; print > out};" \ out=$tmpdir/tmp $filename done # trim spaces and replace them with comma in each file generated with awk for file in `ls $tmpdir/*.*.$nbprocs.csv` do sed -i 's/[[:space:]]\{1,\}/,/g' $file done } # clean previous execution if any if [ -d $tmpdir ] then rm -fr $tmpdir fi mkdir -p $tmpdir # start creating the sql file for data post-processing cat > $dbscript <> $dbscript echo -e "create table if not exists ${op}_mon (nbprocs integer, datasize integer, lat float, speed float, MBspeed float, media float, q1 float, q3 float, d1 float, d9 float, average float, maximum float, primary key (nbprocs, datasize) on conflict abort);\ncreate table if not exists ${op}_nomon (nbprocs integer, datasize integer, lat float, speed float, MBspeed float, media float, q1 float, q3 float, d1 float, d9 float, average float, maximum float, primary key (nbprocs, datasize) on conflict abort);" >> $dbscript done # main loop to launch benchmarks for nbprocs in 2 4 8 12 16 20 24 do echo "$nbprocs procs..." output_nomon="$base_nomon.$nbprocs.dat" error_nomon="$base_nomon.$nbprocs.err" output_mon="$base_mon.$nbprocs.dat" error_mon="$base_mon.$nbprocs.err" # actually do the benchmarks no_monitoring $nbprocs $exe $output_nomon $error_nomon monitoring $nbprocs $exe $output_mon $error_mon # prepare data to insert them more easily into database filter_output $output_nomon $output_mon # insert into database echo -e "\n-- Import each CSV file in its corresponding table" >> $dbscript for op in ${ops[*]} do echo -e ".import $(sed "s|$resdir/|$tmpdir/|" <<<$base_mon).${op}.${nbprocs}.csv ${op}_mon\n.import $(sed "s|$resdir/|$tmpdir/|" <<<$base_nomon).${op}.${nbprocs}.csv ${op}_nomon" >> $dbscript done done echo "Fetch data..." echo -e "\n-- Perform some select query" >> $dbscript for op in ${ops[*]} do cat >> $dbscript <> $dbscript <> $dbscript <> $dbscript < $plotfile < out ; print $0 > out } else { print $0 > out } }' out=$tmpdir/${op}.dat $tmpdir/${op}.dat echo -e "set output '$resdir/${op}.png'\nsplot '$tmpdir/${op}.dat' using (\$1):(\$2):(\$3) with pm3d" done) EOF echo "Generating graphs..." gnuplot < $plotfile echo "Done."