openmp.c 352 B

123456789101112131415161718
  1. #include <omp.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. int main () {
  5. int nthreads, tid;
  6. #pragma omp parallel private(nthreads, tid)
  7. {
  8. tid = omp_get_thread_num();
  9. printf("Hello World from thread = %d\n", tid);
  10. if (tid == 0) {
  11. nthreads = omp_get_num_threads();
  12. printf("Number of threads = %d\n", nthreads);
  13. }
  14. }
  15. return EXIT_SUCCESS;
  16. }