#!/bin/csh
# Usage: MEM.csh <outfile_from_cache>

echo 'Arch: ' $1
rm -f $1.m

echo "stride = [" >> $1.m
awk '/Array 4194304/{print $4}' $1 >> $1.m
echo "];" >> $1.m

echo "k4 = [" >> $1.m
awk '/Array 4096/{print $6}' $1 >> $1.m
echo "];" >> $1.m

echo "k8 = [" >> $1.m
awk '/Array 8192/{print $6}' $1 >> $1.m
echo "];" >> $1.m

echo "k16 = [" >> $1.m
awk '/Array 16384/{print $6}' $1 >> $1.m
echo "];" >> $1.m

echo "k32 = [" >> $1.m
awk '/Array 32768/{print $6}' $1 >> $1.m
echo "];" >> $1.m

echo "k64 = [" >> $1.m
awk '/Array 65536/{print $6}' $1 >> $1.m
echo "];" >> $1.m

echo "k128 = [" >> $1.m
awk '/Array 131072/{print $6}' $1 >> $1.m
echo "];" >> $1.m

echo "k256 = [" >> $1.m
awk '/Array 262144/{print $6}' $1 >> $1.m
echo "];" >> $1.m

echo "k512 = [" >> $1.m
awk '/Array 524288/{print $6}' $1 >> $1.m
echo "];" >> $1.m

echo "m1 = [" >> $1.m
awk '/Array 1048576/{print $6}' $1 >> $1.m
echo "];" >> $1.m

echo "m2 = [" >> $1.m
awk '/Array 2097152/{print $6}' $1 >> $1.m
echo "];" >> $1.m

echo "m4 = [" >> $1.m
awk '/Array 4194304/{print $6}' $1 >> $1.m
echo "];" >> $1.m

echo "MemPlot;" >> $1.m

