Abstract
Divide-and-conquer is an important technique in parallel programming. However, algebraic data structures do not fit divide-and-conquer parallelism. For example, the usual pointer-based implementation of lists cannot efficiently be divided at their middle, which prevents us from developing list-iterating divide-and-conquer parallel programs. Tree-iterating programs possibly face a similar problem, because trees might be ill-balanced and list-like shapes. This paper examines parallel programming based on balanced trees: we consider balanced-tree structures and develop recursive functions on them. By virtue of their balancing nature, either bottom-up or top-down recursive functions exploit divide-and-conquer parallelism. Our main contribution is to demonstrate the promise of this approach. We propose a way of systematically developing balanced trees from parallel algorithms, and then, we show that efficient parallel programs on them can be developed by equational reasoning powered by Reynolds' relational parametricity. We consider functions that operate either lists or binary trees, and show that our methods can uniformly deal with both cases. The developed parallel programs are purely functional, correct by construction, and sometimes even simpler than known algorithms.
Supplemental Material
- K. R. Abrahamson, N. Dadoun, D. G. Kirkpatrick, and T. M. Przytycka. A simple parallel tree contraction algorithm. J. Algorithms, 10 (2): 287--302, 1989. Google Scholar
Digital Library
- U. A. Acar, G. E. Blelloch, R. Harper, J. L. Vittes, and S. L. M. Woo. Dynamizing static algorithms, with applications to dynamic trees and history independence. In Proc. the Fifteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2004, pages 531--540. SIAM, 2004. Google Scholar
Digital Library
- R. P. Brent. The parallel evaluation of general arithmetic expressions. J. ACM, 21 (2): 201--206, 1974. Google Scholar
Digital Library
- S. W. Bent, D. D. Sleator, and R. E. Tarjan. Biased search trees. SIAM J. Comput., 14 (3): 545--568, 1985.Google Scholar
Digital Library
- R. S. Bird. An Introduction to the Theory of Lists. In Logic of Programming and Calculi of Discrete Design,volume 36 of NATO ASI Series F, pages 3--42. Springer-Verlag, 1987. Google Scholar
Digital Library
- G. E. Blelloch, J. C. Hardwick, J. Sipelstein, M. Zagha, and S. Chatterjee. Implementation of a portable nested data-parallel language. J. Parallel Distrib. Comput., 21 (1): 4--14, 1994. Google Scholar
Digital Library
- H.-J. Boehm, R. R. Atkinson, and M. F. Plass. Ropes: An alternative to strings. Softw., Pract. Exper. 25(12): 1315--1330, 1995. Google Scholar
Digital Library
- R. M. Burstall and J. Darlington. A transformation system for developing recursive programs. J. ACM, 24 (1): 44--67, 1977. Google Scholar
Digital Library
- W.-N. Chin, A. Takano, and Z. Hu. Parallelization via context preservation. In Proc. the 1998 International Conference on Computer Languages, ICCL '98, pages 153--162. IEEE Computer Society, 1998. Google Scholar
Digital Library
- M. I. Cole. Algorithmic Skeletons: Structural Management of Parallel Computation. MIT Press, 1989. Google Scholar
Digital Library
- N. A. Day, J. Launchbury, and J. Lewis. Logical abstractions in Haskell. In Proc. the 1999 Haskell Workshop. Utrecht University Department of Computer Science, Technical Report UU-CS-1999-28, October 1999.Google Scholar
- J. Dean and S. Ghemawat. MapReduce: Simplified data processing on large clusters. In Proc. 6th Symposium on Operating System Design and Implementation (OSDI 2004), pages 137--150. USENIX, 2004. Google Scholar
Digital Library
- M. Fluet, M. Rainey, J. H. Reppy, and A. Shaw Implicitly-threaded parallelism in Manticore. In Proc. the 13th ACM SIGPLAN International Conference on Functional Programming, ICFP 2008, pages 119--130. ACM, 2008. Google Scholar
Digital Library
- G. N. Frederickson. A data structure for dynamically maintaining rooted trees. J. Algorithms, 24 (1): 37--65, 1997. Google Scholar
Digital Library
- H. Gazit, G. L. Miller, and S.-H. Teng. Optimal tree contraction in the EREW model. In Proc. the Princeton Workshop on Algorithms, Architectures, and Technology Issues for Models of Concurrent Computation, pages 139--156. Plenum Press, 1987.Google Scholar
- J. Gibbons, W. Cai, and D. B. Skillicorn. Efficient parallel algorithms for tree accumulations. Sci. Comput. Program., 23 (1): 1--18, 1994. Google Scholar
Digital Library
- Z. Hu, H. Iwasaki, and M. Takeichi. Deriving structural hylomorphisms from recursive definitions. In Proc. the 1st ACM SIGPLAN International Conference on Functional Programming, ICFP'96, pages 73--82. ACM, 1996. Google Scholar
Digital Library
- Z. Hu, H. Iwasaki, M. Takeichi, and A. Takano. Tupling calculation eliminates multiple data traversals. In Proc. the 2nd ACM SIGPLAN International Conference on Functional Programming, ICFP'97, pages 164--175. ACM, 1997. Google Scholar
Digital Library
- Z. Hu, M. Takeichi, and W.-N. Chin. Parallelization in calculational forms. In POPL '98: Proc. the 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 316--328. ACM, 1998. Google Scholar
Digital Library
- Z. Hu, H. Iwasaki, and M. Takeichi. An accumulative parallel skeleton for all. In Programming Languages and Systems, 11th European Symposium on Programming, ESOP 2002, Proceedings, volume 2305 of Lecture Notes in Computer Science, pages 83--97. Springer, 2002. Google Scholar
Digital Library
- G. Keller, M. M. T. Chakravarty, R. Leshchinskiy, S. L. P. Jones, and B. Lippmeier. Regular, shape-polymorphic, parallel arrays in haskell. In Proc. the 15th ACM SIGPLAN International Conference on Functional Programming, ICFP 2010, pages 261--272. ACM, 2010. Google Scholar
Digital Library
- D. Knuth. The Art of Computer Programming, volume 3. Addison Wesley Longman, second edition edition, 1998. Google Scholar
Digital Library
- S. R. Kosaraju and A. L. Delcher. Optimal parallel evaluation of tree-structured computations by raking. In VLSI Algorithms and Architectures, 3rd Aegean Workshop on Computing, AWOC 88, Proceedings, volume 319 of Lecture Notes in Computer Science, pages 101--110. Springer, 1988. Google Scholar
Digital Library
- A. Kühnemann, R. Glück, and K. Kakehi. Relating accumulative and non-accumulative functional programs. In Rewriting Techniques and Applications, 12th International Conference, RTA 2001, Proceedings, volume 2051 of Lecture Notes in Computer Science, pages 154--168. Springer, 2001. Google Scholar
Digital Library
- K. Matsuzaki. Efficient implementation of tree accumulations on distributed-memory parallel computers. In Computational Science - ICCS 2007, 7th International Conference, Proceedings, Part II, volume 4488 of Lecture Notes in Computer Science, pages 609--616. Springer, 2007. Google Scholar
Digital Library
- K. Matsuzaki, Z. Hu, and M. Takeichi. Towards automatic parallelization of tree reductions in dynamic programming. In SPAA 2006: Proc. the 18th Annual ACM Symposium on Parallel Algorithms and Architectures, pages 39--48. ACM, 2006a. Google Scholar
Digital Library
- K. Matsuzaki, Z. Hu, and M. Takeichi. Parallel skeletons for manipulating general trees. Parallel Comput., 32 (7--8): 590--603, 2006b. Google Scholar
Digital Library
- E. Meijer, M. M. Fokkinga, and R. Paterson. Functional programming with bananas, lenses, envelopes and barbed wire. In Functional Programming Languages and Computer Architecture, 5th ACM Conference, Proceedings, volume 523 of Lecture Notes in Computer Science, pages 124--144. Springer, 1991. Google Scholar
Digital Library
- G. L. Miller and J. H. Reif. Parallel tree contraction and its application. In 26th Annual Symposium on Foundations of Computer Science, pages 478--489. IEEE, 1985. Google Scholar
Digital Library
- A. Morihata and K. Matsuzaki. Automatic parallelization of recursive functions using quantifier elimination. In Functional and Logic Programming, 10th International Symposium, FLOPS 2010, Proceedings, volume 6009 of Lecture Notes in Computer Science, pages 321--336. Springer, 2010. Google Scholar
Digital Library
- A. Morihata, K. Matsuzaki, Z. Hu, and M. Takeichi. The third homomorphism theorem on trees: Downward & upward lead to divide-and-conquer. In Proc. the 36th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2009, pages 177--185. ACM, 2009. Google Scholar
Digital Library
- S. Peyton Jones, editor. Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, Cambridge, UK, 2003.Google Scholar
- S. L. Peyton Jones, R. Leshchinskiy, G. Keller, and M. M. T. Chakravarty. Harnessing the multicores: Nested data parallelism in haskell. In IARCS Annual Conference on Foundations of Software Technology and Theoretical Computer Science, FSTTCS 2008, volume 08004 of Dagstuhl Seminar Proceedings. Internationales Begegnungs-und Forschungszentrum fuer Informatik (IBFI), 2008.Google Scholar
Digital Library
- J. H. Reif, editor. Synthesis of Parallel Algorithms. Morgan Kaufmann Publishers, 1993. Google Scholar
Digital Library
- J. C. Reynolds. Types, abstraction and parametric polymorphism. Inf. Process., 83: 513--523, 1983.Google Scholar
- D. B. Skillicorn. Structured parallel parallel computation in structured documents. J. UCS, 3 (1): 42--68, 1997.Google Scholar
- D. B. Skillicorn. Parallel implementation of tree skeletons. J. Parallel Distrib. Comput., 39 (2): 115--125, 1996. Google Scholar
Digital Library
- A. Takano and E. Meijer. Shortcut deforestation in calculational form. In Conference Record of FPCA'95: SIGPLAN-SIGARCH-WG2.8 Conference on Functional Programming Languages and Computer Architecture, pages 306--313. ACM, 1995. Google Scholar
Digital Library
- J. Voigtländer. Concatenate, reverse and map vanish for free. In Proc. the Seventh ACM SIGPLAN International Conference on Functional Programming (ICFP'02), pages 14--25, 2002. Google Scholar
Digital Library
- J. Voigtländer. Much ado about two (pearl): a pearl on parallel prefix computation. In Proc. the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2008, pages 29--35. ACM, 2008. Google Scholar
Digital Library
- J. Voigtländer. Bidirectionalization for free! (pearl). In Proc. the 36th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2009, pages 165--176. ACM, 2009. Google Scholar
Digital Library
- P. Wadler. Theorems for free! In FPCA'89 Conference on Functional Programming Languages and Computer Architecture, pages 347--359. ACM, 1989. Google Scholar
Digital Library
- P. Wadler. Deforestation: Transforming programs to eliminate trees. Theor. Comput. Sci., 73 (2): 231--248, 1990. Google Scholar
Digital Library
Index Terms
Balanced trees inhabiting functional parallel programming
Recommendations
Balanced trees inhabiting functional parallel programming
ICFP '11: Proceedings of the 16th ACM SIGPLAN international conference on Functional programmingDivide-and-conquer is an important technique in parallel programming. However, algebraic data structures do not fit divide-and-conquer parallelism. For example, the usual pointer-based implementation of lists cannot efficiently be divided at their ...
On the Maximum Agreement Subtree Conjecture for Balanced Trees
We give a counterexample to the conjecture of Martin and Thatte that two balanced rooted binary leaf-labeled trees on $n$ leaves have a maximum agreement subtree (MAST) of size at least $n^{\frac{1}{2}}$. In particular, we show that for any $c>0$, there ...
Rank-Balanced Trees
Since the invention of AVL trees in 1962, many kinds of binary search trees have been proposed. Notable are red-black trees, in which bottom-up rebalancing after an insertion or deletion takes O(1) amortized time and O(1) rotations worst-case. But the ...







Comments