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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/lib/main.c
ViewVC logotype

Diff of /branches/pure-cfg/src/lib/main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 571, Mon Feb 28 21:36:12 2011 UTC revision 572, Tue Mar 1 15:34:03 2011 UTC
# Line 12  Line 12 
12  #define NC      200  #define NC      200
13    
14  #include <string.h>  #include <string.h>
15    #include <stdio.h>
16  #include <Diderot/diderot.h>  #include <Diderot/diderot.h>
17    
18    extern float getOutf (void *self);
19    
20  int main (int argc, const char **argv)  int main (int argc, const char **argv)
21  {  {
22    //    //
23    printf("initializing globals ...\n");
24      Diderot_InitGlobals ();      Diderot_InitGlobals ();
25    
26    // FIXME: we need to figure out how initialization should be handled.    // FIXME: we need to figure out how initialization should be handled.
27    printf("initializing strands ...\n");
28      void *strands1[NR*NC], *strands2[NR*NC];      void *strands1[NR*NC], *strands2[NR*NC];
29      bool active[NR*NC];      bool active[NR*NC];
30      for (int r = 0;  r <= 199;  r++) {      for (int r = 0;  r <= 199;  r++) {
# Line 33  Line 38 
38      }      }
39    
40    // iterate until all strands are stable    // iterate until all strands are stable
41    printf("run ...\n");
42        int nSteps = 0, nUpdates = 0;
43      int nActive = NR*NC;      int nActive = NR*NC;
44      void **in = &(strands1[0]);      void **in = &(strands1[0]);
45      void **out = &(strands2[0]);      void **out = &(strands2[0]);
46      while (nActive > 0) {      while (nActive > 0) {
47            nSteps++;
48        // update strands        // update strands
49          for (int i = 0;  i < NR*NC;  i++) {          for (int i = 0;  i < NR*NC;  i++) {
50              if (active[i]) {              if (active[i]) {
51                    nUpdates++;
52                  StrandStatus_t sts = Diderot_Strands[0].update(in[i], out[i]);                  StrandStatus_t sts = Diderot_Strands[0].update(in[i], out[i]);
53                  if (sts == DIDEROT_STABILIZE) {                  if (sts == DIDEROT_STABILIZE) {
54                    // copy out to in so that final state is correct                    // copy out to in so that final state is correct
# Line 55  Line 64 
64          out = tmp;          out = tmp;
65      }      }
66    
67    printf("done: %d updates, %d steps\n", nUpdates, nSteps);
68    // here we have the final state of all of the strands in the "in" buffer    // here we have the final state of all of the strands in the "in" buffer
69        FILE *outS = fopen("mip.txt", "w");
70        if (outS == NULL) {
71            fprintf (stderr, "Cannot open output file\n");
72            exit (8);
73        }
74    
75        for (int r = 0;  r <= 199;  r++) {
76            for (int c = 0;  c <= 199;  c++) {
77                int i = NC*r + c;
78                float outV = getOutf (in[i]);
79                if (outV < 0)
80                    fprintf (outS, "%.4f\n", 0.0f);
81                else
82                    fprintf (outS, "%.4f\n", outV);
83            }
84        }
85        fclose (outS);
86    
87      return 0;      return 0;
88    

Legend:
Removed from v.571  
changed lines
  Added in v.572

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