310 likes | 442 Views
Cupid A Domain Specific Language for Coupled ESMs. Rocky Dunlap Coupling Workshop 2013. Second Workshop on Coupling Technologies for Earth System Modeling NCAR, Boulder, Colorado, February 20-22, 2013. Outline. Motivation and Goals of Cupid Overview and Current Status Example Application
E N D
CupidA Domain Specific Language for Coupled ESMs Rocky Dunlap Coupling Workshop 2013 Second Workshop on Coupling Technologies for Earth System Modeling NCAR, Boulder, Colorado, February 20-22, 2013
Outline • Motivation and Goals of Cupid • Overview and Current Status • Example Application • Evaluation and Challenges • Future Work
Motivation and Goals • Earth System Modeling software is highly complex • Much effort is spent dealing with accidental details of parallel programming, array manipulations, etc. • Goal of Cupid: Provide significant increases in modeler productivity by raising the level of abstraction of the coupling aspects of ESMs.
Different Kinds of Performance days simulated per hour papers published model scalability modeler productivity # of nodes hours of effort
How does the form of code reuse affect developer productivity?
Cupid Overview Black box Black box Black box Black box White box Coupling Specification (Cupid DSL) Generated Application (Fortran 90) Executable Cupid Compiler Fortran Compiler Maintenance Maintenance link ESMF
Domain Model and Constraints self.fieldConnection->forAll( srcField.scope = self.srcComponent and dstField.scope = self.dstComponent)
Cupid Compiler [template public genESMFInitMethod(c : ESMFGriddedComponent)] subroutine init_(comp, istate, ostate, clock, rc) type(ESMF_GridComp) :: comp type(ESMF_State) :: istate type(ESMF_State) :: ostate type(ESMF_Clock) :: clock integer, intent(out) :: rc ... [for (field : ESMFField | c.item->filter(ESMFField))] [field.name/] = ESMF_FieldCreate(grid=[field.grid.name/], arrayspec=[field.arraySpec.name/], & indexflag=[field.index/], & totalLWidth=[toFortranArrayConstructor(field.totalLWidth)/], & totalUWidth=[toFortranArrayConstructor(field.totalUWidth)/], & name="[field.name/]", rc=rc) [/for] ... [/template] MOF Model to Text Transformation Language (OMG) http://www.omg.org/spec/MOFM2T/1.0/
Eclipse-based Implementation Eclipse Modeling Framework EcoreMetamodel Photran Editor Acceleo Model to Text
Current Status Calls can be generated to ~10% of API methods. 11 of 23 ESMF types represented in DSL.
Case Study: ESMF Coupled Flow Demo
Caution: Some coding required! Inserted Code • reading namelists, setting parameters • set up initial conditions and boundary conditions • field updates for each timestep • calls to halo operations • Modified Code • grid coordinates • grid inheritance • Generated Code • static superstructure • instantiation of components, states, and fields • populating import and export states • calls to child components • coupler component (redist or regrid) • freeing memory
Challenge: DSL Integration • How to integrate with scientific code? • Possible solutions: • Skeleton approach • Developer fills in science implementation • Model interface approach • A set of Fortran subroutines with model fields as subroutine arguments (à la BFG) • Define interfaces using Scientific Interface Description Language (SIDL) • Self-describing models (à la CSDMS BMI)
Challenge: Representing Behavior • Static structural aspects are fairly easy to model • Parent-child relationship of components • Behavioral (dynamic) aspects are more difficult • Populating an ESMF State object with different fields during different points of model execution • Possible solutions • make behaviors implicit (e.g., all fields added during init, remain unchanged during run, removed during finalize) • introduce a behavioral modeling language (adds complexity!)
Conclusion DSL approach is viable for specifying some parts of the coupling infrastructure. Superstructure Components and their composition; driving Different approaches and different tools are required to raise the abstraction level of each of these parts. Science Field updates based on discrete form of PDEs Infrastructure Building blocks: grids, distributed fields, clocks, regrid, redistribution, I/O, configuration, etc.
Future Work • Cupid: An IDE for Model Development and Modeler TrainingNASA Computational Modeling Algorithms and Cyberinfrastructure (CMAC) Program • Team • Georgia Institute of Technology (Dunlap/Mark/Rugaber) • University of Colorado/CIRES (DeLuca) • NASA Software Systems Support Office (Clune) • NASA GISS (Schmidt) • Extend and harden existing DSL+generator into a student training environment for rapidly developing ESMF-based applications • Incorporate more IDE features, including linking with an execution environment • Modularize Model E and demonstrate in IDE
Domain Specific LanguagesIncrease Productivity • Nokia [1] mobile phone app development • 1000% increase in productivity • “shift focus from code to design” • “In many cases, we can generate 100% of the required code.” • US Air Force Military Command and Control Systems [2] • 300% increase in productivity • Lucent Product Family development [3] • initial productivity factor 3x-5x; 10x productivity increase for experts • graphical DSLs more successful than textual
Reuse Techniques Compositional (library, components, frameworks) Generative (domain-specific languages) System Specification Generator
Hybrid Approach Coupling Specification Generator 22
Challenge: Domain Model • There is no universal domain model for coupling • SQL came about after a formal definition of relational databases • Common Information Model (CIM) currently defined as retrospective metadata • Jay Larson’s theory of coupling [4]
Analysis Approach: Extract DSL from an existing system Domain Model Core Language Model Earth System Modeling Framework (ESMF) Language Model Constraints Behavioral Model Strembeck, Mark, and UweZdun. "An approach for the systematic development of domain‐specific languages." Software: Practice and Experience 39.15 (2009): 1253-1292.
What kinds of domains benefit from DSLs? Domain characteristic Evidence in ESM domain Sprinkle, Jonathan, et al. "Guest Editors' Introduction: What Kinds of Nails Need a Domain-Specific Hammer?." IEEE Software 26.4 (2009): 15-18.
Object Constraint Language self.fieldConnection->forAll( srcField.scope = self.srcComponent and dstField.scope = self.dstComponent)
Implementation – Language Model • Language model using Eclipse-based tools • classes, generalization/ specialization, abstract classes • type system • object references, containment • OCL constraints via annotations • automatic generation of model editor GUI
References Kelly, Steven, and Juha-PekkaTolvanen. "Visual domain-specific modeling: Benefits and experiences of using metaCASE tools." International workshop on Model Engineering, European Conference on Object-Oriented Programming (ECOOP) ed. J. Bezivin, J. Ernst. 2000. Kieburtz, Richard B., et al. "A software engineering experiment in software component generation." Proceedings of the 18th international conference on Software engineering. IEEE Computer Society, 1996. Weiss, D. M., and C. T. R. Lai. "Software product line engineering: a family based software engineering process." (1999). J. Walter Larson, "Ten organising principles for coupling in multiphysics and multiscale models," ANZIAM J., 48, C1090-C1111 (2009).