algorithm - PRAM if-then-else CREW/EREW

标签 algorithm parallel-processing theory prefix-sum

在我的并行算法书中,有以下 PRAM 模型的伪代码:

procedure PrefixSumPRAM( A, n ):
BEGIN
   b := new Array(2*n-1);
   b[1] := SumPRAM(A, n); //this will load A with the computation tree and return the sum
   for i := 1 to ( log2(n) - 1 ) do
   BEGIN
      for all procID where (2^i) <= procID <= ((2^(i+1))-1) do in parallel
      BEGIN
          if odd(procID) then
               b[ procID ] := b[ procID/2 ];
          else
               b[ procID ] := b[ procID/2 ] - a[ procID+1 ];
      END
   END
END

但是...PRAM 指定所有处理器必须对不同的数据执行相同的指令。

所以这个程序只能在 CREW PRAM 模型上执行?

或者在 EREW 模型上可执行,则 ID 为奇数的处理器将执行

b[procID]:=b[procID/2];

当具有偶数 id 的处理器执行(例如)NOP 指令时?

最佳答案

在 PRAM 模型中,有无限数量的处理器和单个内存。尽管处理器通过每个时间步执行一条指令以锁步方式运行,但每个处理器都保持自己的状态,因此可以根据控制流以任意方式执行程序。

在 CREW PRAM 中,两个处理器可以在同一时间步长中从相同的内存位置读取数据,但只有一个处理器可以在一个步骤中写入任何内存位置。在 EREW PRAM 中,读取也不能同时发生。

关于algorithm - PRAM if-then-else CREW/EREW,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20994106/

相关文章:

algorithm - 宽相碰撞检测方法?

c++ - MPI_Scatter 会减慢代码速度吗?

c++ - 带有 std::execution::par_unseq 的 std::for_each 不适用于 GCC 但适用于 MSVC

swift - 使用 BrightFutures 控制并行性,Swift 中的 "future"实现

haskell - Haskell 中类型的含义是什么

operating-system - 抢占式调度程序和非抢占式调度程序哪个更有效?

java - 为什么java使用System.out.print/println而不仅仅是print或println?

algorithm - 有效的时间表算法

c++ - 有条件地并行填充 vector

arrays - 证明或反驳 : There is a general sorting algorithm which can sort an array of length n in O(n) if it's min-heap-ordered