1 / 170

Bridging Languages With Babel

Tutorial. Bridging Languages With Babel. Gary Kumfert Tamara Dahlgren Thomas Epperly James Leek Center for Applied Scientific Computing UCRL-PRES-205332. This work was performed under the auspices of the U.S. Department of Energy by the University

lance
Télécharger la présentation

Bridging Languages With Babel

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tutorial Bridging Languages With Babel Gary Kumfert Tamara DahlgrenThomas Epperly James Leek Center for Applied Scientific Computing UCRL-PRES-205332 This work was performed under the auspices of the U.S. Department of Energy by the University of California, Lawrence Livermore National Laboratory under Contract No. W-7405-Eng-48.

  2. General Housekeeping • You Should Have • Questionnaire • Handouts • Please sign attendance sheet • Please fill out questionnaire

  3. LLNL Babel Team Tamara Dahlgren <dahlgren1@llnl.gov> Tom Epperly <epperly2@llnl.gov> Gary Kumfert <kumfert1@llnl.gov> Jim Leek <leek2@llnl.gov>

  4. Funding History & Statistics • 2000-2002: Funded under LLNL’s LDRD program as the “Components SI” • 2002-present: Funded member of Common Component Architecture Forum under DOE/Office of Science’s SciDAC program • 16 Babel releases since July 2001 • Average >70 downloads/month • Babel used in MD, Optimization, Climate, Chemistry, Meshing, Performance Monitors, EOS, and Solvers • Published 7 Refereed Papers & Proceedings (more in pipeline)

  5. Today’s Outline 1:30 Introduction 2:00 Performance 2:10 SIDL Language 2:40 Babel Tool 3-3:30 Break 3:30 Using Babel Objects 4:00 Building Babel Libraries 4:30 Closing 4:45 Q&A / Demo Adjourn 5:00

  6. I. Introduction

  7. Introduction • Motivation • Language Interoperability Challenges • The Babel Solution • Related Work

  8. Scientific Application Scientific applications are tackling harder problems. • Resulting in an increasing use of, or reliance upon,… • Multi-disciplinary teams • Third-party software (beyond MPI) • Multiple programming languages

  9. Babel’s focus is on scientific language interoperability. Scripting Driver (Python) Simulation Framework (C) Visualization System (Java) Numerical Routines (FORTRAN 77) Solver Library (C++) Callback Handlers (Python)

  10. Introduction • Motivation • Language Interoperability Challenges • The Babel Solution • Related Work

  11. Multi-lingual apps often rely on hand-crafted glue code. • Challenges • Maintaining each language connection • Gluing object-oriented and functional codes together • Ensuring portability These are time consuming and error prone activities!

  12. Fortran 77 Fortran 90 C C++ Python Java Even when using tools, typically O(n2) are needed. … where n is the number of implementation languages.

  13. Introduction • Motivation • Language Interoperability Challenges • The Babel Solution • Related Work

  14. Fortran 77 Fortran 90 C BABEL C++ Python The component’s implementation language. Java Babel reduces interoperability support to a single tool.

  15. Application … … Stub Stub IOR IOR Skeleton Skeleton Implementation Implementation … … Library B Component A Private Data Babel provides Object-Oriented interoperability glue. IOR is the Intermediate Object Representation.

  16. Babel is Object-Oriented, but what does that mean? • Users define classes and interfaces in SIDL. • SIDL objects may be constructed, passed as arguments, or placed in arrays, just like any other object! • The only constraint is that all data is private. Babel only exports methods, so all data access is through callbacks to the implementation.

  17. Interoperability Glue Code Interface Definition BABEL OR Interface Definition Babel technologies consist of two related products. • Compiler • Run-time Library • Object model • Dynamic library loader

  18. Application … Stub Interface Definition BABEL IOR Skeleton Implementation … Library B The compiler generates several layers of glue code.

  19. Human-readable text • Built-in scientific data types • Machine-readable text • Many useful tools available • Repository form • Executable • Fast, single-process communication Babel type information is represented in three forms. Scientific Interface Definition Language eXtensible Markup Language Interface Definitions Intermediate Object Representation

  20. Application Dynamic Library Support • ClassInfo • DLL • Loader • Scope • Resolve • BaseInterface • BaseClass • BaseException • SIDLException Object Model Runtime library enables object management.

  21. = Inheritance The Babel/SIDL object model is based on Java. • Package: Container and namespace for conceptually related set of classes and interfaces. • Interface: Declares a set of abstract, related methods • Class: Defines a set of abstract and/or concrete, related methods • Exception: Standard set of basic methods to elaborate on an unsuccessful execution sidl <<Interface>> BaseInterface BaseClass <<Interface>> BaseException SIDLException

  22. Fortran 77 Fortran 90 C IOR C++ Python Java Non-OO languages support objects through the IOR. The IOR implementation language Recall: IOR is the Intermediate Object Representation.

  23. IOR provides the foundation for object management. • Classes have: • Built-in methods • _cast, _ctor, _dtor, … • Universal base methods • addRef, deleteRef, … • Inherited method(s) • Locally defined method(s)

  24. Babel achieves portability across high end platforms. • IOR in ANSI C • Build relies on GNU tools • Autoconf • Automake • Make • Libtool AIX Linux Solaris … Babel also generates build file helpers (i.e., babel.make and setup.py) for developers to integrate into their build system.

  25. Introduction • Motivation • Language Interoperability Challenges • The Babel Solution • Related Work

  26. Commercial interoperability technologies do exist.

  27. Open Source language interoperability options exist. However, these are all point-to-point solutions.

  28. Other IDL Projects In Scientific Computing • ASE: Argonne SIDL Environment • http://www.mcs.anl.gov/ase • Knepley and Smith @Argonne • Based on Babel-0.6 (Dec’01) • Foundation for PETSc 3.0 • PIDL: Parallel Interface Definition Language • http://www.cs.utah.edu/~damevski/thesis.pdf • Damevski & Parker @SCI Institute, Utah • C++ only • Parallel RMI

  29. II. Performance

  30. Performance overview • How Babel’s design principles address performance • Babel’s method/function call overhead • How to maximize performance

  31. How Babel’s design principles address performance • Correctness is primary — occasionally at the expense of performance • Runtime performance is important • Design tradeoffs impact performance • Natural look-and-feel vs. faster • ::std::string versus char * in C++ • Reducing development time reduces time to solution

  32. Babel’s performance cost is a modest CPU overhead • CPU overhead • Modest increase in cost of function/method calls due to virtual function dispatch • Some overhead per argument depending on type, mode and language due to type translation • Memory overhead • Per object memory >= 32 bytes (in two or more malloc’ed blocks corresponding to IOR & reference counting data) • Memory usage scales with the depth of the type hierarchy • Memory overhead is in addition to your private data

  33. Babel function calls compared to native function calls Timing performed on an 500MHz Intel PIII Babel runtime overhead depends on language and argument type. (µ seconds)

  34. Calling Lang. Called Lang. "Simple" Args. (xF77) Overall Average (xF77) C C 2.6 3.8 C++ C 3.5 6.3 F77 C 2.7 7.3 C C++ 3.9 12.2 C++ C++ 4.9 14.5 F77 C++ 4.1 15.3 C F77 4.1 10.3 C++ F77 4.9 13.3 F77 F77 4.4 14.2 Babel aggregate performance relative to native F77

  35. Babel significantly outperforms in-core CORBA

  36. Overhead is undetectable for coarse grained interfaces • The Babel overhead was undetectable in performance tests with hypre, a scalable linear equation solver library.Kohn, Scott, Gary Kumfert, Jeff Painter, and Cal Ribbens, "Divorcing Language Dependencies from a Scientific Software Library," Proc. 10th SIAM Conf. Parallel Process. Sci. Comput., Portsmouth, VA, March 12-14, 2001.

  37. How to maximize Babel performance • First profile your code to make sure Babel is actually the problem • Avoid strings • Use ordered arrays when indicated • Column-major or row-major • Call with arrays matching the specification • Maximize computation per Babel function call

  38. Proper blocking amortizes interface and array overhead Meshes ranged from 13K to 52K elements. McInnes, et al 2004

  39. References • Bernholdt, Elwasif, Kohl and Epperly,“A Component Architecture for High Performance Computing,”Workshop on Performance Optimization for High-Level Languages and Libraries (POHLL-02) • McInnes, Allan, Armstrong, Benson, Bernholdt, Dahlgren, Diachin, Krishnan, Kohl, Larson, Lefantzi, Nieplocha, Norris, Parker, Ray, and Zhou, “Parallel PDE-Based Simulations Using the Common Component Architecture,” in Bruaset, Bjorstad, and Tveito, editors, Numerical Solution of Partial Differential Equations on Parallel Computers, Springer-Verlag, 2004.

  40. Conclusions • Babel introduces a small overhead • Much cheaper than business component frameworks • Babel’s overhead negligible when… • Sufficiently high granularity • I/O or communication bound • Babel’s overhead a concern when… • Compute bound with fine granularity

  41. III. SIDL Language

  42. SIDL: Scientific Interface Definition Language • Structure • Classes, Interfaces, and Inheritance • Methods, Overloading, and Data Types • XML Representation • Example • Technical Limitations

  43. The SIDL grammar consists of a Java-like syntax. • Packages • Comments • C, C++, and Java style supported • Interfaces • Classes • Methods

  44. final package foo version 1.0 { interface A { void eval (in array<fcomplex,2> a) throws sidl.SIDLException; } package bar { class B implements-all foo.A { } } } Packages provide a name space hierarchy to avoid conflicts. Optional, for non-reentrance Only required if package contains interfaces or classes. Optional nesting

  45. SIDL interfaces and classes support method inheritance.

  46. SIDL supports three inheritance directives. • extends • Used for like-type inheritance • implements • Used when a class is implementing/overriding a subset of the methods inherited from an interface • implements-all • Used when a class is implementing/overriding all of the methods inherited from an interface … interface A { void doA(); }; interface B extends A { void doB(); } class C implements B { void doA(); void doB(); } class D implements-all B { } …

  47. SIDL: Scientific Interface Definition Language • Structure • Classes, Interfaces, and Inheritance • Methods, Overloading, and Data Types • XML Representation • Example • Technical Limitations

  48. SIDL methods are defined through their signatures. All methods are public; otherwise, why expose them?

  49. No native support (C, Fortran, Python) Native support (C++, Java) a_bell.set( 7 ); a_bell.set( 4.5D ); foo_bell_setInt( a_bell, 7 ); foo_bell_setDouble( a_bell, 4.5D ); Overloaded method names vary by implementation language. package foo version 1.5 { … class bell { void set[Int]( in int i ); void set[Double]( in double d ); } } Name extension Short name The tuple <short name, arg types, ordering> assumed unique!

  50. Standard Types bool char int long float double fcomplex dcomplex Advanced Types string enum array< Type, Dimension, Order > opaque Intrinsic Data Types include three scientific types. General template mechanism is not supported.

More Related