Concurrent Polyglot: an Extensible Compiler
Total Page:16
File Type:pdf, Size:1020Kb
CONCURRENT POLYGLOT: AN EXTENSIBLE COMPILER FRAMEWORK by SAURABH SATISH KOTHARI Presented to the Faculty of the Graduate School of The University of Texas at Arlington in Partial Fulfillment of the Requirements for the Degree of MASTER OF SCIENCE IN COMPUTER SCIENCE THE UNIVERSITY OF TEXAS AT ARLINGTON May 2011 Copyright © by Saurabh Satish Kothari 2011 All Rights Reserved ACKNOWLEDGEMENTS I would like to express my deep and sincere gratitude to my supervising professor Dr. Nathaniel Nystrom who has shown tremendous faith and patience in me. He has supported me throughout the work on this thesis and has given me priceless advice on many occasions. I have gained invaluable knowledge working with him, which will undoubtedly help me in the years to come. I would also like to thank my committee members, Dr. Christoph Csallner and Dr. Bahram Khalili for giving me invaluable suggestions and advice. I am grateful to all my friends in Arlington who have spent time with me during the course of my master’s here. I am also grateful to all my friends back home in Bangalore who encouraged me through my studies. I would especially like to thank my roommates: Anjan, Ram and Sharath for their immense support, without which I would not have been able to work on this thesis in an efficient way. I sincerely appreciate my parents’ and my sisters’ love and support, which has enabled me to come this far in my field of study. They have always encouraged me in every possible way. Special thanks go to my friend, Sharda Murthi, at Georgia Institute of Technology, whose patient love and faith has always been with me. I dedicate this work to all who have associated with me in some way in the present and in the past. April 13, 2011 iii ABSTRACT CONCURRENT POLYGLOT: AN EXTENSIBLE COMPILER FRAMEWORK Saurabh Satish Kothari, M.S. The University of Texas at Arlington, 2011 Supervising Professor: Nathaniel Nystrom We have today crossed the threshold of increasing clock frequencies as the dominant solution to faster computing, and it is imperative for software developers to be able to think in the concurrent and parallel paradigm. Important still is to equip programmers with the right tools to develop concurrent and parallel software. Software concurrency is a widely researched area, and many of today’s compilers concentrate on compiling for parallelism. However, although concurrent compilers have been explored since the 1970s, very few of them exist today that justify multicore environments. For instance, gmake [1] supports coarse grained parallelism through the –j option for building independent files in parallel. Our effort here brings into perspective a much finer grained approach: targeting the abstract syntax tree to extract opportunities for parallel and concurrent compilation. Polyglot is an extensible compiler framework. It allows the extension of Java in domain- specific ways into languages that may define their own new constructs. Compilation in Polyglot is sequential. The compiler uses only one core, even if additional cores are present. In order to fully utilize the power of the underlying hardware, we present here our efforts in making Polyglot iv concurrent. Parallelization of the compilation process can yield faster compilation times. It also presents the correctness and scalability challenges that make this a test bed for experimenting with various concurrency models. As part of the larger Polyglot project, we evaluate and present here the performance of Concurrent Polyglot against benchmarks and compare with the performance of Sequential Polyglot. We also present correctness of the output produced by Concurrent Polyglot. v TABLE OF CONTENTS ACKNOWLEDGEMENTS ............................................................................................................ iii ABSTRACT .................................................................................................................................. iv LIST OF ILLUSTRATIONS......................................................................................................... viii LIST OF TABLES ......................................................................................................................... ix Chapter Page 1. INTRODUCTION .......................................................................................................... 1 1.1 Context .......................................................................................................... 1 1.2 Motivation and Goals .................................................................................... 3 1.3 Thesis outline ................................................................................................ 4 2. POLYGLOT, X10 AND THE X10 CONCURRENCY MODEL ...................................... 5 2.1 Polyglot .......................................................................................................... 5 2.1.1 Sequential Polyglot and extensions .............................................. 5 2.1.2 Extensibility ................................................................................... 9 2.1.3 An example: The enhanced for loop for Java 1.4 ......................... 9 2.2 X10 .............................................................................................................. 13 2.2.1 X10 Concurrency model .............................................................. 14 2.3 The Funicular library ................................................................................... 16 2.4 Conclusion ................................................................................................... 17 3. MECHANISMS ........................................................................................................... 18 3.1 Granularity ................................................................................................... 18 3.2 AST and parallelism .................................................................................... 19 3.2.1 Goals, Parallel compilation and Parallel AST passes ................. 19 3.3 Shared Data Structures and Synchronization ............................................. 23 3.3.1 ImportTable ................................................................................. 24 3.3.2 CachingResolver ......................................................................... 25 vi 3.3.3 SystemResolver .......................................................................... 26 3.3.4 TypeSystem ................................................................................ 26 3.3.5 ClassDef ...................................................................................... 27 3.3.6 ConstructorDef ............................................................................ 28 3.3.7 FieldDef ....................................................................................... 28 3.3.8 InitializerDef ................................................................................ 28 3.3.9 MethodDef .................................................................................. 28 3.3.10 LocalDef .................................................................................... 28 3.3.11 Ref_c ......................................................................................... 29 3.4 Conclusion ................................................................................................... 29 4. EXPERIMENTS .......................................................................................................... 31 4.1 Setup of Experiments .................................................................................. 31 4.2 Metrics Measured ........................................................................................ 31 4.3 Input to the experimental setup ................................................................... 32 4.4 Correctness of output .................................................................................. 33 4.5 Results ........................................................................................................ 34 4.5.1 DaCapo Base [21] ....................................................................... 34 4.5.2 DaCapo Antlr ............................................................................... 36 5. RELATED WORK ....................................................................................................... 38 5.1 Early work on FORTRAN compilers ........................................................... 38 5.2 Targeting syntax trees ................................................................................. 39 5.3 Granularity on the function level.................................................................. 40 6. CONCLUSION AND FUTURE WORK ....................................................................... 42 6.1 Conclusion ................................................................................................... 42 6.2 Future work ................................................................................................. 43 6.1.1 Optimizations .............................................................................. 43 6.1.2 Features ...................................................................................... 44 REFERENCES ............................................................................................................... 45 BIOGRAPHICAL INFORMATION .................................................................................. 47 vii LIST OF ILLUSTRATIONS Figure Page 2.1 Example