apply fix for merge sort from issue #1163 by @jtfrey and re-enable it

This commit is contained in:
Axel Kohlmeyer 2018-10-23 08:57:33 -04:00
parent 527ec61586
commit da38ae0370
2 changed files with 5 additions and 8 deletions

View File

@ -46,13 +46,6 @@
#define PRId64 "ld"
#endif
// favor qsort over mergesort for stable release
// TODO: to be removed after stable release
#ifndef LMP_QSORT
#define LMP_QSORT
#endif
namespace LAMMPS_NS {
// enum used for KOKKOS host/device flags

View File

@ -98,7 +98,7 @@ static void merge_sort(int *index, int num, void *ptr,
int *tmp = dest; dest = hold; hold = tmp;
// merge from hold array to destiation array
// merge from hold array to destination array
for (i=0; i < num-1; i += 2*chunk) {
j = i + 2*chunk;
@ -107,6 +107,10 @@ static void merge_sort(int *index, int num, void *ptr,
if (m > num) m=num;
do_merge(dest,hold,i,m,m,j,ptr,comp);
}
// copy all indices not handled by the chunked merge sort loop
for ( ; i < num ; i++ ) dest[i] = hold[i];
chunk *= 2;
}