Add tiny test
[ctsim.git] / tests / test-single-openmp.sh
1 #/bin/bash
2
3 TEST=small
4 if test $# -ge 1; then
5     TEST=$1
6 fi
7
8 if test "x$TEST" = "xtiny"; then
9     PR=19;  PV=14;  IX=11;  IY=$IX
10     NSAMPLE=2
11 elif test "x$TEST" = "xsmall"; then
12     PR=165;  PV=144;  IX=115;  IY=$IX
13     NSAMPLE=2
14 elif test "x$TEST" = "xmedium"; then
15     PR=901;  PV=600;  IX=500;  IY=$IX
16     NSAMPLE=4
17 elif test "x$TEST" = "xlarge"; then
18     PR=1651;  PV=1440;  IX=1151;  IY=$IX
19     NSAMPLE=5
20 else
21     echo "usage: $0 <test-size>"
22     echo "test-size   -- tiny, small, medium, or large"
23     exit
24 fi
25 TIME=
26
27 DIR=/tmp
28 BIN_SNG=$DIR/sng/ctsimtext
29 BIN_OMP=$DIR/omp/ctsimtext
30
31 RUNTIME_REGEX="sed -r 's/^[^0-9]* ([0-9\.]+)[ a-z]*/\1/'"
32 for PHAN in herman; do
33     phmbase=${DIR}/${PHAN}-${TEST}
34     rm -rf ${phmbase}-*
35
36     ts=`sh -c "$BIN_SNG phm2if ${phmbase}-sng.if $IX $IY --phantom $PHAN --nsample $NSAMPLE --verbose | tail -1 | $RUNTIME_REGEX"`
37     tm=`sh -c "$BIN_OMP phm2if ${phmbase}-omp.if $IX $IY --phantom $PHAN --nsample $NSAMPLE --verbose | tail -1 | $RUNTIME_REGEX"`
38     ratio=`bc <<< "scale=2; $ts / $tm"`
39     diff=`$BIN_SNG if2 ${phmbase}-omp.if ${phmbase}-sng.if --comp`
40     echo "Phantom,$PHAN,$tm,$ts,$ratio,\"$diff\""
41
42     for GEOM in equilinear equiangular parallel; do
43         ifbase=${phmbase}-${GEOM}
44         ts=`sh -c "$BIN_SNG phm2pj ${ifbase}-sng.pj $PR $PV --phantom $PHAN --verbose | tail -1 | $RUNTIME_REGEX"`
45         tm=`sh -c "$BIN_OMP phm2pj ${ifbase}-omp.pj $PR $PV --phantom $PHAN --verbose | tail -1 | $RUNTIME_REGEX"`
46         ratio=`bc <<< "scale=2; $ts / $tm"`
47         echo "Projection,$PHAN,$GEOM,$tm,$ts,$ratio"
48
49         for BP in idiff diff; do
50 #        for BP in idiff diff table trig; do
51             for INT in nearest linear cubic; do
52                 recbase=${ifbase}-${BP}-${INT}
53                 ts=`sh -c "$BIN_SNG pjrec ${ifbase}-sng.pj $recbase-sng.if $IX $IY --verbose --interp $INT --backproj $BP | tail -1 | $RUNTIME_REGEX"`
54                 tm=`sh -c "$BIN_OMP pjrec ${ifbase}-omp.pj $recbase-omp.if $IX $IY --verbose --interp $INT --backproj $BP | tail -1 | $RUNTIME_REGEX"`
55                 ratio=`bc <<< "scale=2; $ts / $tm"`
56                 diff=`$BIN_SNG if2 $recbase-omp.if $recbase-sng.if --comp`
57                 echo "Reconstruction,$PHAN,$GEOM,$BP,$INT,$tm,$ts,$ratio,\"$diff\""
58             done
59         done
60     done
61 done