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

tes

parent 762ca23d
Branches
No related merge requests found
...@@ -3,12 +3,31 @@ ...@@ -3,12 +3,31 @@
#include "radix_sort_parallel.h" #include "radix_sort_parallel.h"
__global__ void getMax(int *arr, int *max, int n) { __global__ void getMax(int *arr, int *max, int n) {
int mx = arr[0]; __shared__ int cache[1000];
int temp = arr[0];
for (int i=0; i<n; i+=1000){
if(threadIdx.x< 1000){
if(temp < arr[threadIdx.x + i]){
temp = arr[threadIdx.x+i];
}
}
}
for (int i = 0; i < n; i++) if(threadIdx.x <1000){
if (arr[i] > mx) cache[threadIdx.x] =temp;
mx = arr[i]; }
max[0] = mx;
__syncthreads();
if(threadIdx.x ==0){
*max = cache[0];
for(int i =1; i<1000; i++){
if(*max < cache[i]){
*max = cache[i];
}
}
}
} }
__global__ void countSort(int *arr, int n, int exp) { __global__ void countSort(int *arr, int n, int 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