Speedup and efficiency shell calculator

The following script can be used to calculate the speedup and efficiency of a parallel code when compared to its serial version. Pretty much straight forward process. This script can be used either individually or as part of another script to automate the process of generating the required results. It accepts three arguments: 1) serial execution time 2) parallel execution time 3) number of processors.

./SEcalc.sh <serial> <parallel> <procs>

Script:

############################################################################
# Copyright (C) 2011  Panagiotis Kritikakos <panoskrt@gmail.com>           #
#                                                                          #
#    This program is free software: you can redistribute it and/or modify  #
#    it under the terms of the GNU General Public License as published by  #
#    the Free Software Foundation, either version 3 of the License, or     #
#    (at your option) any later version.                                   #
#                                                                          #
#    This program is distributed in the hope that it will be useful,       #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#    GNU General Public License for more details.                          #
#                                                                          #
#    You should have received a copy of the GNU General Public License     #
#    along with this program.  If not, see <http://www.gnu.org/licenses/>. #
############################################################################

#!/bin/bash

if [ "$#" -eq "3" ]; then
   runtime1proc=$1
   runtimeNproc=$2
   totalprocs=$3
   speedup=`echo "${runtime1proc}/${runtimeNproc}" | bc -l`;
   efficiency=`echo "${speedup}/${totalprocs}" | bc -l`;

   printf "\n Total processors: ${totalprocs}\n\n";
   printf " Runtime for serial code: ${runtime1proc}\n Runtime for parallel code: \
   ${runtimeNproc}\n\n";
   printf " Speedup: ${speedup}\n Efficiency: ${efficiency}\n\n";
else
   printf "\n Usage: SEcalc.sh   \n\n";
   printf " SEcalc.sh 0.350 0.494 2\n\n";
fi
Advertisement

OS X terminal type σε Solaris

Συνδεόμενος μέσω SSH σε κάποιο μηχάνημα Solaris από OS X, πάω να ανοίξω τον Vi και βλέπω το παρακάτω μήνυμα:

$:vi
xterm-color: Unknown terminal type
Visual needs addressable cursor or upline capability
:

Στη συνέχεια δοκιμάζοντας με Emacs:

$:emacs
emacs: Terminal type xterm-color is not defined.
If that is not the actual type of terminal you have,
use the Bourne shell command `TERM=... export TERM' (C-shell:
`setenv TERM ...') to specify the correct type.  It may be necessary
to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.

Ο λόγος: το OS X έχει ως προεπιλογμένο τύπο terminal το xterm-color το οποίο το Solaris δεν αναγνωρίζει. Ο τύπος του terminal ορίζεται μέσω της μεταβλητής περιβάλλοντος $TERM. Εάν οριστεί αυτή ως vt100 τότε το Solaris θα είναι και πάλι χαρούμενο:

export TERM=vt100

Για συνεχή χρήση του συγκεκριμένου τύπου terminal μπορεί να προστεθεί ο παραπάνω ορισμό στο .bash_profile του απομακρυσμένου λογαριασμού ή ακόμη καλύτερα να γίνει αλλαγή των προεπιλεγμένων ρυθμίσεων του terminal του OS X: