【发布时间】:2019-02-06 14:26:14
【问题描述】:
在我看来,在 OpenMP 中拥有一个带有并行块的临界区是没有意义的!我可能只是写一个简单的串行循环,对吗?
在下面的(简单的)示例中,而不是
1.
!$omp critical
!$ thread_num = omp_get_thread_num()
print *, "Hello world from thread number ", thread_num
!$omp end critical
!$omp end parallel
2.
do i=1,num_threads
print *, "Hello world from thread number ", thread_num
end do
话虽如此,我理解其中的区别:1. 使用不同的线程,而 2. 不使用。
是否存在一个重要的上下文,前者实际上可能比后者提供速度优势?
【问题讨论】: