My quicksort works fine it outputs correctly but the parallel version does not execute faster than the non parallel version. What else can I do to it to make it run faster?
void quickSort(int arr[], int low, int high)
{
int pi;
if (low < high)
{
//pi is partitioning index, arr[p] is now at right place
pi = partition(arr, low, high);
// Separately sort elements before partition and after partition
quickSort(arr, low, pi - 1);
quickSort(arr, pi + 1, high);
}
}
void quickSort_parallel_omp(int arr[], int low, int high)
{
int pi;
if (low < high)
{
pi = partition(arr, low, high);
omp_set_nested(1);
#pragma omp parallel sections num_threads(Nthreads)
{ //Nthreads is declared in the main as int Nthreads = 4
#pragma omp section
quickSort_parallel_omp(arr, low, pi - 1);
#pragma omp section
quickSort_parallel_omp(arr, pi + 1, high);
}
}
}