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