在 OpenMP 中,我可以刷新一组指定的变量或整个缓存。
有人知道这个操作的性能吗?仅刷新真正发生变化的变量是否有意义,或者“全部刷新”如此之快,我不应该担心?
我有链接列表,我需要不时刷新我的线程。我应该遍历列表并单独刷新每个元素,还是简单地刷新所有内容?
Given the advice in the OpenMP 3.1 standard:
Use of a flush construct with a list is extremely error prone and users are strongly discouraged from attempting it.
and the following sentence:
An implementation may implement a flush with a list by ignoring the list, and treating it the same as a flush without a list.
I would implement first a solution with pragma omp flush
(without any list).
Then, I would really think carefully before trying to optimize this implementation adding a list to flush constructs, as the code won't be performance portable.