Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/vis12/bugs/open/bug048.diderot
ViewVC logotype

View of /branches/vis12/bugs/open/bug048.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3331 - (download) (annotate)
Wed Oct 21 06:05:03 2015 UTC (4 years, 4 months ago) by glk
File size: 2092 byte(s)
don't know
/*
Something about this was fixed in 2012, but it no longer compiles
(perhaps a repeat of the bug047 issue)

"../../bin/diderotc --exec bug048.diderot" produces:

*** dump environment
  step0713 --> DEF l_step_55
  pos0724 --> DEF l_pos_59
  dir0731 --> DEF l_dir_61
  _t05B1 --> DEF
  out05C1 --> DEF
  sum05C3 --> DEF
  num05C5 --> DEF
***
uncaught exception Fail [Fail: useVar(num0733)]
  raised at common/phase-timer.sml:78.50-78.52
  raised at common/phase-timer.sml:78.50-78.52
  raised at common/phase-timer.sml:78.50-78.52
  raised at tree-il/low-to-tree-fn.sml:136.7-136.50

*/

// FIXED [JHR; 23-03-2012]

// BUG:
// this program does not terminate.  The issue is that the body of the
// "if (dir > 0.0)" is empty in the generated C code.
// The problem is that the SSA form constructed for the successor of the block
// is missing the PHI node, which makes the assignments in the block unused.
// It appears related to the fact that one arm of the if is a stabilize, which
// so there is a single-predecessor join node.
//

int imgSize = 200;
real h = 0.25;    // step size of integration
int stepNum = 5; // take this many steps both upstream and downstream

field#1(2)[2] V = image("../data/tor2slice-vec0.nrrd") ⊛ ctmr;
field#0(2)[] R = image("../data/tor2slice-rand.nrrd") ⊛ tent;

strand LIC (int xi, int yi) {
    real xx = lerp(0.0, 79.0, -0.5, real(xi), real(imgSize)-0.5);
    real yy = lerp(0.0, 79.0, -0.5, real(yi), real(imgSize)-0.5);
    vec2 pos0 = [xx,yy];
    vec2 pos0backup = [xx,yy];
    vec2 pos = pos0;
    vec2 step = [0.0,0.0];
    output vec3 out = [0.0,0.0,0.0];
    real sum = 0.0;
    int num = 0;
    real dir = 1.0;

    update {
      step = h*dir*V(pos);
      if (inside(pos + step, V) && inside(pos + step, R)) {
        pos += step;
      }
      if (num == stepNum) {
	if (dir > 0.0) {
	  num = 0;
	  pos = pos0backup;
	  dir = -1.0;
	}
	else
	  stabilize;
      }
      sum += R(pos);
      num += 1;
    }

    stabilize {
      out = [pos[0], pos[1], sum];
    }
}

initially [ LIC(xi, yi) | yi in 0..(imgSize-1), xi in 0..(imgSize-1) ];

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0