#include #include #include #include #include using namespace std; void init(int* array,int length){ srand((unsigned)time(0)); for(int i=0;iarray[i+1]){ cout << "array[" << i << "] > array[" << i+1 << "]" << endl; return false; } } return true; } int main(int argc, char *argv[]){ int length; int *toBeSorted; double t1,t2; if(argc < 2){ length=6000000; }else{ length=atoi(argv[1]); } toBeSorted = new int[length]; init(toBeSorted, length); cout << "Sorting an array of " << length << " elements." << endl; t1=omp_get_wtime(); #pragma omp parallel #pragma omp single { quicksort(toBeSorted,0,length-1); } t2=omp_get_wtime()-t1; cout << "quicksort took " << t2 << " sec. to complete" << endl; if (!checkFn(toBeSorted, length)) { cout << "validation failed!" << endl; } delete [] toBeSorted; }