NAMD
Functions
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().

119  {
120 
121  // partition free atoms
122  // CkPrintf("%d %d\n", 0, nfree);
123  partition(order, atoms, 0, nfree);
124 
125  // partition fixed atoms
126  // CkPrintf("%d %d\n", nfree, n);
127  partition(order, atoms, nfree, n);
128 
129 }
static void partition(int *order, const FullAtom *atoms, int begin, int end)
Definition: SortAtoms.C:41
#define order
Definition: PmeRealSpace.C:235
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().

133  {
134 
135 //CkPrintf("sorting %d atoms in %d groups to %d x %d x %d\n",
136 // natoms, nmgrps, nk, nj, ni);
137  std::sort(order, order+nmgrps, sortop_z(atoms));
138  int pid = 0;
139  int ibegin = 0;
140  int nai = 0;
141  for ( int ip=0; ip < ni; ++ip ) {
142  int naj = nai;
143  int targi = nai + (natoms - nai - 1) / (ni - ip) + 1;
144  int iend;
145  for ( iend=ibegin; iend<nmgrps; ++iend ) {
146  int mgs = atoms[order[iend]].migrationGroupSize;
147  if (nai + mgs <= targi) nai += mgs;
148  else break;
149  }
150 //CkPrintf(" Z %d %d (%d) %d\n", ibegin, iend, iend-ibegin, nai);
151  std::sort(order+ibegin, order+iend, sortop_y(atoms));
152  int jbegin = ibegin;
153  for ( int jp=0; jp < nj; ++jp ) {
154  int nak = naj;
155  int targj = naj + (nai - naj - 1) / (nj - jp) + 1;
156  int jend;
157  for ( jend=jbegin; jend<iend; ++jend ) {
158  int mgs = atoms[order[jend]].migrationGroupSize;
159  if (naj + mgs <= targj) naj += mgs;
160  else break;
161  }
162 
163 //CkPrintf(" Y %d %d (%d) %d\n", jbegin, jend, jend-jbegin, naj);
164  std::sort(order+jbegin, order+jend, sortop_x(atoms));
165  int kbegin = jbegin;
166  for ( int kp=0; kp < nk; ++kp ) {
167  int targk = nak + (naj - nak - 1) / (nk - kp) + 1;
168  int kend;
169  for ( kend=kbegin; kend<jend; ++kend ) {
170  int mgs = atoms[order[kend]].migrationGroupSize;
171  if (nak + mgs <= targk) nak += mgs;
172  else break;
173 //CkPrintf(" atom %d %d %.2f\n", atoms[order[kend]].id, mgs,
174 // atoms[order[kend]].position.x);
175  }
176 //CkPrintf(" X %d %d (%d) %d\n", kbegin, kend, kend-kbegin, nak);
177  breaks[pid++] = kend;
178  kbegin = kend;
179  }
180  jbegin = jend;
181  }
182  ibegin = iend;
183  }
184 
185 }
#define order
Definition: PmeRealSpace.C:235
int migrationGroupSize
Definition: NamdTypes.h:117
BlockRadixSort::TempStorage sort