#! /bin/csh -f
# Last edited on 2011-06-06 21:27:35 by stolfi

set ver = "dlx"
set mach = "`/bin/uname -n | sed -e 's/[.].*//'`"
set out = "out/${ver}.${mach}"
echo "writing to ${out}"
if ( -r ${out} ) mv ${out} ${out}~~

echo "compiling program..."
/usr/bin/gcc -c -funsigned-char -D__alpha_linux -Wall -static -O2 test-threads.c
/usr/bin/gcc -o tt.${ver} test-threads.o  -lm -lpthread

echo "running..."

echo "thread test for DEC-Alpha/Linux" >> ${out}

/bin/uname -a >> ${out}
/bin/cat /proc/cpuinfo >> ${out}
( printf "gcc version: "; /usr/bin/gcc --version ) >> ${out}
/bin/date >> ${out}

set mb = 70
# set mb = 3000
# set mb = 6000
# set mb = 1800

set mops = 300

set npr = 2
# set npr = 48

echo "${npr} max threads, ${mb}MB array, ${mops} Mops"
echo "${npr} max threads, ${mb}MB array, ${mops} Mops" >> ${out}

/usr/bin/top -b -n 1 -S >>& ${out}

foreach nth ( 48 32 24 16 12 10 8 4 2 1 )
  if ( $nth <= ${npr} ) then
    echo "${nth} threads..."
    tt.${ver}   6700 ${mb} ${mops} 0 ${nth} >>& ${out}
    tt.${ver} 160000 ${mb} ${mops} 0 ${nth} >>& ${out}
    tt.${ver}   6700 ${mb} ${mops} 1 ${nth} >>& ${out}
    tt.${ver} 160000 ${mb} ${mops} 1 ${nth} >>& ${out}
  endif
end

/bin/date >> ${out}

echo "formatting main data..."

set fmt = "fmt/${ver}.${mach}"
if ( -r ${fmt} ) mv ${fmt} ${fmt}~~
cat ${out} | format-results > ${fmt}

echo "done."

