how do i find implementations of "parallel for"?
I would like to know exactly what is going on with omp parallel for
开发者_如何学JAVA and other similiar constructs. How do I find how these are implemented? A short summary of someone who knows about this would be great. Thanks.
Open MP is merely a spec, how a vendor chooses to implement it is up to them. that being said, the libraries GCC uses are open source, so is Intels Thread building blocks, which has a parallel for, just not as a pragma, but its implementation is what your after
http://www.compunity.org/futures/omp-api.html
Consider a simple OpenMP program, with a main program, calling function foo, containing a single OpenMP parallel construct, executing with four threads. Before the first entry into the parallel region, the program has only one thread, the master thread, and that thread has the same callstack in both the user-model, and the implementation-model:
Master
foo
main
<start>
After the entry into the parallel region, there are four threads, and in the user-model, their callstacks would look like:
Master Slave 1 Slave 2 Slave 3
foo-OMPa foo-OMPa foo-OMPa foo-OMPa
foo foo foo foo
main main main main
<start> <start> <start> <start>
As you know, OpenMP is implemented inside of a compiler because it transforms code and generates parallelized code. If you want to know the inside implementation work, then please read this article that explains quite details of Intel compiler's OpenMP implementation.
Of course, you may browse gcc's OpenMP implementation such as omp-low.c in libgomp.
精彩评论