Commits

Rio Yokota committed 2abe6e4

Rename LEAF -> BODY.

Comments (0)

Files changed (9)

 #LFLAGS	+= -std=c++0x -DTBB -ltbb
 
 ### MassiveThreads flags (doesn't work with OpenMP) : MassiveThreads is available from http://code.google.com/p/massivethreads/
-#LFLAGS	+= -std=c++0x -DMTHREAD -lmyth
+LFLAGS	+= -std=c++0x -DMTHREAD -lmyth
 
 ### PAPI flags
 #LFLAGS	+= -DPAPI -lpapi

examples/parallel.cxx

           std::cout << FMM.MPIRANK << " NCHILD : " << Ci->NCHILD << " " << Cj->NCHILD << std::endl;
           break;
         }
-        if( Ci->NCLEAF != Cj->NCLEAF ) {
-          std::cout << FMM.MPIRANK << " NCLEAF : " << Ci->NCLEAF << " " << Cj->NCLEAF << std::endl;
+        if( Ci->NCBODY != Cj->NCBODY ) {
+          std::cout << FMM.MPIRANK << " NCBODY : " << Ci->NCBODY << " " << Cj->NCBODY << std::endl;
           break;
         }
         real_t sumi = 0, sumj = 0;
-        if( Ci->NCLEAF != 0 ) {
-          for( int i=0; i<Ci->NCLEAF; i++ ) {
-            B_iter Bi = Ci->LEAF+i;
-            B_iter Bj = Cj->LEAF+i;
+        if( Ci->NCBODY != 0 ) {
+          for( int i=0; i<Ci->NCBODY; i++ ) {
+            B_iter Bi = Ci->BODY+i;
+            B_iter Bj = Cj->BODY+i;
             sumi += Bi->X[0];
             sumj += Bj->X[0];
           }

include/evaluator.h

   real_t NM2L;                                                  //!< Number of M2L kernel calls
 
 public:
-  int NSPAWN;                                                   //!< Threshold of NDLEAF for spawning new threads
+  int NSPAWN;                                                   //!< Threshold of NDBODY for spawning new threads
   int IMAGES;                                                   //!< Number of periodic image sublevels
   float THETA;                                                  //!< Multipole acceptance criteria
 
 //! Approximate interaction between two cells
   inline void approximate(C_iter Ci, C_iter Cj, bool mutual) {
 #if AUTO
-    if (timeP2P*Ci->NDLEAF*Cj->NDLEAF > timeM2L) {              // If M2L is faster
+    if (timeP2P*Ci->NDBODY*Cj->NDBODY > timeM2L) {              // If M2L is faster
       M2L(Ci,Cj,mutual);                                        //  M2L kernel
       count(NM2L);                                              //  Increment M2L counter
     } else {                                                    // Else if P2P is faster
       for (C_iter cj=Cj0+Cj->CHILD; cj!=Cj0+Cj->CHILD+Cj->NCHILD; cj++ ) {
         traverse(Ci,cj,mutual);
       }
-    } else if (Ci->NDLEAF + Cj->NDLEAF >= NSPAWN || (mutual && Ci == Cj)) {
+    } else if (Ci->NDBODY + Cj->NDBODY >= NSPAWN || (mutual && Ci == Cj)) {
       traverse(Ci0+Ci->CHILD, Ci0+Ci->CHILD+Ci->NCHILD,
                Cj0+Cj->CHILD, Cj0+Cj->CHILD+Cj->NCHILD, mutual);
     } else if (Ci->RCRIT >= Cj->RCRIT) {
   void setCenter(C_iter C) const {
     real_t m = 0;                                               // Initialize mass
     vec3 X = 0;                                                 // Initialize coordinates
-    for (B_iter B=C->LEAF; B!=C->LEAF+C->NCLEAF; B++) {         // Loop over leafs
+    for (B_iter B=C->BODY; B!=C->BODY+C->NCBODY; B++) {         // Loop over bodies
       m += B->SRC;                                              //  Accumulate mass
       X += B->X * B->SRC;                                       //  Accumulate dipole
-    }                                                           // End loop over leafs
+    }                                                           // End loop over bodies
     for (C_iter c=Cj0+C->CHILD; c!=Cj0+C->CHILD+C->NCHILD; c++) {// Loop over child cells
       m += std::abs(c->M[0]);                                   //  Accumulate mass
       X += c->X * std::abs(c->M[0]);                            //  Accumulate dipole
 #endif
       if (R2 > (Ci->RCRIT+Cj->RCRIT)*(Ci->RCRIT+Cj->RCRIT)) {   //  If distance is far enough
         approximate(Ci,Cj,mutual);                              //   Use approximate kernels
-      } else if (Ci->NCHILD == 0 && Cj->NCHILD == 0) {          //  Else if both cells are leafs
-        if (Cj->NCLEAF == 0) {                                  //   If the leafs weren't sent from remote node
+      } else if (Ci->NCHILD == 0 && Cj->NCHILD == 0) {          //  Else if both cells are bodies
+        if (Cj->NCBODY == 0) {                                  //   If the bodies weren't sent from remote node
           approximate(Ci,Cj,mutual);                            //    Use approximate kernels
-        } else {                                                //   Else if the leafs were sent
+        } else {                                                //   Else if the bodies were sent
           if (Ci == Cj) {                                       //    If source and target are same
             P2P(Ci);                                            //     P2P kernel for single cell
           } else {                                              //    Else if source and target are different
             P2P(Ci,Cj,mutual);                                  //     P2P kernel for pair of cells
           }                                                     //    End if for same source and target
           count(NP2P);                                          //    Increment P2P counter
-        }                                                       //   End if for leafs
-      } else {                                                  //  Else if cells are close but not leafs
+        }                                                       //   End if for bodies
+      } else {                                                  //  Else if cells are close but not bodies
         splitCell(Ci,Cj,mutual);                                //   Split cell and call function recursively for child
       }                                                         //  End if for multipole acceptance
     }                                                           // End if for same level cells
     cells.resize(2);
     C_iter Ci = cells.begin(), Cj = cells.begin()+1;
     Ci->X = 0;
-    Ci->NDLEAF = 10;
-    Ci->LEAF = ibodies.begin();
+    Ci->NDBODY = 10;
+    Ci->BODY = ibodies.begin();
     Ci->M = 0;
     Ci->L = 0;
     Cj->X = 1;
-    Cj->NDLEAF = 1000;
-    Cj->LEAF = jbodies.begin();
+    Cj->NDBODY = 1000;
+    Cj->BODY = jbodies.begin();
     Cj->M = 0;
     startTimer("P2P kernel");
     P2P(Ci,Cj,false);
 typedef std::map<pthread_t,int>                ThreadMap;       //!< Map of pthread id to thread id
 typedef std::queue<Trace>                      Traces;          //!< Queue of traces
 typedef std::map<std::string,double>           Timer;           //!< Map of timer event name to timed value
-typedef std::map<std::string,double>::iterator TI_iter;         //!< Iterator of timer event name map
+typedef std::map<std::string,double>::iterator T_iter;          //!< Iterator of timer event name map
 
 //! Timer and Trace logger
 class Logger {
 
 //! Print timings of all events
   inline void printAllTime() {
-    for (TI_iter E=timer.begin(); E!=timer.end(); E++) {        // Loop over all events
+    for (T_iter E=timer.begin(); E!=timer.end(); E++) {         // Loop over all events
       std::cout << std::setw(stringLength) << std::left         //  Set format
                 << E->first << " : " << E->second << std::endl; //  Print event and timer
     }                                                           // End loop over all events
 
 //! Write timings of all events
   inline void writeTime() {
-    for (TI_iter E=timer.begin(); E!=timer.end(); E++) {        // Loop over all events
+    for (T_iter E=timer.begin(); E!=timer.end(); E++) {        // Loop over all events
       timerFile << std::setw(stringLength) << std::left         //  Set format
                 << E->first << " " << E->second << std::endl;   //  Print event and timer
     }                                                           // End loop over all events

include/parallelfmm.h

 //! Add cells to send buffer
   void addSendCell(C_iter C, int &iparent, int &icell) {
     Cell cell(*C);                                              // Initialize send cell
-    cell.NCHILD = cell.NCLEAF = cell.NDLEAF = 0;                // Reset counters
+    cell.NCHILD = cell.NCBODY = cell.NDBODY = 0;                // Reset counters
     cell.PARENT = iparent;                                      // Index of parent
     sendCells.push_back(cell);                                  // Push to send cell vector
     icell++;                                                    // Increment cell counter
 //! Add bodies to send buffer
   void addSendBody(C_iter C, int &ibody, int icell) {
     C_iter Csend = sendCells.begin() + sendCellDispl[IRANK] + icell;// Get send cell iterator
-    Csend->NCLEAF = C->NCLEAF;                                  // Set number of bodies
-    Csend->NDLEAF = ibody;                                      // Set body index per rank
-    for (B_iter B=C->LEAF; B!=C->LEAF+C->NCLEAF; B++) {         // Loop over bodies in cell
+    Csend->NCBODY = C->NCBODY;                                  // Set number of bodies
+    Csend->NDBODY = ibody;                                      // Set body index per rank
+    for (B_iter B=C->BODY; B!=C->BODY+C->NCBODY; B++) {         // Loop over bodies in cell
       sendBodies.push_back(*B);                                 //  Push to send body vector
       sendBodies.back().IPROC = IRANK;                          //  Set current rank
     }                                                           // End loop over bodies in cell
-    ibody+=C->NCLEAF;                                           // Increment body counter
+    ibody+=C->NCBODY;                                           // Increment body counter
   }
 
 //! Determine which cells to send
         localXmin = rankXmin[IRANK];                            //   Set local Xmin for IRANK
         localXmax = rankXmax[IRANK];                            //   Set local Xmax for IRANK
         Cell cell(*Cj0);                                        //   Send root cell
-        cell.NCHILD = cell.NCLEAF = cell.NDLEAF = 0;            //   Reset link to children and leafs
+        cell.NCHILD = cell.NCBODY = cell.NDBODY = 0;            //   Reset link to children and bodies
         sendCells.push_back(cell);                              //   Push it into send buffer
         CellQueue cellQueue;                                    //   Traversal queue
         cellQueue.push(Cj0);                                    //   Push root to traversal queue
     startTimer("Get LET");                                      // Start timer
     for( int i=recvCellCount[irank]-1; i>=0; i-- ) {            // Loop over receive cells
       C_iter C = recvCells.begin() + recvCellDispl[irank] + i;  //  Iterator of receive cell
-      if (C->NCLEAF != 0) {                                     //  If cell has leafs
-        C->LEAF = recvBodies.begin() + recvBodyDispl[irank] + C->NDLEAF;// Iterator of first leaf
-        C->NDLEAF = C->NCLEAF;                                  //   Initialize number of leafs
-      }                                                         //  End if for leafs
+      if (C->NCBODY != 0) {                                     //  If cell has bodies
+        C->BODY = recvBodies.begin() + recvBodyDispl[irank] + C->NDBODY;// Iterator of first body
+        C->NDBODY = C->NCBODY;                                  //   Initialize number of bodies
+      }                                                         //  End if for bodies
       if (i != 0) {                                             //  If cell is not root
         C_iter Cparent = recvCells.begin() + recvCellDispl[irank] + C->PARENT;// Iterator of parent cell
-        Cparent->NDLEAF += C->NDLEAF;                           //   Accululate number of leafs
+        Cparent->NDBODY += C->NDBODY;                           //   Accululate number of bodies
       }                                                         //  End if for root cell
     }                                                           // End loop over receive cells
     cells.resize(recvCellCount[irank]);                         // Resize cell vector for LET

include/serialfmm.h

   void direct(Bodies &ibodies, Bodies &jbodies) {
     Cells cells(2);                                             // Define a pair of cells to pass to P2P kernel
     C_iter Ci = cells.begin(), Cj = cells.begin()+1;            // First cell is target, second cell is source
-    Ci->LEAF = ibodies.begin();                                 // Iterator of first target leaf
-    Ci->NDLEAF = ibodies.size();                                // Number of target leafs
-    Cj->LEAF = jbodies.begin();                                 // Iterator of first source leaf
-    Cj->NDLEAF = jbodies.size();                                // Number of source leafs
+    Ci->BODY = ibodies.begin();                                 // Iterator of first target body
+    Ci->NDBODY = ibodies.size();                                // Number of target bodies
+    Cj->BODY = jbodies.begin();                                 // Iterator of first source body
+    Cj->NDBODY = jbodies.size();                                // Number of source bodies
     int prange = 0;                                             // Range of periodic images
     for (int i=0; i<IMAGES; i++) {                              // Loop over periodic image sublevels
       prange += int(powf(3,i));                                 //  Accumulate range of periodic images

include/treebuilder.h

 private:
 //! Binary tree is used for counting number of bodies with a recursive approach
   struct BinaryTreeNode {
-    ivec8            NLEAF;                                     //!< Number of descendant leafs
+    ivec8            NBODY;                                     //!< Number of descendant bodies
     BinaryTreeNode * LEFT;                                      //!< Pointer to left child
     BinaryTreeNode * RIGHT;                                     //!< Pointer to right child
     BinaryTreeNode * BEGIN;                                     //!< Pointer to begining of memory space
 
 //! Octree is used for building the FMM tree structure as "nodes", then transformed to "cells" data structure
   struct OctreeNode {
-    int          LEAF;                                          //!< Index offset for first leaf in node
-    int          NLEAF;                                         //!< Number of descendant leafs
+    int          BODY;                                          //!< Index offset for first body in node
+    int          NBODY;                                         //!< Number of descendant bodies
     int          NNODE;                                         //!< Number of descendant nodes
     OctreeNode * CHILD[8];                                      //!< Pointer to child node
     vec3         X;                                             //!< Coordinate at center
   fvec3  localXmax;                                             //!< Local Xmax for a given rank
 
 public:
-  int NCRIT;                                                    //!< Number of bodies per leaf cell
+  int NCRIT;                                                    //!< Number of bodies per body cell
 
 private:
 //! Get number of binary tree nodes for a given number of bodies
 //! Create an octree node
   OctreeNode * makeOctNode(int begin, int end, vec3 X, bool nochild) const {
     OctreeNode * octNode = new OctreeNode();                    // Allocate memory for single node
-    octNode->LEAF = begin;                                      // Index of first body in node
-    octNode->NLEAF = end - begin;                               // Number of bodies in node
+    octNode->BODY = begin;                                      // Index of first body in node
+    octNode->NBODY = end - begin;                               // Number of bodies in node
     octNode->NNODE = 1;                                         // Initialize counter for decendant nodes
     octNode->X = X;                                             // Center position of node
     if (nochild) {                                              // If node has no children
   void countBodies(Bodies& bodies, int begin, int end, vec3 X, BinaryTreeNode * binNode) {
     assert(getNumBinNode(end - begin) <= binNode->END - binNode->BEGIN + 1);
     if (end - begin <= NSPAWN) {                                // If number of bodies is less than threshold
-      for (int i=0; i<8; i++) binNode->NLEAF[i] = 0;            //  Initialize number of bodies in octant
+      for (int i=0; i<8; i++) binNode->NBODY[i] = 0;            //  Initialize number of bodies in octant
       binNode->LEFT = binNode->RIGHT = NULL;                    //  Initialize pointers to left and right child node
       for (int i=begin; i<end; i++) {                           //  Loop over bodies in node
         vec3 x = bodies[i].X;                                   //   Position of body
         int octant = (x[0] > X[0]) + ((x[1] > X[1]) << 1) + ((x[2] > X[2]) << 2);// Which octant body belongs to
-        binNode->NLEAF[octant]++;                               //   Increment body count in octant
+        binNode->NBODY[octant]++;                               //   Increment body count in octant
       }                                                         //  End loop over bodies in node
     } else {                                                    // Else if number of bodies is larger than threshold
       int mid = (begin + end) / 2;                              //  Split range of bodies in half
       });                                                       //  Close lambda expression
       countBodies(bodies, mid, end, X, binNode->RIGHT);         //  Recursive call for right branch
       __sync_tasks__;                                           //  Synchronize tasks
-      binNode->NLEAF = binNode->LEFT->NLEAF + binNode->RIGHT->NLEAF;// Sum contribution from both branches
+      binNode->NBODY = binNode->LEFT->NBODY + binNode->RIGHT->NBODY;// Sum contribution from both branches
     }                                                           // End if for number of bodies
   }
 
       spawn_task2(bodies, buffer, {                             //  Spawn new task using Intel TBB or MTHREAD
         moveBodies(bodies, buffer, begin, mid, binNode->LEFT, octantOffset, X);// Recursive call for left branch
       });                                                       //  Close lambda expression
-      octantOffset += binNode->LEFT->NLEAF;                     //  Increment the octant offset for right branch
+      octantOffset += binNode->LEFT->NBODY;                     //  Increment the octant offset for right branch
       moveBodies(bodies, buffer, mid, end, binNode->RIGHT, octantOffset, X);// Recursive call for right branch
       __sync_tasks__;                                           //  Synchronize tasks
     }                                                           // End if for child existance
     }                                                           // End if for number of bodies
     OctreeNode * octNode = makeOctNode(begin, end, X, false);   // Create an octree node with child nodes
     countBodies(bodies, begin, end, X, binNode);                // Count bodies in each octant using binary recursion
-    ivec8 octantOffset = exclusiveScan(binNode->NLEAF, begin);  // Exclusive scan to obtain offset from octant count
+    ivec8 octantOffset = exclusiveScan(binNode->NBODY, begin);  // Exclusive scan to obtain offset from octant count
     moveBodies(bodies, buffer, begin, end, binNode, octantOffset, X);// Sort bodies according to octant
     BinaryTreeNode * binNodeOffset = binNode->BEGIN;            // Initialize pointer offset for binary tree nodes
     __init_tasks__;                                             // Initialize tasks
     for (int i=0; i<8; i++) {                                   // Loop over children
-      int maxBinNode = getMaxBinNode(binNode->NLEAF[i]);        //  Get maximum number of binary tree nodes
+      int maxBinNode = getMaxBinNode(binNode->NBODY[i]);        //  Get maximum number of binary tree nodes
       assert(binNodeOffset + maxBinNode <= binNode->END);
       spawn_task2(buffer, bodies, {                             //  Spawn new task using Intel TBB or MTHREAD
         vec3 Xchild = X;                                        //   Initialize center position of child node
         binNodeChild->BEGIN = binNodeOffset;                    //   Assign first memory address from offset
         binNodeChild->END = binNodeOffset + maxBinNode;         //   Keep track of last memory address
         octNode->CHILD[i] = buildNodes(buffer, bodies,          //   Recursive call for each child
-          octantOffset[i], octantOffset[i] + binNode->NLEAF[i], //   Range of bodies is calcuated from octant offset
+          octantOffset[i], octantOffset[i] + binNode->NBODY[i], //   Range of bodies is calcuated from octant offset
           binNodeChild, Xchild, level+1, !direction);           //   Alternate copy direction bodies <-> buffer
       });                                                       //  Close lambda expression
       binNodeOffset += maxBinNode;                              //  Increment offset for binNode memory address
     C->PARENT = iparent;                                        // Index of parent cell
     C->R      = localRadius / (1 << level);                     // Cell radius
     C->X      = octNode->X;                                     // Cell center
-    C->NDLEAF = octNode->NLEAF;                                 // Number of decendant leafs
-    C->LEAF   = B0 + octNode->LEAF;                             // Iterator of first body in cell
+    C->NDBODY = octNode->NBODY;                                 // Number of decendant bodies
+    C->BODY   = B0 + octNode->BODY;                             // Iterator of first body in cell
     if (octNode->NNODE == 1) {                                  // If node has no children
       C->CHILD  = 0;                                            //  Set index of first child cell to zero
       C->NCHILD = 0;                                            //  Number of child cells
-      C->NCLEAF = octNode->NLEAF;                               //  Number of bodies in cell
-      assert(C->NCLEAF > 0);
+      C->NCBODY = octNode->NBODY;                               //  Number of bodies in cell
+      assert(C->NCBODY > 0);
       MAXLEVEL = std::max(MAXLEVEL,level);                      //  Update maximum level of tree
     } else {                                                    // Else if node has children
-      C->NCLEAF = 0;                                            //  Set number of bodies in cell to zero
+      C->NCBODY = 0;                                            //  Set number of bodies in cell to zero
       int nchild = 0;                                           //  Initialize number of child cells
       int octants[8];                                           //  Map of child index to octants (for when nchild < 8)
       for (int i=0; i<8; i++) {                                 //  Loop over octants
 
   void printTreeData(Cells &cells) {
     std::cout << "----------------------------------" << std::endl;
-    std::cout << "Bodies               : " << cells.front().NDLEAF << std::endl;
+    std::cout << "Bodies               : " << cells.front().NDBODY << std::endl;
     std::cout << "Cells                : " << cells.size() << std::endl;
     std::cout << "Tree depth           : " << MAXLEVEL << std::endl;
 #if COUNT
 //! Structure of cells
 struct Cell {
   int       NCHILD;                                             //!< Number of child cells
-  int       NCLEAF;                                             //!< Number of child leafs
-  int       NDLEAF;                                             //!< Number of descendant leafs
+  int       NCBODY;                                             //!< Number of child bodies
+  int       NDBODY;                                             //!< Number of descendant bodies
   int       PARENT;                                             //!< Index of parent cell
   int       CHILD;                                              //!< Index of child cells
   long long ICELL;                                              //!< Cell index
-  B_iter    LEAF;                                               //!< Iterator of first leaf
+  B_iter    BODY;                                               //!< Iterator of first body
   vec3      X;                                                  //!< Cell center
   real_t    R;                                                  //!< Cell radius
   real_t    RMAX;                                               //!< Max cell radius

kernels/LaplaceCartesianCPU.cxx

 #endif
 
 void Kernel::P2P(C_iter Ci, C_iter Cj, bool mutual) const {
-  B_iter Bi = Ci->LEAF;
-  B_iter Bj = Cj->LEAF;
-  int ni = Ci->NDLEAF;
-  int nj = Cj->NDLEAF;
+  B_iter Bi = Ci->BODY;
+  B_iter Bj = Cj->BODY;
+  int ni = Ci->NDBODY;
+  int nj = Cj->NDBODY;
   int i = 0;
 #if __AVX__
   for ( ; i<=ni-8; i+=8) {
 }
 
 void Kernel::P2P(C_iter C) const {
-  B_iter B = C->LEAF;
-  int n = C->NDLEAF;
+  B_iter B = C->BODY;
+  int n = C->NDBODY;
   int i = 0;
 #if __AVX__
   for ( ; i<=n-8; i+=8) {
 }
 
 void Kernel::P2M(C_iter C, real_t &Rmax) const {
-  for (B_iter B=C->LEAF; B!=C->LEAF+C->NCLEAF; B++) {
+  for (B_iter B=C->BODY; B!=C->BODY+C->NCBODY; B++) {
     vec3 dX = C->X - B->X;
     real_t R = std::sqrt(norm(dX));
     if (R > Rmax) Rmax = R;
 }
 
 void Kernel::L2P(C_iter Ci) const {
-  for (B_iter B=Ci->LEAF; B!=Ci->LEAF+Ci->NCLEAF; B++) {
+  for (B_iter B=Ci->BODY; B!=Ci->BODY+Ci->NCBODY; B++) {
     vec3 dX = B->X - Ci->X;
     vecL C, L;
     C[0] = 1;