Skip to content
Snippets Groups Projects
Commit 0d9ffe3e authored by Ghazwan Sihamudin M.'s avatar Ghazwan Sihamudin M.
Browse files

Finished OpenMP Bucket Sort

parent 7f0a49cd
Branches
Tags
No related merge requests found
File added
File added
......@@ -93,20 +93,28 @@ int main(int argc, char** argv) {
int counter;
time_t start_t;
start_t = clock();
int *sorted_array = NULL;
int *arr =(int *)malloc(sizeof(int) * num_element);
#pragma omp parallel for num_threads(thread_count) shared(rand_nums)
int *arr =(int *)malloc(sizeof(int) * num_element);
int *arr_final = (int *)malloc(sizeof(int) * num_element);
int arr_counter = 0;
start_t = clock();
#pragma omp parallel for num_threads(thread_count) shared(rand_nums, arr_counter, arr_final)
for (counter = 1;counter<thread_count;counter++) {
int size_arr ;
make_bucket(rand_nums,arr,&size_arr,num_element,counter,thread_count);
sorted_array = sort_array(arr,size_arr);
print_array(sorted_array, size_arr);
int j = 0;
for(int i = arr_counter; i < arr_counter+size_arr; i++) {
arr_final[i] = sorted_array[j];
j++;
}
arr_counter += size_arr;
}
time_t finish_t = clock();
print_array(arr_final, num_element);
printf("Waktu eksekusi %d data : %d process : %.5f ms\n", num_element, thread_count, (double)(finish_t-start_t)*1000/CLOCKS_PER_SEC);
free(rand_nums);
......
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