Eindhoven University of Technology MASTER Extracting GXF Models
Total Page:16
File Type:pdf, Size:1020Kb
Eindhoven University of Technology MASTER Extracting GXF models from C code towards LIME-ng tool-chain for dtaflow models Deshpande, A.S. Award date: 2010 Link to publication Disclaimer This document contains a student thesis (bachelor's or master's), as authored by a student at Eindhoven University of Technology. Student theses are made available in the TU/e repository upon obtaining the required degree. The grade received is not published on the document as presented in the repository. The required complexity or quality of research of student theses may vary by program, and the required minimum study period may vary in duration. General rights Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights. • Users may download and print one copy of any publication from the public portal for the purpose of private study or research. • You may not further distribute the material or use it for any profit-making activity or commercial gain Extracting GXF Models from C Code: towards LIME - next generation for Dataflow Models Aditya S. Deshpande August 2010 TECHNISCHE UNIVERSITEIT EINDHOVEN Department of Mathematics & Computer Science Software Engineering & Technology Master Thesis Extracting GXF Models from C Code towards LIME-ng Tool-chain for Dataflow models by Aditya S. Deshpande (0728718) Supervisors: dr. ir. Tom Verhoeff Pjotr Kourzanov, ir. Yanja Dajsuren, PDEng. August 2010 Preview This thesis introduces the LIME - next generation (LIME-ng) toolchain. LIME-ng was implemented at NXP Semiconductors B.V. Eindhoven. The project was developed in the department of media and signal processing at NXP research. The toolchain comprises of four independent tools. The tools developed as a part of LIME-ng toolchain include: • Extracting GXF Models from C code, by Aditya S. Deshpande, • Model Transformation tool for Dataflow Model Transformations [20], by Swaraj Bhat, • Generating C code from Platform Specific Model [42], by Nishanth Sudhakara Shetty and • Visualization of Dataflow Models [36], by Namratha Nayak. The first part (Part 1) of this thesis gives an introduction to the project undertaken and is common for all the thesis mentioned above. Parallel computing is a form of computation in which many calculations are carried out simultaneously [18], operating on the principle that large problems can often be divided into smaller ones, which are then solved concurrently ("in parallel"). With new advances in technology, the study of parallel systems has reached new magnitudes. The power of parallel systems for computational purposes is almost universal now. The result of this is a multitude of parallel systems. This might seem as an asset, but like every other thing it comes with its own set of drawbacks. All these parallel systems are mainly independent of each other, in the sense that they have their own architecture, their own memory models, etc. A particular application may work more efficiently on one parallel system but may not on another parallel system. An application developer may choose to develop a particular application on one of the parallel systems which he thinks is most apt. Later, if the application does not work as efficiently and as expected on the chosen parallel system then the developer has no other choice but to move the application to some other parallel system or rewrite the application. This move currently compels the application developer to start the development process again from scratch. i A way to overcome these problems is to provide a level of abstraction over the existing parallel systems/parallel languages. Abstraction is espe- cially important given the apparent diversity of different communication and synchronization mechanisms found in modern embedded platforms, often possessing heterogeneous multi-cores and accelerators operating in parallel to run the necessary application. On first thoughts, a single layer of abstraction should solve the problem. Library API's of parallel languages can be used as an abstraction layer to cover the bridge between the different parallel systems. Unfortunately, these API's are confined to specific architectures and cannot be easily migrated. Therefore, there is a need to introduce yet another layer of abstraction, this layer should allow the translation of the application to any programming language, giving the application developer the capability to develop an ap- plication once in any language, translate it into any other programming language and run it on its respective parallel hardware. The question thus is how to implement these abstractions as a practi- cal and feasible implementation. The answer to this question leads us to the development of a comprehensive tool chain which we refer to as LIME - next generation (LIME-ng). This tool chain can create dataflow models, transform these models into various platform specific representations and then translate them into their respective parallel language. The above men- tioned tool chain will also be incorporated with visual editing and graphical support. The task of implementing LIME-ng has been divided among four work packages. The tools to be developed will have the following functionalities: 1. Extracting GXF Models from C code - This tool handles the conversion of platform independent C code into a dataflow model for transforma- tion purposes. 2. Model Transformation tool for Dataflow Model Transformations - This tool applies a series of model transformations on an input dataflow model to make it more platform specific [20]. 3. Generating C code from Platform Specific Model - This tool translates the platform specific dataflow model to its corresponding C code and also provides error locating capabilities [42]. 4. Visualization of Dataflow Models - This tool provides visualization and editing capabilities to the dataflow model obtained from the GXF. [36]. ii Acknowledgement The success of any task will be incomplete without complimenting those who made it possible and whose guidance and encouragement made our effort successful. We are indebted to many people for making this project reach its logical ending. We sincerely express our thanks and gratitude to Dr. Tom Verhoeff who has been there for us at every cornerstone. We heartily thank ir. Pjotr Kourzanov from NXP Semiconductor, Eind- hoven whose encouragement, support, guidance and able supervision led us to the understanding and subsequent completion of this project. He has been a constant pillar of support and guidance right from the preliminary level to the concluding. We would also like to thank Yanja Dajsuren, PDEng. from Virage Logic for her timely evaluations and constructive remarks all throughout the project period. We also thank ir. Protic Zvezdan for his valuable guidance and support during the development of the Eclipse plugin. We owe our deepest gratitude to Dr. Manohara Pai M.M. our programme director and Dr. Radhika M. Pai, H.O.D., Department of I & CT, MIT, Manipal for providing us with their able guidance and moral support at every step during this project. Last but not the least we would like to thank the almighty for giving us the strength and our families & friends for trusting us and being there during all the ups and downs in the project. Aditya S Deshpande Namratha Nayak Nishanth Sudhakara Shetty Swaraj Bhat iii iv Contents Preview i I Introduction 1 1 Domain Information 3 2 Challenges 5 2.1 Motivation . 5 2.2 Dataflow Models . 6 2.3 GXF and DTD . 7 3 Existing Prototype 9 3.1 LIME . 9 3.1.1 Compilation flow . 10 3.2 LIMEclipse . 11 4 LIME-next generation 15 4.1 General Architecture . 15 4.2 Code to Model Transformation . 17 4.3 Model Transformation . 17 4.4 Visualization . 18 4.5 Unparsing . 20 4.6 Implementation Language - Functional Programming . 21 4.6.1 Benefits of Functional Programming: . 21 4.6.2 Why BIGLOO Scheme? . 22 II Extracting GXF Models from C Code 25 5 Recognizers and Parsers 29 5.1 Recognizers . 29 v 6 CIGLOO and Extensions 35 6.1 CIGLOO . 35 6.2 Analysis of the CIGLOO parser . 37 7 Implementations 53 7.1 Standardising the AST . 53 7.2 Formatting . 58 7.2.1 Pattern Matching . 58 7.3 Module translate read-ast . 60 7.4 Module SizeOf . 61 7.4.1 Structure Padding . 63 8 Validation and Performance Measurements 65 8.1 GLPK . 68 8.2 Graphviz . 69 8.2.1 SizeOf library . 70 8.2.2 ModifyAst library . 72 8.3 Performance Measurements . 72 8.4 Software metric . 73 8.5 Pmccabe . 74 9 Related work 79 9.1 Edison Design Group . 79 9.2 C Intermediate language (CIL) . 80 9.3 Src2srcML . 82 9.4 Columbus . 84 9.5 Design Maintenance System (DMS) . 85 10 Conclusion and Future Work 87 10.1 Conclusion . 87 10.2 Future Work . 88 Bibliography 90 Appendices 96 A Structure of CIGLOO Grammar 97 B Graphviz Test Results 101 C Links to the Source Files 103 vi List of Figures 2.1 An example dataflow graph with 4 nodes and 5 edges . 7 3.1 LIME tool-chain compilation flow[34]. 11 3.2 A dataflow model in LIMEclipse . 12 4.1 General Architecture of LIME-ng . 16 4.2 Example of the visual representation of a simple Dataflow graph with three nodes and edges between them. 19 4.3 Architecture of the tool developed. 27 5.1 An example for lookahead . 30 7.1 Architecture of Engine Modify module. 54 7.2 Representation of the AST for Case 1 . 56 7.3 Representation of the AST for Case 2 . 57 8.1 Package structure of Cigloo1.1 . 71 8.2 Pmccabe tool result page. 75 8.3 Graph of LOC vs Time taken for parsing and pretty printing 76 8.4 Graph of McCabe complexity vs Time taken for parsing and pretty printing .