how this code works?

Use this forum to discuss the book: Using OpenMP - Portable Shared Memory Parallel Programming, by Barbara Chapman, Gabriele Jost and Ruud van der Pas Read the http://openmp.org/forum/viewtopic.php?f=8&t=465 for book info and to download the examples. Post your feedback about the book and examples to this forum
Forum rules
The OpenMP Forums are now closed to new posts. Please visit Stack Overflow if you are in need of help: https://stackoverflow.com/questions/tagged/openmp
Locked
amir1981
Posts: 2
Joined: Thu Dec 05, 2013 5:08 pm

how this code works?

Post by amir1981 »

I have this code:
#pragma omp parallel for
for(int32 i = 0; i < 10; i++){
DoSomething();
}
...
DoSomething(){
#pragma omp parallel for
for(int32 i = 0; i < 10; i++){
DoAnotherThing();
}
}

I am wondering how openmp distributes the works among threads in the above code! Lets say I have 8 core on my computer. I think openmp distribute the first loop between these 8 cores and basically ignore the second pragama until one of the threads finish its job and become ideal then it assign it to the second one. Am I correct?

gdarmon
Posts: 8
Joined: Wed Feb 26, 2014 1:01 pm

Re: how this code works?

Post by gdarmon »

basically you are right, OpenMp will fork() and join between the pragmas

richarddylan39
Posts: 1
Joined: Fri Sep 18, 2015 5:51 am

Re: how this code works?

Post by richarddylan39 »

Yes you are going to the right way

Locked