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

查看:153
本文介绍了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天全站免登陆