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 have40
cpus, once on each, if have4
, 10 times on each
is tricky homework?
Comments
Post a Comment