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

set ver = "sun"
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 -v -B static -Xt -fast test-threads.c
cc -o tt.${ver} test-threads.o -lm -lpthread

echo "running..."

echo "thread test for Sun-SPARC/Solaris" > ${out}

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

# set mb = 20
# set mb = 70
# set mb = 200
set mb = 3000
# set mb = 6000

set mops = 300

# set npr = 1
# set npr = 8
set npr = 4
# set npr = 48

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

/usr/local/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."


