Go to the documentation of this file.00001
00002
00003 #include <iostream>
00004 using namespace std;
00005
00006 #include <omp.h>
00007
00008 int main(int argc, char *argv[])
00009 {
00010 int th_id, nthreads;
00011 #pragma omp parallel private(th_id) shared(nthreads)
00012 {
00013 th_id = omp_get_thread_num();
00014 #pragma omp critical
00015 {
00016 cout << "Hello World from thread " << th_id << '\n';
00017 }
00018 #pragma omp barrier
00019
00020 #pragma omp master
00021 {
00022 nthreads = omp_get_num_threads();
00023 cout << "There are " << nthreads << " threads" << '\n';
00024 }
00025 }
00026
00027 return 0;
00028 }