#include #include using namespace std; void Greeting(); int main() { omp_set_max_active_levels(2); #pragma omp parallel num_threads(4) { int id{omp_get_thread_num()}; #pragma omp critical { cout << "Hello world from " << id << endl; } #pragma omp parallel num_threads(4) if (id % 2 ) { int newid{omp_get_thread_num()}; #pragma omp critical { cout << "More deeply parallel " << id << " and " << newid << endl; } } #pragma omp barrier cout << endl << endl; #pragma omp for for(int i = 0; i < 20; ++i) { #pragma omp critical { cout << id << " i = " << i << endl; } } } return 0; }