0
在我的并行算法的书没有为PRAM模型下面的伪代码:PRAM IF-THEN-ELSE CREW/EREW
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];
当与偶数编号的处理器上执行的一个(例如)NOP指令?