250 likes | 443 Views
ESMF Code Generation with Cupid Update and Demo October 2009. Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing. Goals. Cupid supports programmers of numerical Earth System Models by:
E N D
ESMF Code Generationwith CupidUpdate and DemoOctober 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing
Goals • Cupid supports programmers of numerical Earth System Models by: • Raising the level of abstraction so that modelers can think and code in terms of ESM vocabulary—not in terms of low or intermediate level programming constructs • Validating coupling configurations at compile time; providing error messages • Automatically generating FORTRAN code for coupling Earth System Modeling Framework (ESMF) components
Process Overview – Inputs & Outputs • You have: • Fortran source code for two (or more) ESMF Gridded Components • You put in: • A description of those components • A description of a coupling configuration: composition, schedule, and deployment • You get out: • Fortran source code for an ESMF driver and an ESMF coupler component
Cupid Architecture Textual syntax and text editor (based on Xtext) ESMF Code Generation ESMF Coupler Generator JFOM Instances JFOM Instances JFOM Instances ESMF Driver Generator FORTRAN Code Generation ESMF Conceptual Modeling ESMF Configuration Instance ESMF Configuration Instance ESMF Configuration Instances (ECIs) ECM Modeling GUI Java Fortran Object Model (JFOM) ESMF Conceptual Model (ECM) StringTemplate Eclipse Modeling Framework (EMF)
Cupid Architecture Textual syntax and text editor (based on Xtext) ESMF Code Generation ESMF Coupler Generator ESMF Driver Generator FORTRAN Code Generation ESMF Conceptual Modeling ESMF Configuration Instances (ECIs) JFOM Instances ECM Modeling GUI Java Fortran Object Model (JFOM) ESMF Conceptual Model (ECM) StringTemplate Eclipse Modeling Framework (EMF)
Cupid Architecture Textual syntax and text editor (based on Xtext) ESMF Code Generation ESMF Coupler Generator ESMF Driver Generator FORTRAN Code Generation ESMF Conceptual Modeling ESMF Configuration Instances (ECIs) JFOM Instances ECM Modeling GUI Java Fortran Object Model (JFOM) ESMF Conceptual Model (ECM) StringTemplate Eclipse Modeling Framework (EMF)
The ESMF Conceptual Model (ECM) • A conceptual model of ESMF API: • Gridded and Coupler Component, Import/Export State • Virtual Machine, PETs, DELayout • DistGrid, Array • Field, Grid (partial) • Not included (yet): Clock, Calendar • Also includes new structures for describing coupling configurations: • Composition – how the components are connected • Schedule – order of execution of components • Deployment – map components to physical resources
Cupid Architecture Textual syntax and text editor (based on Xtext) ESMF Code Generation ESMF Coupler Generator ESMF Driver Generator FORTRAN Code Generation ESMF Conceptual Modeling ESMF Configuration Instances (ECIs) JFOM Instances ECM Modeling GUI Java Fortran Object Model (JFOM) ESMF Conceptual Model (ECM) StringTemplate Eclipse Modeling Framework (EMF)
Cupid Architecture Textual syntax and text editor (based on Xtext) ESMF Code Generation ESMF Coupler Generator ESMF Driver Generator FORTRAN Code Generation ESMF Conceptual Modeling ESMF Configuration Instances (ECIs) JFOM Instances ECM Modeling GUI Java Fortran Object Model (JFOM) ESMF Conceptual Model (ECM) StringTemplate Eclipse Modeling Framework (EMF)
System Architecture Textual syntax and text editor (based on Xtext) ESMF Code Generation ESMF Coupler Generator JFOM Instances JFOM Instances JFOM Instances ESMF Driver Generator FORTRAN Code Generation ESMF Conceptual Modeling ESMF Configuration Instances (ECIs) ECM Modeling GUI Java Fortran Object Model (JFOM) ESMF Conceptual Model (ECM) StringTemplate Eclipse Modeling Framework (EMF)
System Architecture Textual syntax and text editor (based on Xtext) ESMF Code Generation ESMF Coupler Generator ESMF Driver Generator FORTRAN Code Generation ESMF Conceptual Modeling ESMF Configuration Instances (ECIs) JFOM Instances ECM Modeling GUI Java Fortran Object Model (JFOM) ESMF Conceptual Model (ECM) StringTemplate Eclipse Modeling Framework (EMF)
Building a Coupling Configuration • There are two ways to create a coupling configuration (ESMF Configuration Instance): • Graphically using a tree-based model editor • Using a textual syntax and Eclipse-based editor • At the end of the day, both are represented as instances of the ESMF Conceptual Model. • The two formats are interchangeable
Case Studies • ESMF_ArrayRedistSTest • Two components, one-way coupling • user_model1 populates 100x150 global array • user_model2 verifies array data • user_model1 runs on 4 processors (PETs) with a 4x1 DELayout (i.e., four 25x150 local arrays) • user_model2 runs on 2 PETs with a 1x2 DELayout (i.e., two 100x75 local arrays) • ESMF_FieldSparseMatMulSTest • Similar to above except data is packaged in Fields and redistribution is done via ESMF_ArraySMM
Models and Instances ESMF Conceptual Model (ECM) Java Fortran Object Model (JFOM) FORTRAN 90 ISO Standard Model level conform ESMF Configuration Instance (ECI) JFOM Instance FORTRAN source code Instance level transform transform
Current Status • ECM is partially complete (~70%) • missing some elements from the ESMF API • JFOM is partially complete (~33%) • missing FORTRAN constructs • Code generator is “rigid” • geared toward the two system test cases • needs to be stretched with real world models • Hurdles • How to best represent interpolation weights for Sparse Matrix Multiply.
Future Work • Examples, examples, examples • Need to generate couplers for more realistic models • Discussions with modelers/scientists • How can code generation increase productivity, simplify coding, and enhance model understanding? • Coupling in general • What are the hard parts of coupling models? How can this system address them?
Thanks! Questions? code generation Springtime has finally come a happy climate
Existing Infrastructure Pieces • Eclipse Modeling Framework • http://www.eclipse.org/emf/ • “…a modeling framework and code generation facility for building tools and other applications based on a structured data model” • Models are built using a UML-like, object-oriented metamodel called Ecore • StringTemplate • http://www.stringtemplate.org/ • a Java-based template engine for generating formatted text output • templates are strings with “holes” that can be populated programmatically and then output
JFOM: Fortran Conceptual Model • ECIs are input to the code generation phase. We need an API for manipulating Fortran programs. • Java Fortran Object Model (JFOM) • built with the Eclipse Modeling Framework • a set of Java classes that represent the syntactic structures of Fortran programs • based on the Fortran 90 grammar • allows programmatic manipulation of Fortran programs • JFOM instances are serialized with StringTemplate
JFOM Classes JFOM classes represent the syntactic structures of Fortran 90
Generated Code Examples • Examples of generated code can be found here: • http://swiki.cc.gatech.edu:8080/Curator/49