Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions CSG/csg_classify.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,7 @@ enum {
CTRL_RETURN_FLIP_B = 3,
CTRL_LOOP_A = 4,
CTRL_LOOP_B = 5
};


/*
// moved to common action enum sflow.h
// typedef enum {
// UNDEFINED=0,
// CONTINUE=1,
// BREAK=2
// } Action_t ;
*/
};

#if defined(DEBUG) || defined(DEBUG_RECORD)
static const char* CTRL_RETURN_MISS_ = "RETURN_MISS" ;
Expand Down Expand Up @@ -99,4 +89,3 @@ struct LUT
}

};

32 changes: 16 additions & 16 deletions CSG/csg_intersect_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ Flip off the dumpxyz code without changing DEBUG_PIDXYZ with vim replace::
using std::signbit ;
#endif

#include "sflow.h"
#include "FlowAction.h"
#include "csg_classify.h"
#include "csg_error.h"
#include "csg_tranche.h"
#include "csg_stack.h"
#include "csg_postorder.h"
#include "csg_pack.h"
#include "csg_classify.h"
#include "csg_postorder.h"
#include "csg_stack.h"
#include "csg_tranche.h"

#include "f4_stack.h"

Expand Down Expand Up @@ -547,8 +547,7 @@ void intersect_tree( bool& valid_isect, float4& isect, const CSGNode* node, cons
}
#endif


unsigned act = UNDEFINED ;
FlowAction act = FlowAction::Undefined;

if(ctrl < CTRL_LOOP_A) // non-looping : CTRL_RETURN_MISS/CTRL_RETURN_A/CTRL_RETURN_B/CTRL_RETURN_FLIP_B "returning" with a push
{
Expand All @@ -566,7 +565,7 @@ void intersect_tree( bool& valid_isect, float4& isect, const CSGNode* node, cons
ierr = csg_pop0(csg); if(ierr) break ;
ierr = csg_push(csg, result, nodeIdx ); if(ierr) break ;

act = CONTINUE ;
act = FlowAction::Continue;

#ifdef DEBUG_RECORD
if(CSGRecord::ENABLED)
Expand Down Expand Up @@ -625,20 +624,23 @@ void intersect_tree( bool& valid_isect, float4& isect, const CSGNode* node, cons
// push the tranche from here to endTree before pushing the backtracking tranche so known how to proceed after backtracking done
// (hmm: using tmin onwards to endTree looks a bit funny, maybe it should be advanced?)

ierr = tranche_push( tr, endTree, tmin ); if(ierr) break ;
ierr = tranche_push( tr, loopTree, tminAdvanced ); if(ierr) break ;
ierr = tranche_push(tr, endTree, tmin);
if (ierr)
break;
ierr = tranche_push(tr, loopTree, tminAdvanced);
if (ierr)
break;

act = BREAK ;
act = FlowAction::Break;

#ifdef DEBUG_RECORD
if(CSGRecord::ENABLED)
printf("// %3d : looping : act BREAK \n", nodeIdx );
#endif

} // "return" or "recursive call"
} // "return" or "recursive call"


if(act == BREAK)
if (act == FlowAction::Break)
{
#ifdef DEBUG_RECORD
if(CSGRecord::ENABLED)
Expand Down Expand Up @@ -739,5 +741,3 @@ float distance_prim( const float3& global_position, const CSGNode* node, const f
}
return distance ;
}


78 changes: 36 additions & 42 deletions qudarap/qsim.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ Canonical use is from CSGOptiX/CSGOptiX7.cu:simulate
#include "OpticksGenstep.h"
#include "OpticksPhoton.h"

#include "sflow.h"
#include "sqat4.h"
#include "FlowAction.h"
#include "sc4u.h"
#include "sxyz.h"
#include "sphoton.h"
#include "sqat4.h"
#include "sxyz.h"

#include "storch.h"
#include "scarrier.h"
Expand Down Expand Up @@ -105,29 +105,27 @@ struct qsim
QSIM_METHOD static void lambertian_direction(float3* dir, const float3* normal, float orient, RNG& rng, sctx& ctx );
QSIM_METHOD static void random_direction_marsaglia(float3* dir, RNG& rng, sctx& ctx );
QSIM_METHOD void rayleigh_scatter(RNG& rng, sctx& ctx );
QSIM_METHOD int propagate_to_boundary( unsigned& flag, RNG& rng, sctx& ctx );
#endif
QSIM_METHOD FlowAction propagate_to_boundary(unsigned& flag, RNG& rng, sctx& ctx);

#if defined(__CUDACC__) || defined(__CUDABE__) || defined( MOCK_CURAND ) || defined(MOCK_CUDA)
QSIM_METHOD int propagate_at_boundary( unsigned& flag, RNG& rng, sctx& ctx, float theTransmittance=-1.f ) const ;
QSIM_METHOD int propagate_at_boundary_with_T( unsigned& flag, RNG& rng, sctx& ctx, float theTransmittance ) const ;
QSIM_METHOD FlowAction propagate_at_boundary(unsigned& flag, RNG& rng, sctx& ctx, float theTransmittance = -1.f) const;
QSIM_METHOD FlowAction propagate_at_boundary_with_T(unsigned& flag, RNG& rng, sctx& ctx, float theTransmittance) const;
#endif

#if defined(__CUDACC__) || defined(__CUDABE__)
QSIM_METHOD int propagate_at_surface_MultiFilm(unsigned& flag, RNG& rng, sctx& ctx );
QSIM_METHOD FlowAction propagate_at_surface_MultiFilm(unsigned& flag, RNG& rng, sctx& ctx);
#endif

#if defined(__CUDACC__) || defined(__CUDABE__) || defined( MOCK_CURAND ) || defined(MOCK_CUDA)
QSIM_METHOD int propagate_at_surface( unsigned& flag, RNG& rng, sctx& ctx );
QSIM_METHOD int propagate_at_surface_Detect( unsigned& flag, RNG& rng, sctx& ctx ) const ;
QSIM_METHOD FlowAction propagate_at_surface(unsigned& flag, RNG& rng, sctx& ctx);
QSIM_METHOD FlowAction propagate_at_surface_Detect(unsigned& flag, RNG& rng, sctx& ctx) const;
#endif

#if defined(__CUDACC__) || defined(__CUDABE__) || defined( MOCK_CURAND ) || defined(MOCK_CUDA)
QSIM_METHOD void reflect_diffuse( RNG& rng, sctx& ctx );
QSIM_METHOD void reflect_specular( RNG& rng, sctx& ctx );

QSIM_METHOD void fake_propagate( sphoton& p, const quad2* mock_prd, RNG& rng, unsigned long long idx );
QSIM_FORCEINLINE_METHOD int propagate(const int bounce, RNG& rng, sctx& ctx);
QSIM_FORCEINLINE_METHOD FlowAction propagate(const int bounce, RNG& rng, sctx& ctx);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the OptiX simulate caller to FlowAction

This signature change removes the unscoped START/BREAK names that CSGOptiX/CSGOptiX7.cu still relies on in simulate (int command = START and if(command == BREAK)). In CUDA simulation builds that translation unit includes this header, so the deleted sflow.h no longer supplies those symbols, and sim->propagate(...) now returns a FlowAction that cannot be assigned to the existing int variable. Please update the OptiX bounce loop to use FlowAction::Start/FlowAction::Break too.

Useful? React with 👍 / 👎.


QSIM_METHOD void hemisphere_polarized( unsigned polz, bool inwards, RNG& rng, sctx& ctx );
QSIM_METHOD void generate_photon_simtrace( quad4& p, RNG& rng, const quad6& gs, unsigned long long photon_id, unsigned genstep_id ) const ;
Expand Down Expand Up @@ -711,9 +709,7 @@ qsim::propagate_to_boundary

**/



inline QSIM_METHOD int qsim::propagate_to_boundary(unsigned& flag, RNG& rng, sctx& ctx)
inline QSIM_METHOD FlowAction qsim::propagate_to_boundary(unsigned& flag, RNG& rng, sctx& ctx)
{
sphoton& p = ctx.p ;
const sstate& s = ctx.s ;
Expand Down Expand Up @@ -806,7 +802,7 @@ inline QSIM_METHOD int qsim::propagate_to_boundary(unsigned& flag, RNG& rng, sct
{
// Failed energy conservation after 100 attempts — absorb without re-emission
flag = BULK_ABSORB;
return BREAK;
return FlowAction::Break;
}

p.wavelength = new_wavelength;
Expand Down Expand Up @@ -846,7 +842,7 @@ inline QSIM_METHOD int qsim::propagate_to_boundary(unsigned& flag, RNG& rng, sct
}

flag = BULK_REEMIT;
return CONTINUE;
return FlowAction::Continue;
}
else if (absorption_distance <= scattering_distance)
{
Expand Down Expand Up @@ -879,7 +875,7 @@ inline QSIM_METHOD int qsim::propagate_to_boundary(unsigned& flag, RNG& rng, sct
if (scint == nullptr)
{
flag = BULK_ABSORB;
return BREAK;
return FlowAction::Break;
}

float u_re_wavelength = curand_uniform(&rng);
Expand All @@ -901,12 +897,12 @@ inline QSIM_METHOD int qsim::propagate_to_boundary(unsigned& flag, RNG& rng, sct
#endif

flag = BULK_REEMIT ;
return CONTINUE;
return FlowAction::Continue;
}
else
{
flag = BULK_ABSORB ;
return BREAK;
return FlowAction::Break;
}
}
// otherwise sail to boundary
Expand All @@ -922,7 +918,7 @@ inline QSIM_METHOD int qsim::propagate_to_boundary(unsigned& flag, RNG& rng, sct

flag = BULK_SCATTER;

return CONTINUE;
return FlowAction::Continue;
}
// otherwise sail to boundary
} // if scattering_distance < absorption_distance
Expand All @@ -938,7 +934,7 @@ inline QSIM_METHOD int qsim::propagate_to_boundary(unsigned& flag, RNG& rng, sct
ctx.pidx, p.pos.x, p.pos.y, p.pos.z, p.time, sail_time_delta );
#endif

return BOUNDARY ;
return FlowAction::Boundary;
}
#endif
#if defined(__CUDACC__) || defined(__CUDABE__) || defined( MOCK_CURAND ) || defined(MOCK_CUDA)
Expand Down Expand Up @@ -1073,7 +1069,7 @@ incidence.

**/

inline QSIM_METHOD int qsim::propagate_at_boundary(unsigned& flag, RNG& rng, sctx& ctx, float theTransmittance ) const
inline QSIM_METHOD FlowAction qsim::propagate_at_boundary(unsigned& flag, RNG& rng, sctx& ctx, float theTransmittance) const
{
#if !defined(PRODUCTION) && defined(DEBUG_PIDX)
if(ctx.pidx == base->pidx)
Expand Down Expand Up @@ -1281,7 +1277,7 @@ inline QSIM_METHOD int qsim::propagate_at_boundary(unsigned& flag, RNG& rng, sct
}
#endif

return CONTINUE ;
return FlowAction::Continue;
}
/**
qsim::propagate_at_boundary_with_T
Expand All @@ -1300,7 +1296,7 @@ and leave this just for testing.

**/

inline QSIM_METHOD int qsim::propagate_at_boundary_with_T(unsigned& flag, RNG& rng, sctx& ctx, float theTransmittance ) const
inline QSIM_METHOD FlowAction qsim::propagate_at_boundary_with_T(unsigned& flag, RNG& rng, sctx& ctx, float theTransmittance) const
{
sphoton& p = ctx.p ;
const sstate& s = ctx.s ;
Expand Down Expand Up @@ -1374,8 +1370,7 @@ inline QSIM_METHOD int qsim::propagate_at_boundary_with_T(unsigned& flag, RNG& r

flag = reflect ? BOUNDARY_REFLECT : BOUNDARY_TRANSMIT ;


return CONTINUE ;
return FlowAction::Continue;
}

#endif
Expand Down Expand Up @@ -1614,7 +1609,7 @@ Tp: p-component reflect probability
*/

#if defined(__CUDACC__) || defined(__CUDABE__)
inline QSIM_METHOD int qsim::propagate_at_surface_MultiFilm(unsigned& flag, RNG& rng, sctx& ctx )
inline QSIM_METHOD FlowAction qsim::propagate_at_surface_MultiFilm(unsigned& flag, RNG& rng, sctx& ctx)
{

const float one = 1.0f;
Expand Down Expand Up @@ -1665,9 +1660,9 @@ inline QSIM_METHOD int qsim::propagate_at_surface_MultiFilm(unsigned& flag, RNG&
const float& theEfficiency = _qe/An;

float u_theAbsorption = curand_uniform(&rng);
int action = u_theAbsorption < theAbsorption ? BREAK : CONTINUE ;
FlowAction action = u_theAbsorption < theAbsorption ? FlowAction::Break : FlowAction::Continue;

if( action == BREAK )
if (action == FlowAction::Break)
{
float u_theEfficiency = curand_uniform(&rng) ;
flag = u_theEfficiency < theEfficiency ? SURFACE_DETECT : SURFACE_ABSORB ;
Expand Down Expand Up @@ -1753,7 +1748,7 @@ The s.surface float4 is filled by qbnd::fill_state via::

**/

inline QSIM_METHOD int qsim::propagate_at_surface(unsigned& flag, RNG& rng, sctx& ctx)
inline QSIM_METHOD FlowAction qsim::propagate_at_surface(unsigned& flag, RNG& rng, sctx& ctx)
{
const sstate& s = ctx.s ;
const float& detect = s.surface.x ;
Expand All @@ -1770,10 +1765,9 @@ inline QSIM_METHOD int qsim::propagate_at_surface(unsigned& flag, RNG& rng, sctx
tagr.add( stag_sf_burn, u_surface_burn);
#endif

FlowAction action = u_surface < absorb + detect ? FlowAction::Break : FlowAction::Continue;

int action = u_surface < absorb + detect ? BREAK : CONTINUE ;

if( action == BREAK )
if (action == FlowAction::Break)
{
flag = u_surface < absorb ?
SURFACE_ABSORB
Expand Down Expand Up @@ -1802,12 +1796,11 @@ inline QSIM_METHOD int qsim::propagate_at_surface(unsigned& flag, RNG& rng, sctx
return action ;
}


inline QSIM_METHOD int qsim::propagate_at_surface_Detect(unsigned& flag, RNG& rng, sctx& ctx) const
inline QSIM_METHOD FlowAction qsim::propagate_at_surface_Detect(unsigned& flag, RNG& rng, sctx& ctx) const
{
float u_surface_burn = curand_uniform(&rng); // for random alignment
flag = SURFACE_DETECT ;
return BREAK ;
return FlowAction::Break;
}

#endif
Expand Down Expand Up @@ -2046,7 +2039,7 @@ inline QSIM_METHOD void qsim::fake_propagate( sphoton& p, const quad2* mock_prd,
ctx.evt = evt ;
ctx.pidx = idx ;

int command = START ;
FlowAction command = FlowAction::Start;
int bounce = 0 ;
#ifndef PRODUCTION
ctx.point(bounce);
Expand All @@ -2070,7 +2063,8 @@ inline QSIM_METHOD void qsim::fake_propagate( sphoton& p, const quad2* mock_prd,
#ifndef PRODUCTION
ctx.point(bounce);
#endif
if(command == BREAK) break ;
if (command == FlowAction::Break)
break;
}
#ifndef PRODUCTION
ctx.end();
Expand Down Expand Up @@ -2123,7 +2117,7 @@ Prior to supporting special surfaces, within the command == BOUNDARY used::

**/

QSIM_FORCEINLINE_METHOD int qsim::propagate(const int bounce, RNG& rng, sctx& ctx)
QSIM_FORCEINLINE_METHOD FlowAction qsim::propagate(const int bounce, RNG& rng, sctx& ctx)
{
const unsigned boundary = ctx.prd->boundary() ;
const unsigned identity = ctx.prd->identity() ; // sensor_identifier+1, 0:not-a-sensor
Expand Down Expand Up @@ -2171,7 +2165,7 @@ QSIM_FORCEINLINE_METHOD int qsim::propagate(const int bounce, RNG& rng, sctx& ct

unsigned flag = 0 ;

int command = propagate_to_boundary( flag, rng, ctx );
FlowAction command = propagate_to_boundary(flag, rng, ctx);
/**
command possibilities:

Expand All @@ -2187,7 +2181,7 @@ QSIM_FORCEINLINE_METHOD int qsim::propagate(const int bounce, RNG& rng, sctx& ct
ctx.pidx, bounce, command, flag, ctx.s.optical.x, ctx.s.optical.y );
#endif

if( command == BOUNDARY )
if (command == FlowAction::Boundary)
{
const int& ems = ctx.s.optical.y ;

Expand Down
Loading
Loading