diff --git a/src/radix_sort_par.cu b/src/radix_sort_par.cu index ecc6b1814b7c678a37b24bad9fab4e610a324587..a4613c255805dc63210ca3a2a134675fe79e28dd 100644 --- a/src/radix_sort_par.cu +++ b/src/radix_sort_par.cu @@ -18,14 +18,14 @@ __device__ int getMax(int arr[], int n) // the digit represented by exp. __device__ void countSort(int arr[], int n, int exp) { - int index = threadIdx.x; - int stride = blockDim.x; +// int index = threadIdx.x; +// int stride = blockDim.x; int *output= (int*)malloc(sizeof(int)*n); // output array int i, count[10] = {0}; // Store count of occurrences in count[] - for (i = index; i < n; i+=stride) + for (i = 0; i < n; i++) count[ (arr[i]/exp)%10 ]++; // Change count[i] so that count[i] now contains actual @@ -34,7 +34,7 @@ __device__ void countSort(int arr[], int n, int exp) count[i] += count[i - 1]; // Build the output array - for (i = n - 1; i >= index; i-=stride) + for (i = n - 1; i >= 0; i--) { output[count[ (arr[i]/exp)%10 ] - 1] = arr[i]; count[ (arr[i]/exp)%10 ]--; @@ -42,7 +42,7 @@ __device__ void countSort(int arr[], int n, int exp) // Copy the output array to arr[], so that arr[] now // contains sorted numbers according to current digit - for (i = index; i < n; i+=stride) + for (i = 0; i < n; i++) arr[i] = output[i]; }