13 #if !defined(NAMD_HIP) && !defined(NAMD_CUDA) 68 BigReal xmin, ymin, zmin, xmax, ymax, zmax;
78 for (
int i=begin+1; i<end; ++i ) {
80 if ( pos.
x < xmin ) { xmin = pos.
x; }
81 if ( pos.
y < ymin ) { ymin = pos.
y; }
82 if ( pos.
z < zmin ) { zmin = pos.
z; }
83 if ( pos.
x > xmax ) { xmax = pos.
x; }
84 if ( pos.
y > ymax ) { ymax = pos.
y; }
85 if ( pos.
z > zmax ) { zmax = pos.
z; }
91 #define NTH_ELEMENT(BEGIN,SPLIT,END,OP) std::nth_element(BEGIN,SPLIT,END,OP) 92 #if (defined(NAMD_CUDA) || defined(NAMD_HIP)) && defined(__GNUC_PATCHLEVEL__) 93 #if __GNUC__ == 4 && __GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ == 2 94 #define NTH_ELEMENT(BEGIN,SPLIT,END,OP) std::sort(BEGIN,END,OP) 95 #warning gcc 4.8.2 std::nth_element would segfault (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58800) 99 if ( xmax >= ymax && xmax >= zmax ) {
101 }
else if ( ymax >= xmax && ymax >= zmax ) {
117 #if (defined(NAMD_CUDA) || defined(NAMD_HIP)) && defined(__GNUC_PATCHLEVEL__) 118 #if __GNUC__ == 4 && __GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ == 2 136 const FullAtom *atoms,
int nmgrps,
int natoms,
137 int ni,
int nj,
int nk) {
145 for (
int ip=0; ip < ni; ++ip ) {
147 int targi = nai + (natoms - nai - 1) / (ni - ip) + 1;
149 for ( iend=ibegin; iend<nmgrps; ++iend ) {
151 if (nai + mgs <= targi) nai += mgs;
157 for (
int jp=0; jp < nj; ++jp ) {
159 int targj = naj + (nai - naj - 1) / (nj - jp) + 1;
161 for ( jend=jbegin; jend<iend; ++jend ) {
163 if (naj + mgs <= targj) naj += mgs;
170 for (
int kp=0; kp < nk; ++kp ) {
171 int targk = nak + (naj - nak - 1) / (nk - kp) + 1;
173 for ( kend=kbegin; kend<jend; ++kend ) {
175 if (nak + mgs <= targk) nak += mgs;
181 breaks[pid++] = kend;
197 const double *
const a;
200 return (
a[i] <
a[j] );
204 #define NORMAL_SPLIT 32 206 #define FINAL_SPLIT 16 208 #define FINAL_SPLIT 8 211 int * __restrict
order,
212 const double * __restrict ax,
213 const double * __restrict ay,
214 const double * __restrict az,
234 while (
split == -1) {
235 if ( begin/split_factor < (end-1)/split_factor ) {
236 split = ((begin + end + split_factor) / (split_factor*2)) * split_factor;
239 if (split_factor == 1)
return;
243 BigReal xmin, ymin, zmin, xmax, ymax, zmax;
254 int i =
order[begin];
263 for (
int i=begin+1; i<end; ++i ) {
266 if ( pos.
x < xmin ) { xmin = pos.
x; }
267 if ( pos.
y < ymin ) { ymin = pos.
y; }
268 if ( pos.
z < zmin ) { zmin = pos.
z; }
269 if ( pos.
x > xmax ) { xmax = pos.
x; }
270 if ( pos.
y > ymax ) { ymax = pos.
y; }
271 if ( pos.
z > zmax ) { zmax = pos.
z; }
274 if ( ax[j] < xmin ) { xmin = ax[j]; }
275 if ( ax[j] > xmax ) { xmax = ax[j]; }
276 if ( ay[j] < ymin ) { ymin = ay[j]; }
277 if ( ay[j] > ymax ) { ymax = ay[j]; }
278 if ( az[j] < zmin ) { zmin = az[j]; }
279 if ( az[j] > zmax ) { zmax = az[j]; }
287 #define NTH_ELEMENT(BEGIN,SPLIT,END,OP) std::nth_element(BEGIN,SPLIT,END,OP) 288 #if (defined(NAMD_CUDA) || defined(NAMD_HIP)) && defined(__GNUC_PATCHLEVEL__) 289 #if __GNUC__ == 4 && __GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ == 2 290 #define NTH_ELEMENT(BEGIN,SPLIT,END,OP) std::sort(BEGIN,END,OP) 291 #warning gcc 4.8.2 std::nth_element would segfault (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58800) 295 if ( xmax >= ymax && xmax >= zmax ) {
297 }
else if ( ymax >= xmax && ymax >= zmax ) {
311 #if (defined(NAMD_CUDA) || defined(NAMD_HIP)) && defined(__GNUC_PATCHLEVEL__) 312 #if __GNUC__ == 4 && __GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ == 2 318 int * __restrict
order,
319 int * __restrict unorder,
320 const double * __restrict ax,
321 const double * __restrict ay,
322 const double * __restrict az,
335 for (
int i=0; i < n; i++) {
336 unorder[
order[i]] = i;
sortop_x(const FullAtom *atoms)
static void partition_SOA(int *__restrict order, const double *__restrict ax, const double *__restrict ay, const double *__restrict az, int begin, int end)
static void partition(int *order, const FullAtom *atoms, int begin, int end)
sortop_y(const FullAtom *atoms)
bool operator()(int i, int j) const
void sortAtomsForCUDA(int *order, const FullAtom *atoms, int nfree, int n)
bool operator()(int i, int j) const
sortop_base(const FullAtom *atoms)
#define NTH_ELEMENT(BEGIN, SPLIT, END, OP)
void sortAtomsForCUDA_SOA(int *__restrict order, int *__restrict unorder, const double *__restrict ax, const double *__restrict ay, const double *__restrict az, int nfree, int n)
std::vector< std::string > split(const std::string &text, std::string delimiter)
bool operator()(int i, int j) const
bool operator()(int i, int j) const
void sortAtomsForPatches(int *order, int *breaks, const FullAtom *atoms, int nmgrps, int natoms, int ni, int nj, int nk)
sortop_z(const FullAtom *atoms)
sortop_SOA(const double *r)