OpenMP 循环中的索引是否按升序处理?

发布于 2024-11-14 19:58:10 字数 193 浏览 2 评论 0原文

考虑以下 OpenMP for 循环:

#pragma omp parallel for schedule(dynamic)
for (int i = 0; i < n; ++i)
{
    //do something with i
}

是否保证每个 OpenMP 线程都按升序看到其 i 值?

Consider the following OpenMP for loop:

#pragma omp parallel for schedule(dynamic)
for (int i = 0; i < n; ++i)
{
    //do something with i
}

Is it guaranteed that each OpenMP thread sees its i values in ascending order?

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

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

发布评论

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

评论(2

帝王念 2024-11-21 19:58:10

不保证线程运行的顺序; 线程处理自己的块的顺序是有保证的

The order in which threads run is not guaranteed; the order in which a thread processes its own chunk is guaranteed.

半世蒼涼 2024-11-21 19:58:10

如果您的问题是每个线程是否都会获得迭代的一个块,并且如果在该块内 i 的值是连续的,那么答案是肯定的。这是你的问题吗?

If your question is if each thread will get a chunk of the iteration and if within that chunk the value of i is sequential, then the answer is yes. Is that your question?

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