c - How many times will each print statement be executed? -


if following code fragment run on 4 processors, how many times each print statement executed ?

prinf("print # 1\n");    #pargma omp parallel {      printf("print #2\n");         #pragma omp         (i = 0 ; < 40 ; i++) {         printf(“print #\n);     }     printf(“print #4\n”);     } 

smells homework , of course code pasted wouldn't compile, but

  • print #1 - once
  • print #2 & #4 - 4 times, block run once on each cpu
  • "print #" (in for) - 40 times, if have 40 cpus, once on each, if have 4, 10 times on each

is tricky homework?


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -