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

set ver = "ilx"
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..."
gcc -c -funsigned-char -D__intel_linux -Wall -static -O2 test-threads.c
gcc -o tt.${ver} test-threads.o   -lm -lpthread

echo "running..."

echo "thread test for Intel/Linux" > ${out}

/bin/uname -a >> ${out}
/bin/cat /proc/cpuinfo >> ${out}
/usr/bin/top -b -n 1 -S >>& ${out}
/bin/date >> ${out}

set mb = 70
# set mb = 500
# set mb = 6000

set mops = 300

set npr = 2
# set npr = 48

echo "trying up to ${npr} threads"

foreach nth ( 1 2 4 8 10 16 20 24 32 48 )
  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."

