Skip to content
Snippets Groups Projects
Commit 8b7d0b08 authored by Azka Nabilah Mumtaz's avatar Azka Nabilah Mumtaz
Browse files

tes

parent 6b4764ba
No related merge requests found
......@@ -3,14 +3,14 @@
#include "radix_sort_parallel.h"
__global__ void getMax(int *arr, int *max, int n) {
int index = threadIdx.x;
int stride = blockDim.x;
int mx = arr[index];
//int index = threadIdx.x;
//int stride = blockDim.x;
int mx = arr[0];
for (int i = index+stride; i < n; i+=stride)
for (int i = 0; i < n; i++)
if (arr[i] > mx)
mx = arr[i];
max[index] = mx;
max[0] = mx;
}
__global__ void countSort(int *arr, int n, int exp) {
......@@ -55,13 +55,6 @@ void radix_sort(int arr[], int n)
// Transfer data back to host memory
cudaMemcpy(max, d_max, n * sizeof(int), cudaMemcpyDeviceToHost);
int maks = max[0];
for (int i = 0; i < n; i++) {
if (maks < max[i]) {
maks = max[i];
}
}
for (int exp = 1; max[0]/exp > 0; exp *= 10) {
countSort<<<1, 500>>>(d_arr, n, exp);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment