c - How many threads in a loop -
if create loop
for(int i=0;i<n;i++){//do something}
and run through visual studio, program create thread every iteration, whole loop, or it's variable number?
and run through visual studio, program create thread every iteration, whole loop, or it's variable number?
none of above. program default have single thread of execution , execute each iteration of loop in series, without creating new ones.
only feature openmp (or similar) spawn different threads per iteration.
#include <omp.h> #pragma omp parallel for(int n=0; n<10; ++n) { printf(" %d", n); } printf(".\n");
Comments
Post a Comment