25
ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

Embed Size (px)

Citation preview

Page 1: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

ESMF Code Generationwith CupidUpdate and DemoOctober 2009

Rocky DunlapSpencer RugaberLeo MarkGeorgia Tech College of Computing

Page 2: 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:▫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

Page 3: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

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

Page 4: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

Cupid Architecture

ESMF Conceptual Model (ECM)

ECM Modeling GUI

ESMF Conceptual Modeling

ESMF Configuration InstanceESMF Configuration InstanceESMF Configuration Instances (ECIs)

ESMF Driver Generator

ESMF Code Generation

ESMF Coupler Generator

Java Fortran Object Model (JFOM)

FORTRAN Code Generation

JFOM InstancesJFOM InstancesJFOM Instances

StringTemplate Eclipse Modeling Framework (EMF)

Textual syntax and text editor (based on Xtext)

Page 5: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

Cupid Architecture

ESMF Conceptual Model (ECM)

ECM Modeling GUI

ESMF Conceptual Modeling

ESMF Configuration Instances (ECIs)

ESMF Driver Generator

ESMF Code Generation

ESMF Coupler Generator

Java Fortran Object Model (JFOM)

FORTRAN Code Generation

JFOM Instances

StringTemplate Eclipse Modeling Framework (EMF)

Textual syntax and text editor (based on Xtext)

Page 6: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

Cupid Architecture

ESMF Conceptual Modeling

ESMF Configuration Instances (ECIs)

ESMF Driver Generator

ESMF Code Generation

ESMF Coupler Generator

Java Fortran Object Model (JFOM)

FORTRAN Code Generation

JFOM Instances

StringTemplate Eclipse Modeling Framework (EMF)

Textual syntax and text editor (based on Xtext)

ESMF Conceptual Model (ECM)

ECM Modeling GUI

Page 7: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

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

Page 8: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

Graphical Modeling

Page 9: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

Cupid Architecture

ESMF Conceptual Model (ECM)

ECM Modeling GUI

ESMF Conceptual Modeling

ESMF Configuration Instances (ECIs)

ESMF Driver Generator

ESMF Code Generation

ESMF Coupler Generator

Java Fortran Object Model (JFOM)

FORTRAN Code Generation

JFOM Instances

StringTemplate Eclipse Modeling Framework (EMF)

Textual syntax and text editor (based on Xtext)

Page 10: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

Textual Syntax

Page 11: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

Cupid Architecture

ESMF Conceptual Model (ECM)

ECM Modeling GUI

ESMF Conceptual Modeling

ESMF Configuration Instances (ECIs)

ESMF Code Generation

Java Fortran Object Model (JFOM)

FORTRAN Code Generation

JFOM Instances

StringTemplate Eclipse Modeling Framework (EMF)

Textual syntax and text editor (based on Xtext)

ESMF Driver Generator

ESMF Coupler Generator

Page 12: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

System Architecture

ESMF Conceptual Model (ECM)

ECM Modeling GUI

ESMF Conceptual Modeling

ESMF Configuration Instances (ECIs)

ESMF Code Generation

FORTRAN Code Generation

StringTemplate Eclipse Modeling Framework (EMF)

Textual syntax and text editor (based on Xtext)

ESMF Driver Generator

ESMF Coupler Generator

Java Fortran Object Model (JFOM)

JFOM InstancesJFOM InstancesJFOM Instances

Page 13: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

System Architecture

ESMF Conceptual Model (ECM)

ECM Modeling GUI

ESMF Conceptual Modeling

ESMF Configuration Instances (ECIs)

ESMF Code Generation

FORTRAN Code Generation

StringTemplate Eclipse Modeling Framework (EMF)

Textual syntax and text editor (based on Xtext)

ESMF Driver Generator

ESMF Coupler Generator

Java Fortran Object Model (JFOM)

JFOM Instances

Page 14: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

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

Page 15: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

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

Page 16: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

Demo

Page 17: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

Models and Instances

ESMF Conceptual Model (ECM)

ESMF Configuration Instance (ECI)

Java Fortran Object Model

(JFOM)

JFOM Instance

FORTRAN 90ISO Standard

FORTRANsource code

Model level

Instance level

transform transform

conform

Page 18: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

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.

Page 19: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

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?

Page 20: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

Thanks!Questions?

code generationSpringtime has finally come

a happy climate

Page 21: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

Additional slides

Page 22: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

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

Page 23: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

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

Page 24: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

JFOM Classes

JFOM classes represent the syntactic structures of Fortran 90

Page 25: ESMF Code Generation with Cupid Update and Demo October 2009 Rocky Dunlap Spencer Rugaber Leo Mark Georgia Tech College of Computing

Generated Code Examples

•Examples of generated code can be found here:

•http://swiki.cc.gatech.edu:8080/Curator/49