Parallel loops containing a function call

Does this correspond to parallelizing loops containing a function call, or is it much more convenient to parallelize loops that perform the main operation inside.

for example, is it suitable for hosting parallelization directives as shown below?

main(){
..
#omp paralel ..
for (i=0;i<100;i++){
a[i] = foo(&datatype , ...);
...
}
..
}

int foo(datatype *a,...){
//doing complex operations here
//calling other functions etc.
}

Thank you, Richard and Feckler, for the comments were helpful, and I will take a deep look at the book rchrd suggested. But by the end of the day, I’m required to make the existing C code (a really big loop, which is located at the top of the program), if possible, parallelize it using openMP.

, . , , parellelezing , ,

for(i to N){   
  work1() --(serial)
  work2() --(serial)
  Work3() --( PARALLEL)
  work4() --(serial)
}

//does it make sense adding critical sections except work3

#omp parallel for private(Ptr)
for(i to N){   
 #omp single
 {
  work1() --(serial)
  work2() --(serial)
 }
  Work3(Ptr) --( PARALLEL)
 #omp single
 {
  work4() --(serial)
 }
}
+5
2

:

  • foo?
  • foo() , ?
  • openmp?

, - - ( , , ), .

+1

MIT Press Book, OpenMP, , OpenMP.

openmp.org, OpenMP. http://openmp.org/

0

All Articles