Research Article
On the Parallelization of Stream Compaction on a Low-Cost SDC Cluster
Algorithm 3
Parallel work-efficient stream compaction.
| 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) | end if | (24) | if then | (25) | Receive | (26) | end if | (27) | | (28) | for to in parallel do | (29) | | (30) | end for | (31) | for to in parallel do | (32) | if then | (33) | | (34) | end if | (35) | end for |
|