Using continue inside the paralleld for loop

情到浓时终转凉″ 提交于 2019-12-08 10:06:43

问题


My code looks-like as below:

 #pragma omp parallel for num_threads(5)
            for(int i = 0; i < N; i++)
               {
                //some code
                //#pragma omp parallel for reduction(+ : S_x,S_y,S_theta)
                for(int j = 0; j < N; j++)
                  {
                    if (j==i) continue;
                     // some code
                    for(int ky = -1; ky<= 1; ky++)
                        {
                        for(int kx = -1; kx<= 1; kx++)
                           {
                           //some code
                           if (r_ij_square > l0_two)
                              { 
                              //some code
                              }
                           }
                        }
                    }
            //some code
                }

I'm not sure if continue in above code could cause any prblem or not. To avoid any problem, I have ignored second #pragma in above code by //. But I'm not still sure if above code could cause any problem due to using continue or not? My question is if above code could cause problem or not, and if yes, how can I remove the problem? When searching, I found these two sentences loops with "restricted" continue statements can be parallelized. or Only an iteration of the innermost associated loop may be curtailed by a continue statement. . But I don't know what do they mean exactly

来源:https://stackoverflow.com/questions/47426526/using-continue-inside-the-paralleld-for-loop

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!