Algorithm 婴儿车,如果有,机组人员/EREW
在我的并行算法书中,PRAM模型有以下伪代码:Algorithm 婴儿车,如果有,机组人员/EREW,algorithm,parallel-processing,theory,prefix-sum,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
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模型中,当id为偶数的处理器执行(例如)NOP指令时?,有无限多的处理器和单个内存。尽管处理器通过每个时间步执行一条指令以锁定步进方式运行,但每个处理器保持其自己的状态,因此可以根据控制流以任意方式执行程序 在乘员式婴儿车中,两个处理器可以在同一时间步中读取同一内存位置,但在同一时间步中只有一个处理器可以写入任何内存位置。在EREW PRAM中,读取也不能同时发生
b[procID]:=b[procID/2];