#!/bin/bash # # Usage: # process_plot_threadpool_MPI nprocess [time-range-ms] # # Description: # Process all the threadpool info files in the current directory # creating function graphs for steps and threads. MPI version # # The input files are created by a run using the "-Y interval" flag and # should be named "threadpool_info-rank-step.dat" in the current # directory. All located files will be processed using "nprocess" concurrent # processes and all plots will have the same time range if one is given. # An output HTML file "index.html" will be created to view all the plots. # # # This file is part of SWIFT: # # Copyright (C) 2022 Peter W. Draper (p.w.draper@durham.ac.uk) # All Rights Reserved. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser 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 Lesser General Public License # along with this program. If not, see . # Handle command-line if test "$1" = ""; then echo "Usage: $0 nprocess [time-range-ms]" exit 1 fi NPROCS=$1 TIMERANGE=0 LIMIT="(autoranged)" if test "$2" != ""; then TIMERANGE=$2 LIMIT="" fi # Locate script. SCRIPTHOME=$(dirname "$0") # Find all thread info files. Use sort to get into correct order, step then rank. files=$(ls -1 threadpool_info-rank*-step*.dat| sort -t- -k3,3) if test $? != 0; then echo "Failed to find any threadpool info files" exit 1 fi # Construct list of names, the step no and names for the graphics. list="" for f in $files; do r=$(echo $f| sed 's,threadpool_info-rank\(.*\)-step.*.dat,\1,') s=$(echo $f| sed 's,threadpool_info-rank.*-step\(.*\).dat,\1,') list="$list $f $s $r threadpool-step${s}-rank${r}" done # And process them, echo "Processing threadpool info files..." echo $list | xargs -P $NPROCS -n 4 /bin/bash -c "${SCRIPTHOME}/plot_threadpool.py --expand 1 --limit $TIMERANGE --width 16 --height 4 \$0 \$3 " echo $list | xargs -P $NPROCS -n 4 /bin/bash -c "${SCRIPTHOME}/analyse_threadpool_tasks.py \$0 --html > \$3.stats" echo "Writing output threadpool-index.html file" # Construct document - serial. cat < threadpool-index.html SWIFT threadpool tasks $LIMIT

SWIFT threadpool tasks $LIMIT

EOF echo $list | xargs -n 4 | while read f s r g; do cat <> threadpool-index.html

Step $s Rank $r

EOF cat <> threadpool-index.html EOF cat < threadpool-step${s}-rank${r}.html


EOF
cat threadpool-step${s}-rank${r}.stats >> threadpool-step${s}-rank${r}.html
cat <> threadpool-step${s}-rank${r}.html
EOF done cat <> threadpool-index.html EOF echo "Finished" exit