|
| 1 | +#!/bin/bash |
| 2 | +################################################################ |
| 3 | +# Usage: ./script.sh <jobID> <scriptsHome> <extractedFilesBase> <timeStep> <aggType> |
| 4 | +# Example: ./script.sh 12345 /path/to/scripts /path/to/extracted 0 <aggType> |
| 5 | +################################################################ |
| 6 | + |
| 7 | +# Validate input parameters |
| 8 | +if [ $# -lt 5 ]; then |
| 9 | + echo "Usage: $0 <jobID> <scriptsHome> <extractedFilesBase> <timeStep> <aggType>" |
| 10 | + return 1 |
| 11 | +fi |
| 12 | + |
| 13 | +jobID="$1" |
| 14 | +scriptsHome="$2" |
| 15 | +timeStep="$4" |
| 16 | +extractedFilesLoc="$3/${timeStep}" |
| 17 | +# TLS EWS etc |
| 18 | +aggType=$5 |
| 19 | + |
| 20 | +key1="default" |
| 21 | +key2="flatten" |
| 22 | +key3="joined" |
| 23 | + |
| 24 | +if [ $# -ge 6 ]; then |
| 25 | + key1=$6 |
| 26 | +fi |
| 27 | + |
| 28 | +if [ $# -ge 7 ]; then |
| 29 | + key2=$7 |
| 30 | +fi |
| 31 | + |
| 32 | +if [ $# -ge 8 ]; then |
| 33 | + key3=$8 |
| 34 | +fi |
| 35 | + |
| 36 | +prefix12=${key1}_${key2} |
| 37 | +prefix23=${key2}_${key3} |
| 38 | +prefix13=${key1}_${key3} |
| 39 | + |
| 40 | +# Create directory structure |
| 41 | +mkdir -p "plots" || { echo "Error: Cannot create plots directory"; return 1; } |
| 42 | +mkdir -p "plots/${jobID}" || { echo "Error: Cannot create plots/${jobID}"; return 1; } |
| 43 | +mkdir -p "plots/${jobID}/${aggType}" || { echo "Error: Cannot create plots/${jobID}/${aggType}"; return 1; } |
| 44 | + |
| 45 | +currPlotDest="plots/${jobID}/${aggType}/${timeStep}" |
| 46 | +mkdir -p "${currPlotDest}" || { echo "Error: Cannot create ${currPlotDest}"; return 1; } |
| 47 | + |
| 48 | + |
| 49 | +detectContent() |
| 50 | +{ |
| 51 | + local key="$1" |
| 52 | + local count=$(find "${extractedFilesLoc}" -maxdepth 1 -type f -name "${key}*" | wc -l) |
| 53 | + |
| 54 | + if [ ${count} -gt 0 ]; then |
| 55 | + echo "${count} files has ${key}" |
| 56 | + true; return |
| 57 | + else |
| 58 | + false; return |
| 59 | + fi |
| 60 | + |
| 61 | +} |
| 62 | + |
| 63 | +compareTwo() |
| 64 | +{ |
| 65 | + local filePrefix=$1 |
| 66 | + local type1=$2 |
| 67 | + local type2=$3 |
| 68 | + |
| 69 | + #path1=($(ls ${extractedFilesLoc}/${type1}* )) |
| 70 | + #path2=($(ls ${extractedFilesLoc}/${type2}* )) |
| 71 | + |
| 72 | + #n=$((${#path1[@]}*${#path2[@]})) |
| 73 | + |
| 74 | + echo "python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=ES" |
| 75 | + python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=ES |
| 76 | + |
| 77 | + python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=ES_AWD |
| 78 | + python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=ES_AWD logScale=x |
| 79 | + python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=ES_aggregate_info levelAxis=True logScale=x |
| 80 | + |
| 81 | + python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=FixedMetaInfoGather logScale=xy |
| 82 | + python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=FixedMetaInfoGather logScale=y |
| 83 | + python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=FixedMetaInfoGather |
| 84 | + |
| 85 | + python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=MetaInfoBcast |
| 86 | + |
| 87 | + python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=PDW |
| 88 | + python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=PP logScale=x |
| 89 | + |
| 90 | + python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=transport_0.wbytes whichKind=MB |
| 91 | + |
| 92 | + if [[ $type1 == async* ]] ; then |
| 93 | + python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=BS_WaitOnAsync |
| 94 | + python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=DC_WaitOnAsync1 logScale=x |
| 95 | + python3 ${scriptsHome}/plotRanks.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} jsonAttr=DC_WaitOnAsync2 logScale=x |
| 96 | + fi |
| 97 | + |
| 98 | + echo "==> plot all the times spent on rank 0: python3 ${scriptsHome}/plotStack.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} whichRank=0 plotPrefix=${currPlotDest}/${filePrefix}" |
| 99 | + python3 ${scriptsHome}/plotStack.py ${type1} ${type2} --set dataDir=${extractedFilesLoc} whichRank=0 plotPrefix=${currPlotDest}/${filePrefix} |
| 100 | + |
| 101 | + #fi |
| 102 | +} |
| 103 | + |
| 104 | + |
| 105 | +compareThree() |
| 106 | +{ |
| 107 | + local filePrefix=$1 |
| 108 | + local type1=$2 |
| 109 | + local type2=$3 |
| 110 | + local type3=$4 |
| 111 | + |
| 112 | + echo "==> plot all the times spent on rank 0" |
| 113 | + python3 ${scriptsHome}/plotStack.py ${type1} ${type2} ${type3} --set dataDir=${extractedFilesLoc} whichRank=0 plotPrefix=${currPlotDest}/${filePrefix} |
| 114 | + |
| 115 | + echo "==> plot numCalls occurred" |
| 116 | + echo "${scriptsHome}/plotCall.py ${type1} ${type2} ${type3} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix}" |
| 117 | + python3 ${scriptsHome}/plotCall.py ${type1} ${type2} ${type3} --set dataDir=${extractedFilesLoc} plotPrefix=${currPlotDest}/${filePrefix} |
| 118 | +} |
| 119 | + |
| 120 | +checkPossibilities() |
| 121 | +{ |
| 122 | + local prefix=$1 |
| 123 | + local typeA=${prefix}${key1} |
| 124 | + local typeB=${prefix}${key2} |
| 125 | + local typeC=${prefix}${key3} |
| 126 | + |
| 127 | + |
| 128 | + |
| 129 | + local trueCounter=0; |
| 130 | + |
| 131 | + has_key1=false |
| 132 | + has_key2=false |
| 133 | + has_key3=false |
| 134 | + |
| 135 | + if detectContent $typeA; then |
| 136 | + has_key1=true |
| 137 | + trueCounter=$((trueCounter + 1)) |
| 138 | + fi |
| 139 | + |
| 140 | + if detectContent $typeB; then |
| 141 | + has_key2=true |
| 142 | + trueCounter=$((trueCounter + 1)) |
| 143 | + fi |
| 144 | + if detectContent $typeC; then |
| 145 | + has_key3=true |
| 146 | + trueCounter=$((trueCounter + 1)) |
| 147 | + fi |
| 148 | + |
| 149 | + echo "$prefix counter = $trueCounter, $has_key1 $has_key3 $has_key2" |
| 150 | + if [[ trueCounter -ge 2 ]]; then |
| 151 | + if ($has_key1 && $has_key3); then |
| 152 | + compareTwo $prefix13 $typeA $typeC |
| 153 | + fi |
| 154 | + if ($has_key1 && $has_key2); then |
| 155 | + compareTwo $prefix12 $typeA $typeB |
| 156 | + fi |
| 157 | + if ($has_key3 && $has_key2); then |
| 158 | + compareTwo $prefix23 $typeC $typeB |
| 159 | + fi |
| 160 | + fi |
| 161 | + |
| 162 | + if [[ trueCounter -eq 3 ]]; then |
| 163 | + compareThree djf $typeA $typeC $typeB |
| 164 | + fi |
| 165 | + |
| 166 | + if [[ trueCounter -eq 1 ]]; then |
| 167 | + validType=$typeA |
| 168 | + if ${has_key3}; then |
| 169 | + validType=$typeC |
| 170 | + elif ${has_key2}; then |
| 171 | + validType=$typeB |
| 172 | + fi |
| 173 | + compareTwo ${validType} ${validType} ## first input is file prefix |
| 174 | + fi |
| 175 | +} |
| 176 | + |
| 177 | + |
| 178 | +checkPossibilities "" |
| 179 | +checkPossibilities "async" |
| 180 | + |
| 181 | + |
| 182 | + |
| 183 | + |
0 commit comments