OMP中的减少和折叠子句有一些混淆点 [英] Reduction and collapse clauses in OMP have some confusing points

查看:182
本文介绍了OMP中的减少和折叠子句有一些混淆点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OMP中的缩减和折叠子句都让我感到困惑,
一些提示突然出现在我脑海中。

Both of reduction and collapse clauses in OMP confuses me, some points raised popped into my head


  1. 用负号工作?如所列的限制此处

  2. 是有任何工作要实现减号?

  3. 一元运算符如何工作,即x ++或x--?是 - 或++应用于每个部分结果?或者只有在创建全局结果时才一次?这两种情况完全不同。

关于崩溃..
我们可以在嵌套循环上应用collapse,
之间的代码例如

About the collapse.. could we apply collapse on a nested loops but have some lines of code in between for example

for (int i = 0; i < 4; i++)
{
    cout << "Hi"; //This is an extra line. which breaks the 2 loops.
    for (int j = 0; j < 100; j++)
    {
        cout << "*";
    }
}


推荐答案

1 &对于减号,你减去什么?如果你有两个线程,你做 result_thread_1 - result_thread_2 result_thread_2 - result_thread_1 吗?如果你有两个以上的线程,那么它会更加混乱:我只有一个否定词,所有其他都是正数?只有一个积极的词,而其他的是负的?是混合吗?哪些结果是哪些?

1 & 2. For minus, what are you subtracting from? If you have two threads, do you do result_thread_1 - result_thread_2, or result_thread_2 - result_thread_1? If you have more than 2 threads, then it gets even more confusing: Do I only have one negative term and all others are positive? Is there only one positive term and others are negative? Is it a mix? Which results are which? As such, no, there is no workaround.


  1. 如果 x ++ x - ,假设它们在缩减循环内,它们应该出现在每个部分结果中。

  1. In the event of x++ or x--, assuming that they are within the reduction loop, they should happen to each partial result.

是的,我相信这样。

这篇关于OMP中的减少和折叠子句有一些混淆点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆