The Power of Higher-Order Composition Languages in System Design
Total Page:16
File Type:pdf, Size:1020Kb
The Power of Higher-Order Composition Languages in System Design James Adam Cataldo Electrical Engineering and Computer Sciences University of California at Berkeley Technical Report No. UCB/EECS-2006-189 http://www.eecs.berkeley.edu/Pubs/TechRpts/2006/EECS-2006-189.html December 18, 2006 Copyright © 2006, by the author(s). All rights reserved. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission. The Power of Higher-Order Composition Languages in System Design by James Adam Cataldo B.S. (Washington University in St. Louis) 2001 M.S. (University of California, Berkeley) 2003 A dissertation submitted in partial satisfaction of the requirements for the degree of Doctor of Philosophy in Electrical Engineering in the GRADUATE DIVISION of the UNIVERSITY OF CALIFORNIA, BERKELEY Committee in charge: Professor Edward Lee, Chair Professor Alberto Sangiovanni-Vincentelli Professor Raja Sengupta Fall 2006 The dissertation of James Adam Cataldo is approved: Chair Date Date Date University of California, Berkeley Fall 2006 The Power of Higher-Order Composition Languages in System Design Copyright 2006 by James Adam Cataldo 1 Abstract The Power of Higher-Order Composition Languages in System Design by James Adam Cataldo Doctor of Philosophy in Electrical Engineering University of California, Berkeley Professor Edward Lee, Chair This dissertation shows the power of higher-order composition languages in system design. In order to formalize this, I develop an abstract syntax for composition languages and two calculi. The first calculus serves as a framework for composition languages without higher-order components. The second is a framework for higher- order composition languages. I prove there exist classes of systems whose specification in a higher-order composition language is drastically more succinct than it could ever be in a non-higher-order composition language. To justify the calculus, I use it as a semantic domain for a simple higher-order composition language. I use it to reason about higher-order components in this more practical language and use n-level clock distribution networks as a class of systems whose description must grow exponentially in a non-higher order composition lan- 2 guage, but whose description grows linearly with n in a higher-order composition language. As a prototype higher-order composition language, I developed the Ptalon pro- gramming language for Ptolemy II. I explain how components can be built in Ptalon, and I give several examples of models built as a higher-order components in this lan- guage. These examples span several domains in system design: control theory, signal processing, and distributed systems. Unlike functional languages, where higher-order functions are infused with a pro- gram’s execution semantics, the ability to provide scalable higher-order mechanism is completely separated from execution semantics in higher-order composition lan- guages. As a design technique, higher-order composition languages can be used to provide extremely scalable system descriptions. i To Janie, queen of the obscure. ii Contents List of Figures iv 1 Introduction 1 1.1 Background . 7 1.2 Motivating Examples . 10 1.2.1 Map Reduce . 10 1.2.2 Fast Fourier Transform . 17 2 The Succinctness of Higher-Order Composition Languages 21 2.1 The Simple Calculus . 22 2.1.1 Formal Details of the Simple Calculus . 26 2.1.2 Structural Equivalence and Abstract Syntax . 32 2.2 The Higher-Order Calculus . 34 2.2.1 Formal Details of the Extended Calculus . 37 2.2.2 Reduction Isomorphism to λ Calculus with Constants . 49 2.2.3 Scalability of Higher-Order Composition . 54 2.2.4 Undecidability of Structural Equivalence . 62 2.2.5 Abstract Syntax for the Extended Calculus . 64 2.3 Conclusions . 65 3 The Extended Calculus as a Semantic Domain 67 3.1 The Circuit Language . 68 3.2 Intermediate Language . 74 3.3 Semantics of the Circuit Language . 78 3.4 Proofs Using the Semantics Function . 80 3.4.1 Parallel Composition . 81 3.4.2 Adder Circuit . 83 3.4.3 Scalability of a Clock Distribution Network . 89 3.5 Conclusions . 92 iii 4 The Ptalon Programming Language 94 4.1 The Basics of Ptalon . 94 4.2 Recursion and Iteration . 98 4.3 Linear Systems–A Practical Example . 100 4.3.1 Ptalon Code . 102 5 Conclusions 107 Bibliography 109 iv List of Figures 1.1 The Ptolemy model corresponding to the higher-order MapReduce component when the number of map components equals two and the number of reduce components equals three. 15 1.2 The Ptolemy model corresponding to a decimation-in-time FFT higher- order component when N = 4. 20 2.1 A two port component in the simple calculus . 23 2.2 A network of two components in parallel. 25 2.3 A component built out of a parallel network. 26 2.4 A series component in the calculus. 27 3.1 A three-level buffered clock distribution network. 89 4.1 A Ptolemy model equivalent to the Identity component in Ptalon. 96 4.2 The model corresponding to the Link component in Ptalon after the actor parameter A is assigned an actor. 97 4.3 A Ptolemy model equivalent to the Combine component in Ptalon. 98 4.4 The Ptolemy model corresponding to the Parallel component in Ptalon when n :=3................................. 99 4.5 The Ptolemy model corresponding to an IterativeParallel component in Ptalon with n := 3. 100 4.6 A Ptolemy model corresponding to the LinearStateSpace component in Ptalon with the parameters of Equations 4.1 through 4.4. 102 v Acknowledgments Of course, I must thank my mother and father for all the time, energy, money, etc. they have given me throughout my life. Everyone on my thesis committee has been very helpful, particularly Prof. Edward Lee, who has served as an inspiration for me during my time in grad school. I also owe him thanks for actually reading my dissertation multiple times. I must thank Prof. Alberto Sangiovanni-Vincentelli for inspiring some of the theoretical work in this dissertation and Prof. Raja Sengupta for giving me a great idea for an example problem. Perhaps most importantly, I would like to thank Janie, who has been by my side offering support for the past five years. Without her constant jokes, my grad school experience would have been very dull. For help on the Ptalon project, I must thank Thomas Feng, Elaine Cheong, and Andrew Mihal for their work on the original composition calculus. J¨ornJanneck, Jie Liu, and Steve Neuendorffer have also given me some insight and ideas. I would also like to thank Jeffrey Dean for his feedback on my MapReduce example and Prof. Stephen Edwards for introducing me to higher-order components in SHIM. For helping me on previous projects in grad school, I must thank Haiyang Zheng, Xiaojun Liu, and Eleftherios Matsikoudis for their work with me on abstract seman- tics. I must also thank Aaron Ames, Prof. Ian Mitchell, Prof. Shankar Sastry, Hoam Chung, Prof. Claire Tomlin, Prof. Karl Hedrik, and Prof. Pravin Varaiya for working with me on control theory. I’d also like to thank some other members of the Ptolemy vi group with whom I’ve had the pleasure of many fruitful discussions over the years, especially Yang Zhao and Rachel Zhou, but also Christopher Hylands, James Yeh, Chris Chang, and Gang Zhou. I can’t forget to mention Dan Schonberg and Trevor Meyerowitz for all the good times at Berkeley. Finally, I must also thank the rest of my family–Cory, Mike, Jessica, Asia, Coral, and Lexie–for the support they’ve offered along the way. 1 Chapter 1 Introduction Scalability is a big problem in system design. Kuetzer et al. [34] suggest an “or- thogonalization of concerns” to help manage this problem. The idea is to separate various aspects of system design to allow more effective exploration of possible solu- tions in the design space. As an example, function, or what the system should do, can be separated from architecture, or how the system should do it. Similarly, com- munication, or how components transfer data, can be separated from computation, or how components transform data. Another design methodology which addresses scale is Sztipanovits and Karsai’s “model-integrated computing” [51]. Here the idea is to automate the transformation of a metamodel specification of a domain-specific modeling language, coupled with model integrity constraints, into a domain-specific design environment. Whenever possible, models, analysis tools, and transformation tools are shared across domains 2 to promote reuse and to save design time, both in a particular design environment and in the design of that design environment. L´edeczi et al. [1] identify an impor- tant orthogonalization of concerns in model-integrated computing, the separation of “static semantics,” or the rules to specify which domain models are well-formed in a design environment, from “dynamic semantics,” or the execution semantics of a system implementation or simulation. Jackson and Sztipanovits [30] have taken this orthogonalization a step further by formalizing static and dynamic semantics in what they call “structural semantics” and “behavioral semantics” respectively. They formulate structural semantics as a decision procedure for checking model well-formedness in a particular domain. They formulate dynamic semantics as an “interpretation,” or a mapping from one domain to another. For any particular structural semantics, scalability can be an issue in the spec- ification of system structure.