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 111 of file SortAtoms.C.

References atoms, and partition().

Referenced by HomePatch::positionsReady().

00111                                                                            {
00112 
00113   // partition free atoms
00114   // CkPrintf("%d %d\n", 0, nfree);
00115   partition(order, atoms, 0, nfree);
00116 
00117   // partition fixed atoms
00118   // CkPrintf("%d %d\n", nfree, n);
00119   partition(order, atoms, nfree, n);
00120 
00121 }

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

Definition at line 123 of file SortAtoms.C.

References atoms.

Referenced by WorkDistrib::createAtomLists().

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


Generated on Sat Nov 18 01:17:17 2017 for NAMD by  doxygen 1.4.7