203 lines
4.6 KiB
Bash
Executable File
203 lines
4.6 KiB
Bash
Executable File
#!/bin/zsh
|
|
#
|
|
# Copyright (C) 2011 Thomas Preud'homme <thomas.preud-homme@lip6.fr>
|
|
#
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
# in the Software without restriction, including without limitation the rights
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
# furnished to do so, subject to the following conditions:
|
|
#
|
|
# The above copyright notice and this permission notice shall be included in
|
|
# all copies or substantial portions of the Software.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
# SOFTWARE.
|
|
|
|
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
|
|
{
|
|
grep "^GOMP_\(stream\|batchQ\)_connect_view" | cut -d ' ' -f '2-' | while read stream thread view direction task
|
|
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
|
|
|
|
grep "^GOMP_\(stream\|batchQ\)_update \[out]" | cut -d ' ' -f '3-' | while read stream burstSize upStart upEnd
|
|
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
|
|
|
|
grep "^GOMP_\(stream\|batchQ\)_stall \[out]" | cut -d ' ' -f '3-' | while read stream burstSize stStart stEnd
|
|
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
|