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 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

how this code works?

Postby amir1981 » Thu Dec 05, 2013 11:23 pm

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?
amir1981
 
Posts: 2
Joined: Thu Dec 05, 2013 5:08 pm

Re: how this code works?

Postby gdarmon » Wed Feb 26, 2014 3:11 pm

basically you are right, OpenMp will fork() and join between the pragmas
gdarmon
 
Posts: 8
Joined: Wed Feb 26, 2014 1:01 pm


Return to Using OpenMP - The Book and Examples

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest