File indexing completed on 2026-04-09 07:49:17
0001
0002 usage(){ cat << EOU
0003 SGenerate__test.sh
0004 ====================
0005
0006 CPU test of CUDA code to generate torch photons using srngcpu.h::
0007
0008 lo
0009
0010 ~/o/sysrap/tests/SGenerate__test.sh info_build_run_ls
0011
0012 MODE=3 ~/o/sysrap/tests/SGenerate__test.sh pdb
0013
0014
0015 EOU
0016 }
0017
0018 cd $(dirname $(realpath $BASH_SOURCE))
0019
0020 name=SGenerate__test
0021
0022 cuda_prefix=/usr/local/cuda
0023 CUDA_PREFIX=${CUDA_PREFIX:-$cuda_prefix}
0024
0025 tmp=/tmp/$USER/opticks
0026 export TMP=${TMP:-$tmp}
0027 export FOLD=$TMP/$name
0028 mkdir -p $FOLD
0029
0030 bin=$FOLD/$name
0031 script=$name.py
0032
0033 defarg=info_build_run_ls_ana
0034 arg=${1:-$defarg}
0035
0036 unset SGenerate__GeneratePhotons_RNG_PRECOOKED
0037
0038
0039 vv="BASH_SOURCE U4TDIR CUDA_PREFIX OPTICKS_PREFIX FOLD bin script SGenerate__test_GS_NAME SGenerate__test_PH_NAME"
0040
0041
0042 src=disc
0043
0044 if [ "$src" == "sphere" ]; then
0045 export storch_FillGenstep_type=sphere
0046 export storch_FillGenstep_radius=100
0047 export storch_FillGenstep_pos=0,0,0
0048 export storch_FillGenstep_distance=1.00
0049
0050 elif [ "$src" == "disc" ]; then
0051
0052 export storch_FillGenstep_type=disc
0053 export storch_FillGenstep_radius=399
0054 export storch_FillGenstep_zenith=0,1
0055 export storch_FillGenstep_azimuth=0,1
0056 export storch_FillGenstep_mom=0,0,1
0057 export storch_FillGenstep_pos=0,0,$(( -1963 - 500 ))
0058
0059 fi
0060
0061 pfx=SGenerate
0062 export SEvent__MakeGenstep_num_ph=M1
0063
0064 export SGenerate__test_GS_NAME=${pfx}_gs_${src}_${SEvent__MakeGenstep_num_ph}.npy
0065 export SGenerate__test_PH_NAME=${pfx}_ph_${src}_${SEvent__MakeGenstep_num_ph}.npy
0066
0067
0068 env | grep storch
0069
0070 if [ "$storch_FillGenstep_type" == "" ]; then
0071 echo $BASH_SOURCE : FATAL : for CHECK $CHECK LAYOUT $LAYOUT GEOM $GEOM
0072 exit 1
0073 fi
0074
0075 if [ "${arg/info}" != "$arg" ]; then
0076 for v in $vv ; do printf "%30s : %s \n" "$v" "${!v}" ; done
0077 fi
0078
0079 if [ "${arg/build}" != "$arg" ]; then
0080
0081 opt=-DNOT_MOCK_CURAND
0082
0083 gcc $name.cc -std=c++11 -lstdc++ -lm -g \
0084 $opt \
0085 -I.. \
0086 -I$CUDA_PREFIX/include \
0087 -I$OPTICKS_PREFIX/externals/glm/glm \
0088 -I$OPTICKS_PREFIX/externals/plog/include \
0089 -L$OPTICKS_PREFIX/lib64 \
0090 -lSysRap \
0091 -o $bin
0092
0093 [ $? -ne 0 ] && echo $msg build error && exit 1
0094 fi
0095
0096 if [ "${arg/run}" != "$arg" ]; then
0097 $bin
0098 [ $? -ne 0 ] && echo $msg run error && exit 2
0099 fi
0100
0101 if [ "${arg/ls}" != "$arg" ]; then
0102 echo ls -alst $FOLD
0103 ls -alst $FOLD
0104 fi
0105
0106 if [ "${arg/pdb}" != "$arg" ]; then
0107 ${IPYTHON:-ipython} --pdb -i $script
0108 [ $? -ne 0 ] && echo $msg pdb error && exit 3
0109 fi
0110
0111 if [ "${arg/ana}" != "$arg" ]; then
0112 ${PYTHON:-python} $script
0113 [ $? -ne 0 ] && echo $msg ana error && exit 4
0114 fi
0115
0116 exit 0
0117