|
Packit |
857059 |
#!/bin/bash
|
|
Packit |
857059 |
# BEGIN_ICS_COPYRIGHT8 ****************************************
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# Copyright (c) 2015, Intel Corporation
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# Redistribution and use in source and binary forms, with or without
|
|
Packit |
857059 |
# modification, are permitted provided that the following conditions are met:
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# * Redistributions of source code must retain the above copyright notice,
|
|
Packit |
857059 |
# this list of conditions and the following disclaimer.
|
|
Packit |
857059 |
# * Redistributions in binary form must reproduce the above copyright
|
|
Packit |
857059 |
# notice, this list of conditions and the following disclaimer in the
|
|
Packit |
857059 |
# documentation and/or other materials provided with the distribution.
|
|
Packit |
857059 |
# * Neither the name of Intel Corporation nor the names of its contributors
|
|
Packit |
857059 |
# may be used to endorse or promote products derived from this software
|
|
Packit |
857059 |
# without specific prior written permission.
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
857059 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
857059 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
Packit |
857059 |
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
Packit |
857059 |
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
Packit |
857059 |
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
Packit |
857059 |
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
Packit |
857059 |
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
Packit |
857059 |
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Packit |
857059 |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# END_ICS_COPYRIGHT8 ****************************************
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# [ICS VERSION STRING: unknown]
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# Might want to tune this later.
|
|
Packit |
857059 |
NBs=168
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# Generate some reasonable defaults based on the current node.
|
|
Packit |
857059 |
default_numcores=$(lscpu | grep "^CPU(s):" | awk '{print $2}')
|
|
Packit |
857059 |
bytesram=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}')
|
|
Packit |
857059 |
default_megsram=$(( $bytesram / 1024 ))
|
|
Packit |
857059 |
default_pressure=0.3
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# If we have an mpi_hosts file, use that for the default # of hosts.
|
|
Packit |
857059 |
if [ -e /usr/src/opa/mpi_hosts ]; then
|
|
Packit |
857059 |
default_numnodes=$(sort -u mpi_hosts | wc -l)
|
|
Packit |
857059 |
else
|
|
Packit |
857059 |
default_numnodes=1
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
numcores=$default_numcores
|
|
Packit |
857059 |
megsram=$default_megsram
|
|
Packit |
857059 |
pressure=$default_pressure
|
|
Packit |
857059 |
numnodes=$default_numnodes
|
|
Packit |
857059 |
|
|
Packit |
857059 |
USAGE() {
|
|
Packit |
857059 |
echo >&2
|
|
Packit |
857059 |
echo >&2 "Usage:"
|
|
Packit |
857059 |
echo >&2 " ./hpl_dat_gen.sh [-2|-1][-n <nodes>][-c <cores>][-r <ram>][-p <pressure>][-d]"
|
|
Packit |
857059 |
echo >&2
|
|
Packit |
857059 |
echo >&2 " This tool generates an HPL.dat file and copies it to the appropriate hpl"
|
|
Packit |
857059 |
echo >&2 " executable directory (hpl-2.2/bin/ICS.Linux.*)"
|
|
Packit |
857059 |
echo >&2
|
|
Packit |
857059 |
echo >&2 " The HPL.dat file can be tuned for different numbers of nodes, cores per node,"
|
|
Packit |
857059 |
echo >&2 " and the approximate amount of RAM per node to use. The script chooses"
|
|
Packit |
857059 |
echo >&2 " defaults based on the characteristics of the node the script is run on, but"
|
|
Packit |
857059 |
echo >&2 " these values can be overridden either by command line options or by"
|
|
Packit |
857059 |
echo >&2 " prompting the user to enter new values."
|
|
Packit |
857059 |
echo >&2
|
|
Packit |
857059 |
echo >&2 "Options:"
|
|
Packit |
857059 |
echo >&2
|
|
Packit |
857059 |
echo >&2 " --nodes <nodes>"
|
|
Packit |
857059 |
echo >&2 " -n <nodes> # of nodes in the fabric."
|
|
Packit |
857059 |
echo >&2
|
|
Packit |
857059 |
echo >&2 " --cores <cores>"
|
|
Packit |
857059 |
echo >&2 " -c <cores> # of cores per node."
|
|
Packit |
857059 |
echo >&2
|
|
Packit |
857059 |
echo >&2 " --ram <ram>"
|
|
Packit |
857059 |
echo >&2 " -r <ram> Amount of RAM per node in MB."
|
|
Packit |
857059 |
echo >&2
|
|
Packit |
857059 |
echo >&2 " --pressure "
|
|
Packit |
857059 |
echo >&2 " -p Total memory pressure, expressed as a number"
|
|
Packit |
857059 |
echo >&2 " between 0.1 and 0.9. This value scales the"
|
|
Packit |
857059 |
echo >&2 " problem size against the amount of RAM available."
|
|
Packit |
857059 |
echo >&2 " (For example, a pressure of 0.5 will use about"
|
|
Packit |
857059 |
echo >&2 " half the available RAM on each node.)"
|
|
Packit |
857059 |
echo >&2
|
|
Packit |
857059 |
echo >&2 " --use-defaults"
|
|
Packit |
857059 |
echo >&2 " -d Use defaults for unspecified values."
|
|
Packit |
857059 |
echo >&2 " (otherwise prompt for the missing values.)"
|
|
Packit |
857059 |
echo >&2
|
|
Packit |
857059 |
echo >&2 "Defaults for this system are:"
|
|
Packit |
857059 |
echo >&2 " -2"
|
|
Packit |
857059 |
echo >&2 " -n $default_numnodes"
|
|
Packit |
857059 |
echo >&2 " -c $default_numcores"
|
|
Packit |
857059 |
echo >&2 " -r $default_megsram"
|
|
Packit |
857059 |
echo >&2 " -p $default_pressure"
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
P=0
|
|
Packit |
857059 |
Q=0
|
|
Packit |
857059 |
HPL_PQ() {
|
|
Packit |
857059 |
local cores=$1
|
|
Packit |
857059 |
local pp
|
|
Packit |
857059 |
local qq
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# Find values of P and Q that use every available core and are as close
|
|
Packit |
857059 |
# in value as possible, with Q being slightly larger than P.
|
|
Packit |
857059 |
# For example, if the # of cores is 36, the optimal (P,Q) is (4,9) rather
|
|
Packit |
857059 |
# than (6,6).
|
|
Packit |
857059 |
for pp in $(seq 1 $cores); do
|
|
Packit |
857059 |
qq=$(( $cores / $pp))
|
|
Packit |
857059 |
ll=$(( $pp * $qq))
|
|
Packit |
857059 |
if [ $pp -ge $qq ]; then
|
|
Packit |
857059 |
break
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
if [ $ll -eq $cores ]; then
|
|
Packit |
857059 |
P=$pp;
|
|
Packit |
857059 |
Q=$qq;
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
done
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
Ns=""
|
|
Packit |
857059 |
CALC_NS() {
|
|
Packit |
857059 |
local numnodes=$1
|
|
Packit |
857059 |
local megspernode=$2
|
|
Packit |
857059 |
local pressure=$3
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# This calculation adjusts the size of the HPL problem to a percentage
|
|
Packit |
857059 |
# of the available RAM. The formula is:
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# "Take the square root of the total amount of memory in the cluster
|
|
Packit |
857059 |
# divided by the number of bytes in a double precision number, then
|
|
Packit |
857059 |
# multiply by the requested memory pressure and round up to a multiple
|
|
Packit |
857059 |
# of the block size."
|
|
Packit |
857059 |
Ns=$(echo "sqrt($megspernode * 1024 * 1024 * $numnodes / 8) * $pressure / $NBs * $NBs" | bc)
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
inputval=""
|
|
Packit |
857059 |
GET_INPUT() {
|
|
Packit |
857059 |
local defval=""
|
|
Packit |
857059 |
local prompt="Input"
|
|
Packit |
857059 |
local value=""
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ $# -ge 1 ]; then
|
|
Packit |
857059 |
prompt=$1
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ $# -ge 2 ]; then
|
|
Packit |
857059 |
defval=$2
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
while [ -z $value ]; do
|
|
Packit |
857059 |
if [ ! -z $defval ]; then
|
|
Packit |
857059 |
echo -n "$prompt [$defval]? "
|
|
Packit |
857059 |
else
|
|
Packit |
857059 |
echo -n "$prompt? "
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
read value
|
|
Packit |
857059 |
if [ -z $value ]; then
|
|
Packit |
857059 |
value=$defval
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
done
|
|
Packit |
857059 |
|
|
Packit |
857059 |
inputval=$value
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
TEMP_FILE="$(mktemp)"
|
|
Packit |
857059 |
trap "rm -rf $TEMP_FILE; exit 1" SIGINT SIGHUP SIGTERM
|
|
Packit |
857059 |
trap "rm -rf $TEMP_FILE" EXIT
|
|
Packit |
857059 |
|
|
Packit |
857059 |
arch=ICS.`uname -s`.`./get_mpi_cc.sh`
|
|
Packit |
857059 |
|
|
Packit |
857059 |
got_nodes=0
|
|
Packit |
857059 |
got_cores=0
|
|
Packit |
857059 |
got_ram=0
|
|
Packit |
857059 |
got_pressure=0
|
|
Packit |
857059 |
use_defaults=0
|
|
Packit |
857059 |
|
|
Packit |
857059 |
OPTIONS=$(getopt -o "n:c:r:p:hd12" --long "nodes:,cores:,ram:,pressure:,help,use-defaults" -- "$@")
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ $? -ne 0 ]; then
|
|
Packit |
857059 |
USAGE; exit 1
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
eval set -- "$OPTIONS"
|
|
Packit |
857059 |
|
|
Packit |
857059 |
while true; do
|
|
Packit |
857059 |
case "$1" in
|
|
Packit |
857059 |
-n | --nodes )
|
|
Packit |
857059 |
numnodes=$2; got_nodes=1;
|
|
Packit |
857059 |
shift; shift;;
|
|
Packit |
857059 |
-c | --cores )
|
|
Packit |
857059 |
numcores=$2; got_cores=1;
|
|
Packit |
857059 |
shift; shift;;
|
|
Packit |
857059 |
-r | --ram )
|
|
Packit |
857059 |
megsram=$2; got_ram=1;
|
|
Packit |
857059 |
shift; shift;;
|
|
Packit |
857059 |
-p | --pressure )
|
|
Packit |
857059 |
pressure=$2; got_pressure=1;
|
|
Packit |
857059 |
shift; shift;;
|
|
Packit |
857059 |
-d | --use-defaults )
|
|
Packit |
857059 |
use_defaults=1;
|
|
Packit |
857059 |
shift;;
|
|
Packit |
857059 |
-- )
|
|
Packit |
857059 |
# End of arguments list.
|
|
Packit |
857059 |
break;;
|
|
Packit |
857059 |
-h | --help )
|
|
Packit |
857059 |
USAGE; exit 0;;
|
|
Packit |
857059 |
* )
|
|
Packit |
857059 |
USAGE; exit 1;;
|
|
Packit |
857059 |
esac
|
|
Packit |
857059 |
done
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if ! [[ $numnodes =~ ^[0-9]+$ ]]; then
|
|
Packit |
857059 |
echo >&2 "\"$numnodes\" is not a valid # of nodes"
|
|
Packit |
857059 |
USAGE; exit 1
|
|
Packit |
857059 |
elif ! [[ $numcores =~ ^[0-9]+$ ]]; then
|
|
Packit |
857059 |
echo >&2 "\"$numcores\" is not a valid # of cores"
|
|
Packit |
857059 |
USAGE; exit 1
|
|
Packit |
857059 |
elif ! [[ $megsram =~ ^[0-9]+$ ]]; then
|
|
Packit |
857059 |
echo >&2 "\"$megsram\" is not a valid amount of RAM"
|
|
Packit |
857059 |
USAGE; exit 1
|
|
Packit |
857059 |
elif ! [[ $pressure =~ ^0\.[1-9][0-9]*$ ]]; then
|
|
Packit |
857059 |
echo >&2 "\"$pressure\" is not a valid amount memory pressure."
|
|
Packit |
857059 |
USAGE; exit 1
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
while [ $got_nodes -eq 0 -a $use_defaults -eq 0 ]
|
|
Packit |
857059 |
do
|
|
Packit |
857059 |
GET_INPUT "# of compute nodes" $default_numnodes
|
|
Packit |
857059 |
numnodes=$inputval
|
|
Packit |
857059 |
if [[ $numnodes =~ ^[0-9]+$ ]]; then
|
|
Packit |
857059 |
got_nodes=1
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
done
|
|
Packit |
857059 |
|
|
Packit |
857059 |
while [ $got_cores -eq 0 -a $use_defaults -eq 0 ]
|
|
Packit |
857059 |
do
|
|
Packit |
857059 |
GET_INPUT "# of cores per node" $default_numcores
|
|
Packit |
857059 |
numcores=$inputval
|
|
Packit |
857059 |
if [[ $numcores =~ ^[0-9]+$ ]]; then
|
|
Packit |
857059 |
got_cores=1
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
done
|
|
Packit |
857059 |
|
|
Packit |
857059 |
while [ $got_ram -eq 0 -a $use_defaults -eq 0 ]
|
|
Packit |
857059 |
do
|
|
Packit |
857059 |
GET_INPUT "# of RAM per node (in MB)" $default_megsram
|
|
Packit |
857059 |
megsram=$inputval
|
|
Packit |
857059 |
if [[ $megsram =~ ^[0-9]+$ ]]; then
|
|
Packit |
857059 |
got_ram=1
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
done
|
|
Packit |
857059 |
|
|
Packit |
857059 |
while [ $got_pressure -eq 0 -a $use_defaults -eq 0 ]
|
|
Packit |
857059 |
do
|
|
Packit |
857059 |
GET_INPUT "Memory pressure (range between 0.1 and 0.9)" $default_pressure
|
|
Packit |
857059 |
pressure=$inputval
|
|
Packit |
857059 |
if [[ $pressure =~ ^0\.[1-9][0-9]*$ ]]; then
|
|
Packit |
857059 |
got_pressure=1
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
done
|
|
Packit |
857059 |
|
|
Packit |
857059 |
totnumcores=$(( $numcores * $numnodes ))
|
|
Packit |
857059 |
|
|
Packit |
857059 |
HPL_PQ $totnumcores
|
|
Packit |
857059 |
|
|
Packit |
857059 |
CALC_NS $numnodes $megsram $pressure
|
|
Packit |
857059 |
|
|
Packit |
857059 |
echo
|
|
Packit |
857059 |
echo "Use \"./run_hpl2 $totnumcores\" to use this configuration."
|
|
Packit |
857059 |
echo
|
|
Packit |
857059 |
echo
|
|
Packit |
857059 |
|
|
Packit |
857059 |
DATFILE=$PWD/hpl-2.2/bin/$arch/HPL.dat
|
|
Packit |
857059 |
|
|
Packit |
857059 |
cat <
|
|
Packit |
857059 |
HPLinpack benchmark input file - $totnumcores processes, $pressure memory size
|
|
Packit |
857059 |
Generated by hpl_dat_gen.sh.
|
|
Packit |
857059 |
HPL.out output file name (if any)
|
|
Packit |
857059 |
6 device out (6=stdout,7=stderr,file)
|
|
Packit |
857059 |
1 # of problems sizes (N)
|
|
Packit |
857059 |
$Ns Ns
|
|
Packit |
857059 |
1 # of NBs
|
|
Packit |
857059 |
$NBs NBs
|
|
Packit |
857059 |
0 PMAP process mapping (0=Row-,1=Column-major)
|
|
Packit |
857059 |
1 # of process grids (P x Q)
|
|
Packit |
857059 |
$P Ps
|
|
Packit |
857059 |
$Q Qs
|
|
Packit |
857059 |
16.0 threshold
|
|
Packit |
857059 |
1 # of panel fact
|
|
Packit |
857059 |
1 PFACTs (0=left, 1=Crout, 2=Right)
|
|
Packit |
857059 |
1 # of recursive stopping criterium
|
|
Packit |
857059 |
4 NBMINs (>= 1)
|
|
Packit |
857059 |
1 # of panels in recursion
|
|
Packit |
857059 |
2 NDIVs
|
|
Packit |
857059 |
1 # of recursive panel fact.
|
|
Packit |
857059 |
2 RFACTs (0=left, 1=Crout, 2=Right)
|
|
Packit |
857059 |
1 # of broadcast
|
|
Packit |
857059 |
1 BCASTs (0=1rg,1=1rM,2=2rg,3=2rM,4=Lng,5=LnM)
|
|
Packit |
857059 |
1 # of lookahead depth
|
|
Packit |
857059 |
1 DEPTHs (>=0)
|
|
Packit |
857059 |
2 SWAP (0=bin-exch,1=long,2=mix)
|
|
Packit |
857059 |
$NBs swapping threshold
|
|
Packit |
857059 |
0 L1 in (0=transposed,1=no-transposed) form
|
|
Packit |
857059 |
0 U in (0=transposed,1=no-transposed) form
|
|
Packit |
857059 |
1 Equilibration (0=no,1=yes)
|
|
Packit |
857059 |
8 memory alignment in double (> 0)
|
|
Packit |
857059 |
EOF
|