41 #if (defined(NAMD_CUDA) || defined(NAMD_HIP) || defined(NAMD_AVXTILES))
63 BigReal xmin, ymin, zmin, xmax, ymax, zmax;
73 for (
int i=begin+1; i<end; ++i ) {
75 if ( pos.
x < xmin ) { xmin = pos.
x; }
76 if ( pos.
y < ymin ) { ymin = pos.
y; }
77 if ( pos.
z < zmin ) { zmin = pos.
z; }
78 if ( pos.
x > xmax ) { xmax = pos.
x; }
79 if ( pos.
y > ymax ) { ymax = pos.
y; }
80 if ( pos.
z > zmax ) { zmax = pos.
z; }
86 #define NTH_ELEMENT(BEGIN,SPLIT,END,OP) std::nth_element(BEGIN,SPLIT,END,OP)
87 #if (defined(NAMD_CUDA) || defined(NAMD_HIP)) && defined(__GNUC_PATCHLEVEL__)
88 #if __GNUC__ == 4 && __GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ == 2
89 #define NTH_ELEMENT(BEGIN,SPLIT,END,OP) std::sort(BEGIN,END,OP)
90 #warning gcc 4.8.2 std::nth_element would segfault (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58800)
94 if ( xmax >= ymax && xmax >= zmax ) {
96 }
else if ( ymax >= xmax && ymax >= zmax ) {
110 #if (defined(NAMD_CUDA) || defined(NAMD_HIP)) && defined(__GNUC_PATCHLEVEL__)
111 #if __GNUC__ == 4 && __GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ == 2
127 #endif //End of GPU-specific code.
131 int ni,
int nj,
int nk) {
139 for (
int ip=0; ip < ni; ++ip ) {
141 int targi = nai + (natoms - nai - 1) / (ni - ip) + 1;
143 for ( iend=ibegin; iend<nmgrps; ++iend ) {
145 if (nai + mgs <= targi) nai += mgs;
151 for (
int jp=0; jp < nj; ++jp ) {
153 int targj = naj + (nai - naj - 1) / (nj - jp) + 1;
155 for ( jend=jbegin; jend<iend; ++jend ) {
157 if (naj + mgs <= targj) naj += mgs;
164 for (
int kp=0; kp < nk; ++kp ) {
165 int targk = nak + (naj - nak - 1) / (nk - kp) + 1;
167 for ( kend=kbegin; kend<jend; ++kend ) {
169 if (nak + mgs <= targk) nak += mgs;
175 breaks[pid++] = kend;
sortop_x(const FullAtom *atoms)
static void partition(int *order, const FullAtom *atoms, int begin, int end)
static __thread atom * atoms
bool operator()(int i, int j) const
sortop_y(const FullAtom *atoms)
void sortAtomsForCUDA(int *order, const FullAtom *atoms, int nfree, int n)
sortop_base(const FullAtom *atoms)
#define NTH_ELEMENT(BEGIN, SPLIT, END, OP)
std::vector< std::string > split(const std::string &text, std::string delimiter)
BlockRadixSort::TempStorage sort
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)