OpenMP 循环中的索引是否按升序处理?
考虑以下 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不保证线程运行的顺序; 线程处理自己的块的顺序是有保证的。
The order in which threads run is not guaranteed; the order in which a thread processes its own chunk is guaranteed.
如果您的问题是每个线程是否都会获得迭代的一个块,并且如果在该块内
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?