<small id='mh9nX'></small><noframes id='mh9nX'>

    <legend id='mh9nX'><style id='mh9nX'><dir id='mh9nX'><q id='mh9nX'></q></dir></style></legend>
  1. <i id='mh9nX'><tr id='mh9nX'><dt id='mh9nX'><q id='mh9nX'><span id='mh9nX'><b id='mh9nX'><form id='mh9nX'><ins id='mh9nX'></ins><ul id='mh9nX'></ul><sub id='mh9nX'></sub></form><legend id='mh9nX'></legend><bdo id='mh9nX'><pre id='mh9nX'><center id='mh9nX'></center></pre></bdo></b><th id='mh9nX'></th></span></q></dt></tr></i><div id='mh9nX'><tfoot id='mh9nX'></tfoot><dl id='mh9nX'><fieldset id='mh9nX'></fieldset></dl></div>

  2. <tfoot id='mh9nX'></tfoot>
      <bdo id='mh9nX'></bdo><ul id='mh9nX'></ul>

      OpenMP:局部变量是否自动私有?

      OpenMP: are local variables automatically private?(OpenMP:局部变量是否自动私有?)
        <tfoot id='1zbDF'></tfoot>

        <small id='1zbDF'></small><noframes id='1zbDF'>

          <tbody id='1zbDF'></tbody>
        <i id='1zbDF'><tr id='1zbDF'><dt id='1zbDF'><q id='1zbDF'><span id='1zbDF'><b id='1zbDF'><form id='1zbDF'><ins id='1zbDF'></ins><ul id='1zbDF'></ul><sub id='1zbDF'></sub></form><legend id='1zbDF'></legend><bdo id='1zbDF'><pre id='1zbDF'><center id='1zbDF'></center></pre></bdo></b><th id='1zbDF'></th></span></q></dt></tr></i><div id='1zbDF'><tfoot id='1zbDF'></tfoot><dl id='1zbDF'><fieldset id='1zbDF'></fieldset></dl></div>

              <legend id='1zbDF'><style id='1zbDF'><dir id='1zbDF'><q id='1zbDF'></q></dir></style></legend>
                <bdo id='1zbDF'></bdo><ul id='1zbDF'></ul>
              • 本文介绍了OpenMP:局部变量是否自动私有?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                #pragma omp parallel
                {
                    int x; // private to each thread ?
                }
                
                #pragma omp parallel for
                for (int i = 0; i < 1000; ++i)
                {
                    int x; // private to each thread ?
                }
                

                谢谢!

                附言如果局部变量是自动私有的,使用 private 子句有什么意义?

                P.S. If local variables are automatically private, what is the point of using private clause?

                推荐答案

                是的,局部变量是自动私有的.

                Yes, local variables are automatically private.

                存在 private 子句的原因是 您不必更改代码.

                The reason for the existence of the private clause is so that you don't have to change your code.

                没有private 子句的唯一并行化以下代码的方法

                The only way to parallelize the following code without the private clause

                int i,j;
                #pragma omp parallel for private(j)
                for(i = 0; i < n; i++) {
                    for(j = 0; j < n; j++) {
                        //do something
                    }
                }
                

                是更改代码.例如像这样:

                is to change the code. For example like this:

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

                这是完全有效的 C89/C90 代码,但 OpenMP 的目标之一是不必更改您的代码,除非添加可以在编译时启用或禁用的 pragma 语句.

                That's perfectly valid C89/C90 code but one of the goals of OpenMP is not have to change your code except to add pragma statements which can be enabled or disabled at compile time.

                这篇关于OpenMP:局部变量是否自动私有?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Constructor initialization Vs assignment(构造函数初始化 Vs 赋值)
                Is a `=default` move constructor equivalent to a member-wise move constructor?(`=default` 移动构造函数是否等同于成员移动构造函数?)
                Has the new C++11 member initialization feature at declaration made initialization lists obsolete?(声明时新的 C++11 成员初始化功能是否使初始化列表过时了?)
                Order of constructor call in virtual inheritance(虚继承中构造函数调用的顺序)
                How to use sfinae for selecting constructors?(如何使用 sfinae 选择构造函数?)
                Initializing a union with a non-trivial constructor(使用非平凡的构造函数初始化联合)

                    <i id='y6v6U'><tr id='y6v6U'><dt id='y6v6U'><q id='y6v6U'><span id='y6v6U'><b id='y6v6U'><form id='y6v6U'><ins id='y6v6U'></ins><ul id='y6v6U'></ul><sub id='y6v6U'></sub></form><legend id='y6v6U'></legend><bdo id='y6v6U'><pre id='y6v6U'><center id='y6v6U'></center></pre></bdo></b><th id='y6v6U'></th></span></q></dt></tr></i><div id='y6v6U'><tfoot id='y6v6U'></tfoot><dl id='y6v6U'><fieldset id='y6v6U'></fieldset></dl></div>
                      • <bdo id='y6v6U'></bdo><ul id='y6v6U'></ul>
                          <tbody id='y6v6U'></tbody>

                          <tfoot id='y6v6U'></tfoot><legend id='y6v6U'><style id='y6v6U'><dir id='y6v6U'><q id='y6v6U'></q></dir></style></legend>
                        1. <small id='y6v6U'></small><noframes id='y6v6U'>