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

set ver = "dec"
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..."
cc -c -D__alpha_osf -non_shared -pthread -fast test-threads.c
cc -o tt.${ver} test-threads.o   -lm -lpthread -lexc

echo "running..."

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

/bin/uname -a >> ${out}
/usr/sbin/psrinfo -v >> ${out}
/bin/date >> ${out}

set mb = 70
# set mb = 120
# set mb = 1000
# set mb = 6000

set mops = 300

set npr = 2
# set npr = 10
# set npr = 48

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

# Compaq's "ulimit" crock
# set mbx = 850
# echo "=== soft limits before ===" >> ${out}
# limit  >> ${out}
# limit datasize ${mbx}m >> ${out}
# limit addressspace ${mbx}m >> ${out}
# limit stacksize 32m >> ${out}
echo "=== soft limits ===" >> ${out}
limit  >> ${out}
echo "=== hard limits ===" >> ${out}
limit -h >> ${out}

vmstat -s >> ${out}
if ( -x /usr/bin/top ) top -b -d 1 >> ${out}

echo "trying up to ${npr} threads" >> ${out}

foreach nth ( 48 32 24 16 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."

