File indexing completed on 2026-04-09 07:49:22
0001
0002 usage(){ cat << EOU
0003 storch_test.sh
0004 ================
0005
0006 CPU test of CUDA code to generate torch photons using srngcpu.h::
0007
0008 ~/opticks/sysrap/tests/storch_test.sh
0009
0010 HMM : unless can get the implementation to work header only its
0011 kinda pointless not including storch_test in the CMake built
0012 ones as normally need to rebuild sysrap anyhow.
0013
0014 EOU
0015 }
0016 cd $(dirname $(realpath $BASH_SOURCE))
0017
0018 case $(uname) in
0019 Darwin) defarg=build_env_run_ana ;;
0020 Linux) defarg=build_env_run ;;
0021 esac
0022 arg=${1:-$defarg}
0023
0024
0025 TMP=${TMP:-/tmp/$USER/opticks}
0026
0027
0028 msg="=== $BASH_SOURCE :"
0029 name=storch_test
0030 bdir=$TMP/$name.build
0031 mkdir -p $bdir
0032 bin=$bdir/$name
0033
0034 script=$name.py
0035
0036
0037
0038
0039 vers=sphere__hemi
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 fold=$TMP/$name
0053 export FOLD=$fold
0054 mkdir -p $FOLD
0055
0056
0057 vars="BASH_SOURCE name bdir bin script FOLD vers"
0058
0059 if [ "${arg/info}" != "$arg" ]; then
0060 for var in $vars ; do printf "%20s : %s \n" "$var" "${!var}" ; done
0061 fi
0062
0063 if [ "$vers" == "up" ]; then
0064
0065 export storch_FillGenstep_pos=0,0,-990
0066 export storch_FillGenstep_mom=0,0,1
0067 export storch_FillGenstep_radius=49
0068
0069 elif [ "$vers" == "up99" -o "$vers" == "M1up99" ]; then
0070
0071 export storch_FillGenstep_pos=0,0,-99
0072 export storch_FillGenstep_mom=0,0,1
0073 export storch_FillGenstep_radius=49
0074
0075 elif [ "$vers" == "down" ]; then
0076
0077 export storch_FillGenstep_pos=0,0,990
0078 export storch_FillGenstep_mom=0,0,-1
0079 export storch_FillGenstep_radius=49
0080
0081 elif [ "$vers" == "circle_outwards" ]; then
0082
0083 export storch_FillGenstep_type=circle
0084 export storch_FillGenstep_radius=1
0085 export storch_FillGenstep_pos=0,0,0
0086 export storch_FillGenstep_azimuth=0,1
0087
0088 elif [ "$vers" == "circle_inwards" ]; then
0089
0090 export storch_FillGenstep_type=circle
0091 export storch_FillGenstep_radius=-100
0092 export storch_FillGenstep_pos=0,0,0
0093 export storch_FillGenstep_azimuth=0,1
0094
0095 elif [ "$vers" == "circle_inwards_hemi" ]; then
0096
0097 export storch_FillGenstep_type=circle
0098 export storch_FillGenstep_radius=-100
0099 export storch_FillGenstep_pos=0,0,50
0100
0101 export storch_FillGenstep_azimuth=0.5,1
0102
0103 elif [ "$vers" == "sphere" -o "$vers" == "sphere_marsaglia" ]; then
0104
0105 export storch_FillGenstep_type=$vers
0106 export storch_FillGenstep_radius=100
0107 export storch_FillGenstep_pos=0,0,0
0108 export storch_FillGenstep_distance=1.00
0109
0110 elif [ "$vers" == "sphere__restricted" -o "$vers" == "sphere_marsaglia__restricted" ]; then
0111
0112 export storch_FillGenstep_type=${vers/__*}
0113 export storch_FillGenstep_radius=100
0114 export storch_FillGenstep_pos=0,0,0
0115 export storch_FillGenstep_zenith=0.25,0.75
0116 export storch_FillGenstep_azimuth=0.25,0.75
0117 export storch_FillGenstep_distance=0.25
0118
0119 elif [ "$vers" == "sphere__hemi" ]; then
0120
0121 export storch_FillGenstep_type=sphere
0122 export storch_FillGenstep_radius=-50
0123 export storch_FillGenstep_pos=0,0,0
0124 export storch_FillGenstep_zenith=0,1
0125 export storch_FillGenstep_azimuth=0.25,0.75
0126 export storch_FillGenstep_distance=0.25
0127
0128 fi
0129
0130
0131
0132 K1=1000
0133 K10=10000
0134 K100=100000
0135 M1=1000000
0136
0137 case ${vers:-dummy} in
0138 circle*) num=100 ;;
0139 K100*) num=$K100 ;;
0140 K10*) num=$K10 ;;
0141 K1*) num=$K1 ;;
0142 M1*) num=$M1 ;;
0143 *) num=$K10 ;;
0144 esac
0145 export SEvent_MakeGenstep_num_ph=$num
0146 export SEvent_MakeGenstep_dump=1
0147
0148
0149 cuda_prefix=/usr/local/cuda
0150 CUDA_PREFIX=${CUDA_PREFIX:-$cuda_prefix}
0151
0152
0153 if [ "${arg/build}" != "$arg" ]; then
0154
0155 case $(uname) in
0156 Darwin) libline="-L$OPTICKS_PREFIX/lib" ;;
0157 Linux) libline="-L$OPTICKS_PREFIX/lib64 -lm -lssl -lcrypto" ;;
0158 esac
0159
0160
0161
0162 gcc $name.cc \
0163 -o $bin \
0164 -std=c++11 -lstdc++ -g -lm \
0165 -DMOCK_CURAND \
0166 -I.. \
0167 -I$CUDA_PREFIX/include \
0168 -I$OPTICKS_PREFIX/externals/glm/glm \
0169 -I$OPTICKS_PREFIX/externals/plog/include \
0170 $libline \
0171 -lSysRap
0172
0173 [ $? -ne 0 ] && echo $msg build error && exit 1
0174 fi
0175
0176
0177 if [ "${arg/env}" != "$arg" ]; then
0178 env | grep storch_FillGenstep
0179 fi
0180
0181 if [ "${arg/run}" != "$arg" ]; then
0182 $bin
0183 [ $? -ne 0 ] && echo $msg run error && exit 2
0184 fi
0185
0186 if [ "${arg/pdb}" != "$arg" ]; then
0187 ${IPYTHON:-ipython} --pdb -i $script
0188 [ $? -ne 0 ] && echo $msg pdb error && exit 3
0189 fi
0190
0191 if [ "${arg/ana}" != "$arg" ]; then
0192 ${PYTHON:-python} $script
0193 [ $? -ne 0 ] && echo $msg ana error && exit 4
0194 fi
0195
0196
0197
0198 if [ "${arg/grab}" != "$arg" ]; then
0199 echo $msg odir $odir
0200
0201 xdir=$odir/
0202 from=P:$xdir
0203 to=$xdir
0204
0205 vars="xdir from to"
0206 dumpvars(){ for var in $vars ; do printf "%-30s : %s \n" $var "${!var}" ; done ; }
0207 dumpvars
0208 read -p "$msg Enter YES to proceed with rsync between from and to " ans
0209 if [ "$ans" == "YES" ]; then
0210 echo $msg proceeding
0211 mkdir -p $to
0212 rsync -zarv --progress --include="*/" --include="*.txt" --include="*.npy" --include="*.jpg" --include="*.mp4" --include "*.json" --exclude="*" "$from" "$to"
0213 tto=${to%/}
0214 find $tto -name '*.json' -o -name '*.txt' -print0 | xargs -0 ls -1rt
0215 echo ls.1 tto $tto jpg mp4 npy
0216 find $tto -name '*.jpg' -o -name '*.mp4' -o -name '*.npy' -print0 | xargs -0 ls -1rt
0217 else
0218 echo $msg skipping
0219 fi
0220 fi
0221
0222 if [ "${arg/ls}" != "$arg" ]; then
0223 tto=$odir
0224 find $tto -name '*.json' -o -name '*.txt' -print0 | xargs -0 ls -1rt
0225 find $tto -name '*.jpg' -o -name '*.mp4' -o -name '*.npy' -print0 | xargs -0 ls -1rt
0226 fi
0227
0228
0229 exit 0
0230
0231