2011-08-05 15:57:55 +02:00
|
|
|
#!/bin/zsh
|
|
|
|
|
|
|
|
if [ $# -gt 2 ]
|
|
|
|
then
|
|
|
|
echo "Usage: ${0##*/} action [file]"
|
|
|
|
echo "Possible actions: structures|updates|stalls"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Initialization
|
|
|
|
if [ $# -eq 2 ]
|
|
|
|
then
|
|
|
|
exec < $2
|
|
|
|
fi
|
|
|
|
|
|
|
|
action=$1
|
|
|
|
|
|
|
|
|
|
|
|
function fill_hashtables
|
|
|
|
{
|
2011-11-02 19:32:56 +01:00
|
|
|
grep "^GOMP_\(stream\|batchQ\)_connect_view" | cut -d ' ' -f '2-' | while read stream thread view direction task
|
2011-08-05 15:57:55 +02:00
|
|
|
do
|
|
|
|
if (( 1 - ${+threads[$thread]} ))
|
|
|
|
then
|
|
|
|
threadId+=1
|
|
|
|
threads[$thread]=$threadId
|
|
|
|
fi
|
|
|
|
#if (( 1 - ${+views[$view]} ))
|
|
|
|
#then
|
|
|
|
# viewId+=1
|
|
|
|
# views[$view]=$viewId
|
|
|
|
#fi
|
|
|
|
if (( 1 - ${+tasks[$task]} ))
|
|
|
|
then
|
|
|
|
taskId+=1
|
|
|
|
tasks[$task]=$taskId
|
|
|
|
fi
|
|
|
|
if (( 1 - ${+streams[$stream]} ))
|
|
|
|
then
|
|
|
|
streamId+=1
|
|
|
|
streams[$stream]=$streamId
|
|
|
|
fi
|
|
|
|
if (( ${+taskViews[$task]} ))
|
|
|
|
then
|
|
|
|
taskViews[$task]="$taskViews[$task], s$streams[$stream] ($direction)"
|
|
|
|
else
|
|
|
|
taskViews[$task]="s$streams[$stream] ($direction)"
|
|
|
|
fi
|
|
|
|
if [[ $direction == "In" ]]
|
|
|
|
then
|
|
|
|
if (( ${+streamsInputs[$stream]} ))
|
|
|
|
then
|
|
|
|
streamsInputs[$stream]="$streamsInputs[$stream],t$threads[$thread]"
|
|
|
|
else
|
|
|
|
streamsInputs[$stream]="t$threads[$thread]"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if (( ${+streamsOutputs[$stream]} ))
|
|
|
|
then
|
|
|
|
streamsOutputs[$stream]="$streamsOutputs[$stream],t$threads[$thread]"
|
|
|
|
else
|
|
|
|
streamsOutputs[$stream]="t$threads[$thread]"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function display_streams_structure
|
|
|
|
{
|
|
|
|
for stream in ${(k)streams}
|
|
|
|
do
|
|
|
|
echo "$streamsInputs[$stream] --s$streams[$stream]--> $streamsOutputs[$stream]"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function display_id_matchings
|
|
|
|
{
|
|
|
|
{ for stream in ${(k)streams}
|
|
|
|
do
|
|
|
|
echo "$streams[$stream]: $stream"
|
|
|
|
done } | sort -n | sed "s/^/s/"
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
{ for thread in ${(k)threads}
|
|
|
|
do
|
|
|
|
echo "$threads[$thread]: $thread"
|
|
|
|
done } | sort -n | sed "s/^/t/"
|
|
|
|
}
|
|
|
|
|
|
|
|
function display_task_views
|
|
|
|
{
|
|
|
|
for task in ${(k)tasks}
|
|
|
|
do
|
|
|
|
echo "T$tasks[$task]: $taskViews[$task]"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function streams_structure
|
|
|
|
{
|
|
|
|
integer streamId=0
|
|
|
|
integer threadId=0
|
|
|
|
#integer viewId=0
|
|
|
|
integer taskId=0
|
|
|
|
typeset -A streams
|
|
|
|
typeset -A streamsInputs
|
|
|
|
typeset -A streamsOutputs
|
|
|
|
typeset -A threads
|
|
|
|
#typeset -A views
|
|
|
|
typeset -A tasks
|
|
|
|
typeset -A taskViews
|
|
|
|
|
|
|
|
fill_hashtables
|
|
|
|
display_streams_structure
|
|
|
|
echo
|
|
|
|
display_id_matchings
|
|
|
|
echo
|
|
|
|
display_task_views
|
|
|
|
}
|
|
|
|
|
|
|
|
function updates_infos
|
|
|
|
{
|
|
|
|
typeset -A streams
|
|
|
|
|
2011-11-02 19:32:56 +01:00
|
|
|
grep "^GOMP_\(stream\|batchQ\)_update \[out]" | cut -d ' ' -f '3-' | while read stream burstSize upStart upEnd
|
2011-08-05 15:57:55 +02:00
|
|
|
do
|
|
|
|
curVal=$(( (upEnd - upStart) * burstSize ))
|
|
|
|
if (( ${+streams[$stream]} ))
|
|
|
|
then
|
|
|
|
last=${streams[$stream]##* }
|
|
|
|
lastVal=${last%\(*}
|
|
|
|
lastValCount=${last#*\(}
|
|
|
|
lastValCount=${lastValCount%\)}
|
|
|
|
#echo "curVal: $curVal"
|
|
|
|
#echo "last: $last"
|
|
|
|
#echo "lastVal: $lastVal"
|
|
|
|
#echo "lastValCount: $lastValCount"
|
|
|
|
if [[ $curVal -eq $lastVal ]]
|
|
|
|
then
|
|
|
|
streams[$stream]="${streams[$stream]%\(*}($((lastValCount+1)))"
|
|
|
|
else
|
|
|
|
streams[$stream]="$streams[$stream] $curVal(1)"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
streams[$stream]="$curVal(1)"
|
|
|
|
#echo "streams[$stream]: $streams[$stream]"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for stream in ${(k)streams}
|
|
|
|
do
|
|
|
|
echo "$stream: $streams[$stream]"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function stalls_infos
|
|
|
|
{
|
|
|
|
typeset -A streams
|
|
|
|
|
2011-11-02 19:32:56 +01:00
|
|
|
grep "^GOMP_\(stream\|batchQ\)_stall \[out]" | cut -d ' ' -f '3-' | while read stream burstSize stStart stEnd
|
2011-08-05 15:57:55 +02:00
|
|
|
do
|
|
|
|
if (( ${+streams[$stream]} ))
|
|
|
|
then
|
|
|
|
streams[$stream]="$streams[$stream] $(( (stEnd - stStart) * burstSize ))"
|
|
|
|
else
|
|
|
|
streams[$stream]=$(( (stEnd - stStart) * burstSize ))
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for stream in ${(k)streams}
|
|
|
|
do
|
|
|
|
echo "$stream: $streams[$stream]"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
case $action in
|
|
|
|
"structures") streams_structure ;;
|
|
|
|
"updates") updates_infos ;;
|
|
|
|
"stalls") stalls_infos ;;
|
|
|
|
*) echo "Unsupported action: $action" ; exit 1;;
|
|
|
|
esac
|