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

SCM Repository

[diderot] Diff of /branches/lamont/src/compiler/c-target/fragments/grid2D.in
ViewVC logotype

Diff of /branches/lamont/src/compiler/c-target/fragments/grid2D.in

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

revision 2200, Sun Feb 24 15:16:01 2013 UTC revision 2201, Sun Feb 24 16:02:12 2013 UTC
# Line 1  Line 1 
 STATIC_INLINE GridItem_t * Diderot_GridFindItemInPool(uint32_t id, GridContext * ctx)  
 {  
     return &(ctx->gridPool.pool[id]);  
   
 }  
   
 GridItem_t * Diderot_GridFindItemInGrid(uint32_t id, GridContext * ctx)  
 {  
     if(ctx->grid[id].poolIdx == -1)  
         return 0;  
     else  
         return &(ctx->gridPool.pool[ctx->grid[id].poolIdx]);  
 }  
   
1  //! \brief allocate memory for the grid context  //! \brief allocate memory for the grid context
2  //! \param gridSize the dimensions of the grid  //! \param gridSize the dimensions of the grid
3  //! \param numberOfStrands the number of strands  //! \param numberOfStrands the number of strands
# Line 41  Line 27 
27    
28      return newGridContext;      return newGridContext;
29  }  }
 GridItem_t * newGridItem(GridContext * ctx, uint32_t * poolIdx)  
 {  
    if(ctx->gridPool.handle < ctx->gridPool.poolSize)  
    {  
       *poolIdx = (ctx->gridPool.handle)++;  
       return &(ctx->gridPool.pool[*poolIdx]);  
    } else {  
      //FIXME: write code to resize the grid pool!!!  
      return 0;  
    }  
 }  
 void Diderot_GridClear(GridContext * ctx)  
 {  
     Diderot_union2_t v;  
     v.v = *(ctx->gridSize);  
   
     ctx->gridPool.handle  = 0;  
   
     uint32_t size = (v.r[0] + 2) * (v.r[1] + 2);  
   
     for(uint32_t i=0; i < size; i++){  
        ctx->grid[i].poolIdx = -1;  
     }  
 }  
30  void Diderot_GridAdd2D(Diderot_vec2_t pos, uint32_t id, GridContext * ctx)  void Diderot_GridAdd2D(Diderot_vec2_t pos, uint32_t id, GridContext * ctx)
31  {  {
32     uint32_t gridIdx = worldToGridIdx2D(pos,ctx);     uint32_t gridIdx = worldToGridIdx2D(pos,ctx);
# Line 80  Line 42 
42    
43     ctx->grid[gridIdx].poolIdx = newPoolIdx;     ctx->grid[gridIdx].poolIdx = newPoolIdx;
44  }  }
45  void buildGrid2D(@STRANDTY@ ** strands, GridContext * ctx)  void Diderot_GridBuild2D(@STRANDTY@ ** strands, GridContext * ctx)
46  {  {
47        Diderot_GridClear(ctx);        Diderot_GridClear(ctx);
48    
# Line 130  Line 92 
92     for(int x = xBounds.i[0]; x <= xBounds.i[1]; x++){     for(int x = xBounds.i[0]; x <= xBounds.i[1]; x++){
93          for(int y = yBounds.i[0]; y <= yBounds.i[1]; y++) {          for(int y = yBounds.i[0]; y <= yBounds.i[1]; y++) {
94                   int neighborCellIndx = UMAD(y,gridSize.r[1] + 2,x);                   int neighborCellIndx = UMAD(y,gridSize.r[1] + 2,x);
95                   GridItem_t * neighborCellStrands =  Diderot_GridFindItemInGrid(neighborCellIndx,ctx);                   GridItem_t * neighborCellStrands =  Diderot_GridFindCellStart(neighborCellIndx,ctx);
96                  while(neighborCellStrands != 0) {                  while(neighborCellStrands != 0) {
97                        if(isWithinRadius2D(strandPosition,strands[neighborCellStrands->strandId]->pos,radius)){                        if(isWithinRadius2D(strandPosition,strands[neighborCellStrands->strandId]->pos,radius)){
98                              if(neighborCellStrands->strandId != qStrand->strandId) {                              if(neighborCellStrands->strandId != qStrand->strandId) {
# Line 141  Line 103 
103                       if(neighborCellStrands->next == -1)                       if(neighborCellStrands->next == -1)
104                          break;                          break;
105                       else                       else
106                          neighborCellStrands = Diderot_GridFindItemInPool(neighborCellStrands->next,ctx);                          neighborCellStrands = Diderot_GridFindItemInCell(neighborCellStrands->next,ctx);
107                    }                    }
108          }          }
109      }      }
# Line 150  Line 112 
112    
113      return seq;      return seq;
114  }  }
  Diderot_DynSeq_t * spherical_query(@STRANDTY@ ** strands,  
                                     @STRANDTY@ * qStrand,  
                                    GridContext * ctx,  
                                    QueryPool_t * queryPool,  
                                    Diderot_real_t radius)  
 {  
    return spherical_query2D(strands,qStrand,ctx,queryPool,radius);  
 }  

Legend:
Removed from v.2200  
changed lines
  Added in v.2201

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