
// author: N. Matloff

// Rth interface to Thrust sort 

#include <thrust/device_vector.h>
#include <thrust/sort.h>

extern "C" {

#ifdef GPU
#define flouble float
#else
#define flouble double
#endif

void rthsort(flouble *x, int *nx, flouble *xout) 
{  int n = *nx;
   // set up device vector and copy x to it
   thrust::device_vector<flouble> dx(x,x+n);
   // sort, then copy back to x
   thrust::sort(dx.begin(), dx.end());
   thrust::copy(dx.begin(), dx.end(),xout);
}

}

