omp 并行与 omp 并行 [英] omp parallel vs. omp parallel for

查看:24
本文介绍了omp 并行与 omp 并行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两者有什么区别?

[A]

#pragma omp parallel
{ 
    #pragma omp for
    for(int i = 1; i < 100; ++i)
    {
        ...
    }
}

[B]

#pragma omp parallel for
for(int i = 1; i < 100; ++i)
{
   ...
}

推荐答案

我认为没有什么区别,一个是另一个的捷径.尽管您的确切实现可能会以不同的方式处理它们.

I don't think there is any difference, one is a shortcut for the other. Although your exact implementation might deal with them differently.

合并的并行工作共享结构是一种快捷方式指定包含一个工作共享结构的并行结构并且没有其他声明.允许的子句是子句的并集允许并行和工作共享结构.

The combined parallel worksharing constructs are a shortcut for specifying a parallel construct containing one worksharing construct and no other statements. Permitted clauses are the union of the clauses allowed for the parallel and worksharing contructs.

取自 http://www.openmp.org/mp-文档/OpenMP3.0-SummarySpec.pdf

OpenMP 的规范在这里:

The specs for OpenMP are here:

https://openmp.org/specifications/

这篇关于omp 并行与 omp 并行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆