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

SCM Repository

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

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

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

revision 1518, Sat Oct 8 02:39:41 2011 UTC revision 1519, Sun Oct 9 18:30:16 2011 UTC
# Line 9  Line 9 
9   */   */
10    
11  #include <Diderot/diderot.h>  #include <Diderot/diderot.h>
 #include <string.h>  
 #include <stdio.h>  
 #include <assert.h>  
12  #include <teem/nrrd.h>  #include <teem/nrrd.h>
13    
14  // NOTE: we probably should put this in a file that supports runtime printing  // NOTE: we probably should put this in a file that supports runtime printing
# Line 20  Line 17 
17  static bool     NrrdOutputFlg = false;  static bool     NrrdOutputFlg = false;
18    
19  struct struct_world {  struct struct_world {
20      const char          *name;          //!< the program name      STRUCT_WORLD_PREFIX
     bool                isArray;        //!< is the initialization an array or collection?  
     uint32_t            nDims;          //!< depth of iteration nesting  
     int32_t             *base;          //!< nDims array of base indices  
     uint32_t            *size;          //!< nDims array of iteration sizes  
     uint32_t            numStrands;     //!< number of strands in the world  
21      void                **inState;      void                **inState;
22      void                **outState;      void                **outState;
     uint8_t             *status;        //!< array of strand status flags  
23  };  };
24    
25  extern float getOutf (void *self);  extern float getOutf (void *self);
# Line 73  Line 64 
64                  StrandStatus_t sts = Diderot_Strands[0]->update(wrld->inState[i], wrld->outState[i]);                  StrandStatus_t sts = Diderot_Strands[0]->update(wrld->inState[i], wrld->outState[i]);
65                  switch (sts) {                  switch (sts) {
66                    case DIDEROT_STABILIZE:                    case DIDEROT_STABILIZE:
                     Diderot_Strands[0]->stabilize(wrld->inState[i], wrld->outState[i]);  
67                      existsStabilizing = true;                      existsStabilizing = true;
68                      wrld->status[i] = DIDEROT_STABILIZE;                      wrld->status[i] = DIDEROT_STABILIZE;
69                      break;                      break;
# Line 90  Line 80 
80              for (int i = 0;  i < wrld->numStrands;  i++) {              for (int i = 0;  i < wrld->numStrands;  i++) {
81  // NOTE: we may want to compact the array of strands  // NOTE: we may want to compact the array of strands
82                  if (wrld->status[i] == DIDEROT_STABILIZE) {                  if (wrld->status[i] == DIDEROT_STABILIZE) {
 #ifdef STABILIZE_FIXED  
83                    // stabilize the strand's state.  Note that the outState has been set by                    // stabilize the strand's state.  Note that the outState has been set by
84                    // the last call to update, so we make the inState be the target of the                    // the last call to update, so we make the inState be the target of the
85                    // stabilize method.  This call also has the effect of copying out to in.                    // stabilize method.
86                      Diderot_Strands[0]->stabilize(wrld->outState[i], wrld->inState[i]);                      Diderot_Strands[0]->stabilize(wrld->outState[i], wrld->inState[i]);
87  #endif                      memcpy (wrld->outState[i], wrld->inState[i], Diderot_Strands[0]->stateSzb);
                   // copy out to in so that both copies are the stable state  
                     memcpy (wrld->inState[i], wrld->outState[i], Diderot_Strands[0]->stateSzb);  
88                      wrld->status[i] = DIDEROT_STABLE;                      wrld->status[i] = DIDEROT_STABLE;
89                      nActive--;                      nActive--;
90                  }                  }
# Line 116  Line 103 
103          printf ("usr=%f\n", totalTime);          printf ("usr=%f\n", totalTime);
104    
105    // output the final strand states    // output the final strand states
     Output_Args_t outArgs;  
     outArgs.name = wrld->name;  
     outArgs.isArray = wrld->isArray;  
     outArgs.numStrands = wrld->numStrands;  
     outArgs.status = wrld->status;  
     outArgs.inState = wrld->inState;  
     outArgs.nDims = wrld->nDims;  
     outArgs.size = wrld->size;  
     outArgs.outputSzb = Diderot_Strands[0]->outputSzb;  
106      if (NrrdOutputFlg)      if (NrrdOutputFlg)
107          Diderot_Output (&outArgs);          Diderot_Output (wrld, Diderot_Strands[0]->outputSzb);
108      else      else
109          Diderot_Print (&outArgs);          Diderot_Print (wrld);
110    
111      Diderot_Shutdown (wrld);      Diderot_Shutdown (wrld);
112    
# Line 136  Line 114 
114    
115  }  }
116    
   
 // this should be the part of the scheduler  
 void *Diderot_AllocStrand (Strand_t *strand)  
 {  
     return CheckedAlloc(strand->stateSzb);  
 }  
   
117  // block allocation of an initial collection of strands  // block allocation of an initial collection of strands
118  Diderot_World_t *Diderot_AllocInitially (  Diderot_World_t *Diderot_AllocInitially (
119      const char *name,           // the name of the program      const char *name,           // the name of the program
# Line 188  Line 159 
159    
160    // initialize strand state pointers etc.    // initialize strand state pointers etc.
161      for (size_t i = 0;  i < numStrands;  i++) {      for (size_t i = 0;  i < numStrands;  i++) {
162          wrld->inState[i] = Diderot_AllocStrand (strand);          wrld->inState[i] = CheckedAlloc (strand->stateSzb);
163          wrld->outState[i] = Diderot_AllocStrand (strand);          wrld->outState[i] = CheckedAlloc (strand->stateSzb);
164          wrld->status[i] = DIDEROT_ACTIVE;          wrld->status[i] = DIDEROT_ACTIVE;
165      }      }
166    
# Line 209  Line 180 
180      assert (i < wrld->numStrands);      assert (i < wrld->numStrands);
181      return wrld->outState[i];      return wrld->outState[i];
182  }  }
   
 bool Diderot_IsActive (Diderot_World_t *wrld, uint32_t i)  
 {  
     assert (i < wrld->numStrands);  
     return !wrld->status[i];  
 }  

Legend:
Removed from v.1518  
changed lines
  Added in v.1519

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