相关疑难解决方法(0)

如何以惯用的方式打破嵌套并行(OpenMP)Fortran循环?

这是顺序代码:

do i = 1, n
   do j = i+1, n
      if ("some_condition(i,j)") then
         result = "here's result"
         return
      end if
   end do
end do
Run Code Online (Sandbox Code Playgroud)

有没有更简洁的方法同时执行外部循环的迭代:

  !$OMP PARALLEL private(i,j)
  !$OMP DO 
  do i = 1, n     
     !$OMP FLUSH(found)
     if (found) goto 10
     do j = i+1, n        
        if ("some_condition(i,j)") then
           !$OMP CRITICAL
           !$OMP FLUSH(found)
           if (.not.found) then           
              found = .true.
              result = "here's result"
           end if
           !$OMP FLUSH(found)
           !$OMP END CRITICAL
           goto 10
        end if
     end do
10   continue
  end …
Run Code Online (Sandbox Code Playgroud)

fortran openmp break

8
推荐指数
1
解决办法
8552
查看次数

标签 统计

break ×1

fortran ×1

openmp ×1