SortAtoms.h File Reference

Go to the source code of this file.

Functions

void sortAtomsForCUDA (int *order, const FullAtom *atoms, int nfree, int n)
void sortAtomsForPatches (int *order, int *breaks, const FullAtom *atoms, int nmgrps, int natoms, int ni, int nj, int nk)

Function Documentation

void sortAtomsForCUDA ( int *  order,
const FullAtom atoms,
int  nfree,
int  n 
)

Definition at line 119 of file SortAtoms.C.

References partition().

Referenced by HomePatch::positionsReady().

00119                                                                            {
00120 
00121   // partition free atoms
00122   // CkPrintf("%d %d\n", 0, nfree);
00123   partition(order, atoms, 0, nfree);
00124 
00125   // partition fixed atoms
00126   // CkPrintf("%d %d\n", nfree, n);
00127   partition(order, atoms, nfree, n);
00128 
00129 }

void sortAtomsForPatches ( int *  order,
int *  breaks,
const FullAtom atoms,
int  nmgrps,
int  natoms,
int  ni,
int  nj,
int  nk 
)

Definition at line 131 of file SortAtoms.C.

References FullAtom::migrationGroupSize, and sort.

Referenced by WorkDistrib::createAtomLists().

00133                                                  {
00134 
00135 //CkPrintf("sorting %d atoms in %d groups to %d x %d x %d\n",
00136 //    natoms, nmgrps, nk, nj, ni);
00137   std::sort(order, order+nmgrps, sortop_z(atoms));
00138   int pid = 0;
00139   int ibegin = 0;
00140   int nai = 0;
00141   for ( int ip=0; ip < ni; ++ip ) {
00142     int naj = nai;
00143     int targi = nai + (natoms - nai - 1) / (ni - ip) + 1;
00144     int iend;
00145     for ( iend=ibegin; iend<nmgrps; ++iend ) { 
00146       int mgs = atoms[order[iend]].migrationGroupSize;
00147       if (nai + mgs <= targi) nai += mgs;
00148       else break;
00149     }
00150 //CkPrintf("  Z %d %d (%d) %d\n", ibegin, iend, iend-ibegin, nai);
00151     std::sort(order+ibegin, order+iend, sortop_y(atoms));
00152     int jbegin = ibegin;
00153     for ( int jp=0; jp < nj; ++jp ) {
00154       int nak = naj;
00155       int targj = naj + (nai - naj - 1) / (nj - jp) + 1;
00156       int jend;
00157       for ( jend=jbegin; jend<iend; ++jend ) { 
00158         int mgs = atoms[order[jend]].migrationGroupSize;
00159         if (naj + mgs <= targj) naj += mgs;
00160         else break;
00161       }
00162 
00163 //CkPrintf("    Y %d %d (%d) %d\n", jbegin, jend, jend-jbegin, naj);
00164       std::sort(order+jbegin, order+jend, sortop_x(atoms));
00165       int kbegin = jbegin;
00166       for ( int kp=0; kp < nk; ++kp ) {
00167         int targk = nak + (naj - nak - 1) / (nk - kp) + 1;
00168         int kend;  
00169         for ( kend=kbegin; kend<jend; ++kend ) {
00170           int mgs = atoms[order[kend]].migrationGroupSize;
00171           if (nak + mgs <= targk) nak += mgs;
00172           else break;
00173 //CkPrintf("        atom %d %d %.2f\n", atoms[order[kend]].id, mgs,
00174 //                  atoms[order[kend]].position.x);
00175         }
00176 //CkPrintf("      X %d %d (%d) %d\n", kbegin, kend, kend-kbegin, nak);
00177         breaks[pid++] = kend;
00178         kbegin = kend;
00179       }
00180       jbegin = jend;
00181     }
00182     ibegin = iend;
00183   }
00184 
00185 }


Generated on 13 Aug 2020 for NAMD by  doxygen 1.6.1