// // This is an OpenMP test/demonstration program // Written by Christoph Federrath, 2016 // #include #include #include //#include #include using namespace std; /** ----------------------------- Main ------------------------------- ** OMP_TEST main procedure ** ------------------------------------------------------------------ */ int main(int argc, char *argv[]) { cout << "*------------------- OMP_TEST -----------------*" << endl; long double time_start, time_end; double time_elapsed; double n = 9e9; time_start = time(0); //cout << "time_start = " << time_start << endl; double sum = 0.0; for (long i = 0; i <= (long)n; i++) { sum += i; } cout << "sum = " << sum << endl; time_end = time(0); //cout << "time_end = " << time_end << endl; time_elapsed = (double)(time_end - time_start); cout << "Time: " << time_elapsed << " seconds" << endl; time_start = time(0); //cout << "time_start = " << time_start << endl; sum = 0.0; #pragma omp parallel { double sum_loc = 0.0; //long i = 0; #pragma omp for for (long i = 0; i <= (long)n; i++) { sum_loc += i; } #pragma omp critical { cout << "["<