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/kdtree.in
ViewVC logotype

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

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

revision 3387, Mon Nov 9 22:04:56 2015 UTC revision 3388, Tue Nov 10 03:17:51 2015 UTC
# Line 32  Line 32 
32    
33          return isWithinRadius@SPATIAL_DIMENSION@D(qPos, neighbor->pos, radius);          return isWithinRadius@SPATIAL_DIMENSION@D(qPos, neighbor->pos, radius);
34  }  }
35    void sphereSearchOpt(@PREFIX@World_t * wrld,
 void sphereSearch(@PREFIX@World_t * wrld,  
36                                    KDNode_t * curr,                                    KDNode_t * curr,
37                                    Diderot_vec@SPATIAL_DIMENSION@_t qPos,                                    Diderot_vec@SPATIAL_DIMENSION@_t qPos,
38                                    uint32_t qStrandId,                                    uint32_t qStrandId,
# Line 44  Line 43 
43                                    uint32_t * neighborCount)                                    uint32_t * neighborCount)
44  {  {
45          @STRANDTY@ ** strands = wrld->inState;          @STRANDTY@ ** strands = wrld->inState;
   
46          if (!curr) return;          if (!curr) return;
47    
48          bool shouldInclude = (qStrandId != curr->strandId) &&          bool shouldInclude = (qStrandId != curr->strandId) &&
# Line 52  Line 50 
50                                                    wrld->status[curr->strandId] == DIDEROT_STABLE);                                                    wrld->status[curr->strandId] == DIDEROT_STABLE);
51    
52          if(shouldInclude && Diderot_KDTree_isWithinRadius(qPos,strands[curr->strandId],radius,dim)) {          if(shouldInclude && Diderot_KDTree_isWithinRadius(qPos,strands[curr->strandId],radius,dim)) {
   
53                  Diderot_QueryList_Add(strands[curr->strandId],qList);                  Diderot_QueryList_Add(strands[curr->strandId],qList);
54                  *neighborCount +=1;                  *neighborCount +=1;
   
55          }          }
56    
   
57          int oldI = i;          int oldI = i;
58    
59          if (++i >= dim) i = 0;          if (++i >= dim) i = 0;
60    
61          if ( Diderot_Query_GetPosValue(strands[curr->strandId]->pos,oldI) >= (Diderot_Query_GetPosValue(qPos,oldI) - radius)  &&          if ((Diderot_Query_GetPosValue(strands[curr->strandId]->pos,oldI) >= (Diderot_Query_GetPosValue(qPos,oldI) - radius)  &&
62                  (Diderot_Query_GetPosValue(strands[curr->strandId]->pos,oldI) <= (Diderot_Query_GetPosValue(qPos,oldI) + radius))) {                  (Diderot_Query_GetPosValue(strands[curr->strandId]->pos,oldI) <= (Diderot_Query_GetPosValue(qPos,oldI) + radius)))) {
63                  sphereSearch(wrld,curr->left,qPos,qStrandId,qList, radius, i, dim,neighborCount);  
64                  sphereSearch(wrld,curr->right,qPos,qStrandId, qList,radius, i, dim,neighborCount);                  sphereSearchOpt(wrld,curr->left,qPos,qStrandId,qList, radius, i, dim,neighborCount);
65                    sphereSearchOpt(wrld,curr->right,qPos,qStrandId, qList,radius, i, dim,neighborCount);
66    
67          }else if(Diderot_Query_GetPosValue(strands[curr->strandId]->pos,oldI) <= (Diderot_Query_GetPosValue(qPos,oldI) - radius)){          }else if(Diderot_Query_GetPosValue(strands[curr->strandId]->pos,oldI) <= (Diderot_Query_GetPosValue(qPos,oldI) - radius)){
68                  sphereSearch(wrld,curr->right,qPos,qStrandId, qList,radius, i, dim,neighborCount);                  sphereSearchOpt(wrld,curr->right,qPos,qStrandId, qList,radius, i, dim,neighborCount);
69          }else {          }else {
70                  sphereSearch(wrld,curr->left, qPos,qStrandId, qList,radius, i, dim,neighborCount);                  sphereSearchOpt(wrld,curr->left, qPos,qStrandId, qList,radius, i, dim,neighborCount);
71            }
72    }
73    void sphereSearch(@PREFIX@World_t * wrld,
74                                      Diderot_vec@SPATIAL_DIMENSION@_t qPos,
75                                      uint32_t qStrandId,
76                                      QueryList_t * qList,
77                                      Diderot_real_t radius,
78                                      uint32_t dim,
79                                      uint32_t * neighborCount)
80    {
81            @STRANDTY@ ** strands = wrld->inState;
82            for(int i = 0; i < wrld->numStrands; i++){
83                    @STRANDTY@ * curr = strands[i];
84                    bool shouldInclude = (qStrandId != curr->strandId) &&
85                                                     (wrld->status[curr->strandId] == DIDEROT_ACTIVE ||
86                                                      wrld->status[curr->strandId] == DIDEROT_STABLE);
87                    if (shouldInclude && Diderot_KDTree_isWithinRadius(qPos,curr,radius,dim)){
88                            Diderot_QueryList_Add(strands[curr->strandId],qList);
89                            *neighborCount +=1;
90                    }
91          }          }
92  }  }
93    
# Line 88  Line 104 
104          KDTree_t * tree = wrld->spatialTree;          KDTree_t * tree = wrld->spatialTree;
105          uint32_t qStrandId = qStrand->strandId;          uint32_t qStrandId = qStrand->strandId;
106          QueryList_t * qList = Diderot_Grab_QueryList(queryPool);          QueryList_t * qList = Diderot_Grab_QueryList(queryPool);
107          sphereSearch(wrld,tree->root,qPos,qStrandId,qList,radius,0,tree->dim,&neighborCount);          if(!wrld->disableSOpt)
108            {
109                    sphereSearchOpt(wrld,tree->root,qPos,qStrandId,qList,radius,0,tree->dim,&neighborCount);
110            }else {
111                    sphereSearch(wrld,qPos,qStrandId,qList,radius,@SPATIAL_DIMENSION@,&neighborCount);
112            }
113    
114          Diderot_DynSeq_t * seq = Diderot_DynSeqAlloc(sizeof(@STRANDTY@ *), neighborCount);          Diderot_DynSeq_t * seq = Diderot_DynSeqAlloc(sizeof(@STRANDTY@ *), neighborCount);
115      seq->data = qList->pool;      seq->data = qList->pool;
116          return seq;          return seq;

Legend:
Removed from v.3387  
changed lines
  Added in v.3388

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