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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/include/Diderot/cl-scheduler.h
ViewVC logotype

Diff of /branches/pure-cfg/src/include/Diderot/cl-scheduler.h

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

revision 1488, Fri Sep 9 08:21:07 2011 UTC revision 1489, Fri Sep 9 08:57:21 2011 UTC
# Line 26  Line 26 
26    
27  typedef struct {  typedef struct {
28      int numStrands;                 // number of strands      int numStrands;                 // number of strands
29      int sId;                         // the index into the todo list or queue      int sId;                         // the index accumlator for the todo list or queue
30      int nextStrand[1];              // index of the next strand to retrieve from the pool      int nextStrand[1];              // index of the next strand to retrieve from the pool
31      int queueSize;                  // number of blocks on the scheduler's queue      int queueSize;                  // number of blocks on the scheduler's queue
32      int todoSize;                   // number of blocks on the scheduler's todo list      int todoSize;                   // number of blocks on the scheduler's todo list
# Line 46  Line 46 
46      __global StrandBlock_t *blocks,      __global StrandBlock_t *blocks,
47      __local StrandBlock_t *lBlk)      __local StrandBlock_t *lBlk)
48  {  {
49        //Retrieve a block from the list
50      int blkIdx = atom_inc(&(sched->sId));      int blkIdx = atom_inc(&(sched->sId));
     lBlk->nDying = blkIdx;  
51    
52        //Check to see if the index retrieve is less than the
53        //number of blocks on the queue
54      if(blkIdx < sched->queueSize)      if(blkIdx < sched->queueSize)
55      {      {
56            //Copy over the global data for the block into local memory
57          lBlk->blkIdx = (blocks[queue[blkIdx]]).blkIdx;          lBlk->blkIdx = (blocks[queue[blkIdx]]).blkIdx;
58          lBlk->nActive = (blocks[queue[blkIdx]]).nActive;          lBlk->nActive = (blocks[queue[blkIdx]]).nActive;
59          lBlk->nDead = (blocks[queue[blkIdx]]).nDead;          lBlk->nDead = (blocks[queue[blkIdx]]).nDead;
60          lBlk->nStabilizing = (blocks[queue[blkIdx]]).nStabilizing;          lBlk->nStabilizing = (blocks[queue[blkIdx]]).nStabilizing;
61          lBlk->nDying = (blocks[queue[blkIdx]]).nDying;          lBlk->nDying = (blocks[queue[blkIdx]]).nDying;
62    
63            //If the his block has no active strands then check to see if
64            // there are strands still waiting to be processed
65          if(lBlk->nActive == 0)          if(lBlk->nActive == 0)
66          {          {
67                //Get a block of strands
68              int startStrandIdx = atom_add(&(sched->nextStrand[0]), BLK_SZ);              int startStrandIdx = atom_add(&(sched->nextStrand[0]), BLK_SZ);
69              int idx = 0, count = 0;              int idx = 0, count = 0;
70                //For each work-item in the workgroup
71              for(int i = startStrandIdx, count = 0; i < sched->numStrands && count < BLK_SZ; i++,count++)              for(int i = startStrandIdx, count = 0; i < sched->numStrands && count < BLK_SZ; i++,count++)
72              {              {
73                    //Increment the number of active strands and assign each work-item a strand to process
74                  lBlk->nActive++;                  lBlk->nActive++;
75                  blockIndxs[lBlk->blkIdx * BLK_SZ + idx] = i;                  blockIndxs[lBlk->blkIdx * BLK_SZ + idx] = i;
76                  idx++;                  idx++;
77              }              }
78                //If there are no strands left to process than make this block inactive
79              if(idx == 0)              if(idx == 0)
80                  lBlk->nActive = -1;                  lBlk->nActive = -1;
81          }          }
82      }      }
83        //IF there isn't any queue items then notify the the workgroup
84      else      else
85          lBlk->nActive = -1;          lBlk->nActive = -1;
86  }  }
87    
88  //! \brief Get a block of strands from the scheduler pool.  //! \brief Get a block of strands from the Todolist scheduler pool.
89  //! \param sched global scheduler state  //! \param sched global scheduler state
90  //! \param blocks global array of strand blocks  //! \param blocks global array of strand blocks
91  //! \param lBlk pointer to global storage for the strand block  //! \param lBlk pointer to global storage for the strand block
# Line 87  Line 97 
97      __global StrandBlock_t *blocks,      __global StrandBlock_t *blocks,
98      __local StrandBlock_t *lBlk)      __local StrandBlock_t *lBlk)
99  {  {
100        //Retrieve a block from the todolist
101      int blkIdx = atom_inc(&(sched->sId));      int blkIdx = atom_inc(&(sched->sId));
102    
103        //Check to make sure the idx retrieve is a valid for the list
104      if(blkIdx < sched->todoSize)      if(blkIdx < sched->todoSize)
105      {      {
106            //Copy over the global data into the local data.
107          lBlk->blkIdx = (blocks[todoList[blkIdx]]).blkIdx;          lBlk->blkIdx = (blocks[todoList[blkIdx]]).blkIdx;
108          lBlk->nActive = (blocks[todoList[blkIdx]]).nActive;          lBlk->nActive = (blocks[todoList[blkIdx]]).nActive;
109          lBlk->nDead = (blocks[todoList[blkIdx]]).nDead;          lBlk->nDead = (blocks[todoList[blkIdx]]).nDead;

Legend:
Removed from v.1488  
changed lines
  Added in v.1489

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