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

SCM Repository

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

View of /branches/lamont/src/compiler/c-target/fragments/grid.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2201 - (download) (annotate)
Sun Feb 24 16:02:12 2013 UTC (7 years, 8 months ago) by lamonts
File size: 1633 byte(s)
Refactored the spatail implementation slightly
/**** Common Grid Functions: (Retrieval, Clearing, Building, and Querying) ********/  
STATIC_INLINE GridItem_t * Diderot_GridFindItemInCell(uint32_t id, GridContext * ctx)
{ 
    return &(ctx->gridPool.pool[id]);
}
STATIC_INLINE GridItem_t * Diderot_GridFindCellStart(uint32_t id, GridContext * ctx)
{ 
    if(ctx->grid[id].poolIdx == -1) 
        return 0; 
    else 
        return &(ctx->gridPool.pool[ctx->grid[id].poolIdx]); 
}
STATIC_INLINE 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) 
{ 
   uint32_t size = 0; 
   ctx->gridPool.handle  = 0;  

#if defined(DIDEROT_GRID_2D)
    Diderot_union2_t v;
    v.v = *(ctx->gridSize);  
    size = (v.r[0] + 2) * (v.r[1] + 2); 

#elif defined(DIDEROT_GRID_3D)
    Diderot_union3_t v;
    v.v = *(ctx->gridSize);  
    size = (v.r[0] + 2) * (v.r[1] + 2) * (v.r[2] + 2);
#else
#  error grid dimension unknown
#endif 

    for(uint32_t i=0; i < size; i++){ 
       ctx->grid[i].poolIdx = -1; 
    }
}
STATIC_INLINE Diderot_DynSeq_t * spherical_query(@STRANDTY@ ** strands,
                                    @STRANDTY@ * qStrand,
                                   GridContext * ctx,
                                   QueryPool_t * queryPool,
                                   Diderot_real_t radius) 
{
    return spherical_query@GRID_D@D(strands,qStrand,ctx,queryPool,radius);
}


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