Research Article

On the Parallelization of Stream Compaction on a Low-Cost SDC Cluster

Algorithm 4

Parallel stream split.
Input: Vector I of length n
Input: Predicate function F
Input: Number of processes p
Input: pid of process
Output: Vector O of valid elements
Output: nvalid: the number of valid elements
(1)
(2)
(3)
(4)
(5)for to in parallel do
(6)if then
(7)  
(8)  
(9)end if
(10)end for
(11)if then
(12) Send to process pid 0
(13)end if
(14)if then
(15)for to do
(16)  
(17)  
(18)end for
(19)for to do
(20)  Send to process pid i
(21)end for
(22)
(23) Send to all processes
(24)end if
(25)if then
(26) Receive
(27) Receive
(28)end if
(29)
(30)for to in parallel do
(31)
(32)end for
(33)for to in parallel do
(34)if then
(35)  
(36)else
(37)  
(38)end if
(39)end for