我如何找到“parallel for”的实现?

发布于 2024-10-16 01:42:28 字数 91 浏览 3 评论 0原文

我想确切地知道 omp parallel for 和其他类似结构发生了什么。我如何找到这些是如何实施的?了解这一点的人的简短总结会很棒。谢谢。

I would like to know exactly what is going on with omp parallel for 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

归途 2024-10-23 01:42:29

如您所知,OpenMP 是在编译器内部实现的,因为它转换代码并生成并行代码。如果您想了解内部实现工作,请阅读这篇文章解释了英特尔编译器 OpenMP 实现的详细信息。

当然,您可以浏览gcc的OpenMP实现,例如libgomp中的omp-low.c。

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.

雨后彩虹 2024-10-23 01:42:28

Open MP 只是一个规范,供应商选择如何实现它取决于他们。话虽这么说,GCC 使用的库是开源的,Intel 的 Thread 构建块也是开源的,它有一个并行的 for,只是不是作为编译指示,但它的实现是您想要的

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

探春 2024-10-23 01:42:28

http://www.compunity.org/futures/omp-api.html

考虑一个简单的 OpenMP 程序,其中一个主程序调用函数 foo,包含单个 OpenMP 并行构造,使用四个线程执行。在第一次进入并行区域之前,程序只有一个线程,即主线程,并且该线程在用户模型和实现模型中具有相同的调用堆栈:

Master
foo
main
<start>

进入并行区域后,有四个线程,在用户模型中,它们的调用堆栈如下所示:

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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文