Скачать презентацию Tamara Dahlgren Tom Epperly Scott Kohn Gary Скачать презентацию Tamara Dahlgren Tom Epperly Scott Kohn Gary

8c4b7686ba350397b4f72861429b8627.ppt

  • Количество слайдов: 61

Tamara Dahlgren, Tom Epperly, Scott Kohn, & Gary Kumfert Center for Applied Scientific Computing Tamara Dahlgren, Tom Epperly, Scott Kohn, & Gary Kumfert Center for Applied Scientific Computing

Audience Calibration What is a component? Who writes code? Who uses code? What languages Audience Calibration What is a component? Who writes code? Who uses code? What languages used? What platforms used? # 3 rd party libraries your code uses? # apps uses your libraries? CASC GKK 2

Outline Problem Motivation Babel Solution Strategy SIDL Using Babel Outstanding Problems Future R&D CASC Outline Problem Motivation Babel Solution Strategy SIDL Using Babel Outstanding Problems Future R&D CASC GKK 3

Problem Motivation Code Reuse is Hard. Scientific Barriers Code Reuse is Harder! to Reuse. Problem Motivation Code Reuse is Hard. Scientific Barriers Code Reuse is Harder! to Reuse. . . ¢ Language Interoperability ¢ Semantics ¢ Software Portability ¢ Lack of Standards ¢ More. . . CASC GKK 4

What I mean by “Language Interoperability” Scripting Driver (Python) Simulation Framework (C) Numerical Routines What I mean by “Language Interoperability” Scripting Driver (Python) Simulation Framework (C) Numerical Routines (f 77) CASC Solver Library (C++) Visualization System (Java) Callback Handlers (Python) GKK 5

Current Language Interoperability Native f 77 cfortran. h f 90 C SWIG JNI C++ Current Language Interoperability Native f 77 cfortran. h f 90 C SWIG JNI C++ Python Siloon Chasm Java CASC Platform Dependent GKK 6

Babel Enabled Language Interoperability f 77 C f 90 C++ Python Java CASC GKK Babel Enabled Language Interoperability f 77 C f 90 C++ Python Java CASC GKK 7

Babel Enabled Language Interoperability f 77 What’s in version 0. 6? C f 90 Babel Enabled Language Interoperability f 77 What’s in version 0. 6? C f 90 C++ Python Java CASC GKK 8

Outline Problem Motivation Babel Solution Strategy SIDL Using Babel Outstanding Problems Future R&D CASC Outline Problem Motivation Babel Solution Strategy SIDL Using Babel Outstanding Problems Future R&D CASC GKK 9

Developer Writes Interface SIDL interface description SIDL: Scientific Interface Definition Language Similar ¢ to Developer Writes Interface SIDL interface description SIDL: Scientific Interface Definition Language Similar ¢ to CORBA/COM IDLs. . . Language/Platform Independent . . . but ¢ ¢ CASC tuned for scientific apps complex numbers dynamic, multidimensional arrays GKK 10

version My. Solver. Lib 0. 1. 0; import ESI; package My. Solver. Lib { version My. Solver. Lib 0. 1. 0; import ESI; package My. Solver. Lib { interface Matrix. Generator {. . . } class Option. Database { void get. Option( in string name, out string val ); } class Vector implements-all ESI. Vector { void set. Options( in Option. Database db ); } abstract class Bizarre implements Matrix. Generator { abstract int foo(); void set. Data( in array a ); } CASC GKK 11

Babel Generates Glue Code XML repository interface description machine configuration database XML C C++ Babel Generates Glue Code XML repository interface description machine configuration database XML C C++ SIDL interface description parser analyzer backend F 77 Python Java F 90 Matlab? CASC GKK 12

Babel Provides Uniform Object Model f 77 Universal Base Classes Virtual Method Dispatch f Babel Provides Uniform Object Model f 77 Universal Base Classes Virtual Method Dispatch f 90 C Exception Reference C++ Handling Counting Python. . . It all happens here! Java CASC GKK 13

Babel Provides a Firewall Between Use and Implementation Application Stubs SIDL interface description IORs Babel Provides a Firewall Between Use and Implementation Application Stubs SIDL interface description IORs Skels Impls CASC GKK 14

Outline Problem Motivation Babel Solution Strategy SIDL Using Babel Outstanding Problems Future R&D CASC Outline Problem Motivation Babel Solution Strategy SIDL Using Babel Outstanding Problems Future R&D CASC GKK 15

SIDL as a text-based design tool Express only the public API Prevents discussion drift SIDL as a text-based design tool Express only the public API Prevents discussion drift into implementation details Amenable Easier CASC to email debates to learn than UML GKK 16

The SIDL Grammar Packages & Versions Interfaces & Classes Inheritance Model Methods Polymorphism Intrinsic The SIDL Grammar Packages & Versions Interfaces & Classes Inheritance Model Methods Polymorphism Intrinsic Modifiers Data Types Parameter Modes Gotchas CASC GKK 17

Packages version foo 1. 0; package foo { //. . . }; package gov Packages version foo 1. 0; package foo { //. . . }; package gov { package llnl { package babel { //. . . }; }; }; CASC Use SIDL packages to prevent symbol conflicts ¢ packages in Java ¢ namespaces in C++ ¢ prefixes in C / Fortran (e. g. mpi_send() ) must have version number lowercase symbols recommended Can be nested Versioning applies only to outermost package Currently not reentrant by design GKK 18

Interfaces and Classes Objective. C and Java Inheritance Model Interfaces ¢ ¢ ¢ pure Interfaces and Classes Objective. C and Java Inheritance Model Interfaces ¢ ¢ ¢ pure abstract base classes in C++ define calling sequence only provide no implementation cannot be instantiated can inherit (“extend”) other interfaces Classes ¢ ¢ CASC inherit (“extend”) from at most one class (including its implementation) may inherit (“implement”) multiple interfaces GKK 19

Interfaces and Classes (Example) version their 1. 0; package their { interface Foo {/*. Interfaces and Classes (Example) version their 1. 0; package their { interface Foo {/*. . */}; interface Bar {/*. . */}; interface Baz {/*. . */}; }; version my 1. 12; // import their; package my { interface Foo extends their. Foo { }; class CFoo implements Foo { }; class Bar extends CFoo implements their. Bar { }; class Baz extends CFoo implements their. Bar, their. Baz { }; }; CASC GKK 20

Inheritance Model Interfaces form contracts between implementor and user. Default ¢ ¢ Inheritance: SIDL. Inheritance Model Interfaces form contracts between implementor and user. Default ¢ ¢ Inheritance: SIDL. Base. Interface reference counting s ex nt e dynamic casting te nd em pl s introspection im reflection SIDL. Base. Class ex ten ds (interfaces) (classes) CASC GKK 21

Abstract Class– Partially Implemented Class interface Foo { int do. This( in int i Abstract Class– Partially Implemented Class interface Foo { int do. This( in int i ); int do. That( in int i ); } interface abstract class Bar implements Foo { int i in int do. This( indo. This(); int i ); }; int do. That( in int i ); } class Grille implements-all Foo { // int Foo { abstract implementsdo. This( in int class Bar implements Foo {i ); // int do. That( int do. This( in int i ); }; }; class Grille implements Foo { int do. This( in int i ); int do. That( in int i ); }; CASC GKK 22

Methods (a. k. a. “member functions”) Belong to both Interfaces and Classes SIDL ¢ Methods (a. k. a. “member functions”) Belong to both Interfaces and Classes SIDL ¢ ¢ ¢ In has no sense of method “access” specifiers (e. g. private, protected, public) All methods in SIDL are public Makes sense for an “Interface Definition Language” practice, can make package and private methods. In classes only, methods can also be ¢ static -- independent of an instance ¢ final -- not overridden by derived classes No CASC Method Overloading Yet. GKK 23

Method Modifiers static ¢ avoid OOP altogether: make one class full of static methods. Method Modifiers static ¢ avoid OOP altogether: make one class full of static methods. class Math { static double sin( in double x ); static double cos( in double x ); }; final ¢ ¢ CASC prevent function from being overridden In C++ umethods are final by default umust be declared “virtual” to be overridden GKK 24

Intrinsic Data Types Standard ¢ ¢ ¢ ¢ Types bool char int long float Intrinsic Data Types Standard ¢ ¢ ¢ ¢ Types bool char int long float double fcomplex dcomplex Advanced ¢ ¢ ¢ string enum object (interface or class) array< Type, Dimension > opaque NOTES: ¢ ¢ CASC Types Mapped to different types in different languages No General Template Mechanism GKK 25

Parameter Modes Unique Each ¢ ¢ ¢ to IDLs parameter in a method call Parameter Modes Unique Each ¢ ¢ ¢ to IDLs parameter in a method call has a mode declared in out inout Intent: ¢ ¢ Communication optimization for distributed components Copy minimization when copy is unavoidable Benefit: ¢ CASC Easy to understand intent when reading GKK 26

Parameter Modes II “in” ¢ pass by value semantics (not const!) “out” ¢ ¢ Parameter Modes II “in” ¢ pass by value semantics (not const!) “out” ¢ ¢ ¢ pass by reference semantics no initialization required information returned “inout” ¢ ¢ CASC pass by reference semantics initialization required new information returned instance may be destroyed and replaced GKK 27

Parameter Modes III package util { // SIDL FILE class String { static void Parameter Modes III package util { // SIDL FILE class String { static void reverse( inout string ); }; DANGER: }; “inout” parameters may be #include destroyed and replaced #include “util_String. h” under the covers. Do you want to risk a int main () { char * hi = “Hello. ”; “free(hi); ” in the stubs? ? ? util_String_reverse( &hi ) ; printf(“%sn”, hi ); } CASC GKK 28

Parameter Modes IV package util { // SIDL FILE class String { static void Parameter Modes IV package util { // SIDL FILE class String { static void append. Reverse(inout string); }; }; #include #include “util_String. h” int main () { char * hi = “Hello. ”; util_String_append. Reverse( &hi ) ; printf(“%sn”, hi ); } CASC GKK 29

Parameter Modes V package util { // SIDL FILE class String { static void Parameter Modes V package util { // SIDL FILE class String { static void append. Reverse(inout string); }; #include }; #include #include “util_String. h” int main () { char * hi = strdup( “Hello. ” ); util_String_append. Reverse( &hi ) ; printf(“%sn”, hi ); free( hi ); } CASC GKK 30

// This is a comment Babel is a Comment Doc. Comments Preserves Too */ // This is a comment Babel is a Comment Doc. Comments Preserves Too */ /* This /** This is a Doc. Comment for the package */ package Hello { /** * This class has one method */ class World { /** result = “hello” + name */ string get. Msg( in string name ); }; }; CASC GKK 31

SIDL Gotchas Case ¢ ¢ Sensitive SIDL is F 77 is not Reserved ¢ SIDL Gotchas Case ¢ ¢ Sensitive SIDL is F 77 is not Reserved ¢ ¢ Words: union of C, C++, Fortran C++ has 90+ reserved words! Forbidden ¢ Method Names same as class name (reserved in C++) Built-in method names start with “_” to avoid collisions with user defined names. CASC GKK 32

Outline Problem Motivation Babel Solution Strategy SIDL Using Babel Outstanding Problems Future R&D CASC Outline Problem Motivation Babel Solution Strategy SIDL Using Babel Outstanding Problems Future R&D CASC GKK 33

Getting The Software Grab ¢ ¢ tarball http: //www. llnl. gov/CASC/components/software. html Current release: Getting The Software Grab ¢ ¢ tarball http: //www. llnl. gov/CASC/components/software. html Current release: babel-0. 6. 3. tar. gz Typical ¢ ¢ build/install (using VPATH) gtar zxvf babel-0. 6. 3. tar. gz cd babel-0. 6. 3 -build/. . /babel-0. 6. 3/configure --prefix=${HOME}/babel gmake all check install Platforms ¢ ¢ CASC Tested Nightly: Linux ( GNU, KCC) Solaris ( GNU ) GKK 34

The Babel Compiler – commandline options Choose exactly one --help --version --parse-check --xml --client=[lang] The Babel Compiler – commandline options Choose exactly one --help --version --parse-check --xml --client=[lang] --server=[lang] of the following: Display more info Babel Version Parse SIDL, no output Generate XML User of Babel Object Developer of Babel Object Other Options --output-directory=[dir] --repository-path=[path] --generate-subdirs CASC Default =. Semicolon separated URLs GKK 35

Babel from a developer’s POV Application Stubs SIDL interface description IORs Skels Impls CASC Babel from a developer’s POV Application Stubs SIDL interface description IORs Skels Impls CASC GKK 36

hello. sidl /** This is a Doc. Comment for the package */ version hello hello. sidl /** This is a Doc. Comment for the package */ version hello 1. 0; package hello { class World { void set. Name( in string name ); /** result = “Hello ” + name + “!”*/ string get. Msg( ); }; }; CASC GKK 37

Adding the Implementation namespace hello { class World_impl { private: // DO-NOT-DELETE splicer. begin(hello. Adding the Implementation namespace hello { class World_impl { private: // DO-NOT-DELETE splicer. begin(hello. World. _implementation) // Put additional implementation details here. . . // DO-NOT-DELETE splicer. end(hello. World. _implementation) string hello: : World_impl: : get. Msg () throw () { // DO-NOT-DELETE splicer. begin(hello. World. get. Msg) // insert implementation here // DO-NOT-DELETE splicer. end(hello. World. get. Msg) } CASC GKK 38

Adding the Implementation namespace hello { class World_impl { private: // DO-NOT-DELETE splicer. begin(hello. Adding the Implementation namespace hello { class World_impl { private: // DO-NOT-DELETE splicer. begin(hello. World. _implementation) string d_name; // DO-NOT-DELETE splicer. end(hello. World. _implementation) string hello: : World_impl: : get. Msg () throw () { // DO-NOT-DELETE splicer. begin(hello. World. get. Msg) string msg(“Hello “); return msg + d_name + “!”; // DO-NOT-DELETE splicer. end(hello. World. get. Msg) } CASC GKK 39

Babel Generates LOTS of Code!!! hello. sidl 9 Hand added Implementation 4 Generated C/C++ Babel Generates LOTS of Code!!! hello. sidl 9 Hand added Implementation 4 Generated C/C++ code (wc –l *) CASC 4, 107 GKK 40

Babel from a user’s POV Application Stubs SIDL interface description libfoo. so CASC GKK Babel from a user’s POV Application Stubs SIDL interface description libfoo. so CASC GKK 42

A driver in C #include <stdio. h> #include A driver in C #include #include "hello. h" int main(int argc, char ** argv ) { hello_World hw; char * msg; hw = hello_World__create(); hello_World_set. Name( hw, argv[1] ); msg = hello_World_get. Msg( hw ); fprintf(stdout, "%s", msg ); free( msg ); hello_World_delete. Reference( hw ); } CASC GKK 43

A driver in Python import hello. World if __name__ = ‘__main__’: h = hello. A driver in Python import hello. World if __name__ = ‘__main__’: h = hello. World() h. set. Name( ‘Gary’ ) print h. get. Msg() CASC GKK 44

Outline Problem Motivation Babel Solution Strategy SIDL Using Babel Outstanding Problems Future R&D CASC Outline Problem Motivation Babel Solution Strategy SIDL Using Babel Outstanding Problems Future R&D CASC GKK 45

Common Problems $CLASSPATH compilers Python not set not found ($CC, $CXX, $F 77) or Common Problems $CLASSPATH compilers Python not set not found ($CC, $CXX, $F 77) or Num. Py not installed Server-side Python requires libpython. so (Not in standard distributions) LD_LIBRARY_PATH C++ CASC issues with shared libraries and shared libraries GKK 46

Achilles’ Heel Babel Generates Correct Code It does nothing about correct compilation CASC GKK Achilles’ Heel Babel Generates Correct Code It does nothing about correct compilation CASC GKK 47

sun-sparc-solaris 2. 7 -gcc 2. 95. x Babel Test History: CASC GKK 49 sun-sparc-solaris 2. 7 -gcc 2. 95. x Babel Test History: CASC GKK 49

Outline Problem Motivation Babel Solution Strategy SIDL Using Babel Outstanding Problems Future R&D CASC Outline Problem Motivation Babel Solution Strategy SIDL Using Babel Outstanding Problems Future R&D CASC GKK 51

Platform Independence Encourage Locality for Maximum Performance Connect ¢ to separate process space to Platform Independence Encourage Locality for Maximum Performance Connect ¢ to separate process space to avoid symbol conflicts at link time Connect ¢ ¢ ¢ CASC to separate machine to utilize special hardware to use platform specific code (Babel doesn’t get Windows apps to run on UNIX!) To distribute work GKK 52

Same Process Space Components Application Stubs IORs Skels Impls CASC GKK 53 Same Process Space Components Application Stubs IORs Skels Impls CASC GKK 53

Out of Process Components Application Stubs IPC IORs IPC Skels Impls CASC GKK 54 Out of Process Components Application Stubs IPC IORs IPC Skels Impls CASC GKK 54

Remote Components Application Line Protocol Stubs Unmarshaler IORs Internet Marshaler Skels Line Protocol Impls Remote Components Application Line Protocol Stubs Unmarshaler IORs Internet Marshaler Skels Line Protocol Impls CASC GKK 55

Parallel Components: Mx. N Communication CASC GKK 56 Parallel Components: Mx. N Communication CASC GKK 56

Problem Motivation Code Reuse is Hard. Scientific Barriers Code Reuse is Harder! to Reuse. Problem Motivation Code Reuse is Hard. Scientific Barriers Code Reuse is Harder! to Reuse. . . ¢ Language Interoperability ¢ Semantics ¢ Software Portability ¢ Lack of Standards ¢ More. . . CASC Tammy Dahlgren’s Ph. D Thesis GKK 57

Problem Motivation Code Reuse is Hard. Scientific Barriers Code Reuse is Harder! to Reuse. Problem Motivation Code Reuse is Hard. Scientific Barriers Code Reuse is Harder! to Reuse. . . ¢ Language Interoperability ¢ Semantics ¢ Software Portability ¢ Lack of Standards ¢ More. . . CASC Whitepaper GKK 58

How do I find out more? ? ? Website User’s http: //www. llnl. gov/CASC/components How do I find out more? ? ? Website User’s http: //www. llnl. gov/CASC/components Guide Download Code Email ¢ ¢ Reflectors (subscribe via majordomo@lists. llnl. gov) babel-users@llnl. gov babel-announce@llnl. gov Email ¢ CASC the team components@llnl. gov GKK 59

The End CASC GKK 60 The End CASC GKK 60

Business Component Frameworks CORBA 4 Language Independent 4 Wide Industry Acceptance 4 Primarily Remoting Business Component Frameworks CORBA 4 Language Independent 4 Wide Industry Acceptance 4 Primarily Remoting Architecture Enterprise Java Beans (EJB) 4 Platform Independent 4 Runs wherever Java does COM 4 Language Independent 4 Most Established 4 In Process Optimization 4 Network Transparent CASC GKK 61

Science Business Component Frameworks 1. CORBA 1. Language Independent 2. Wide Industry Acceptance 3. Science Business Component Frameworks 1. CORBA 1. Language Independent 2. Wide Industry Acceptance 3. Primarily Remoting Architecture 4. Huge Standard 5. No In-Process Optimization COM 1. Language Independent 2. Most Established 3. In Process Optimization 4. Network Transparent 5. not Microsoft Transparent 6. Relies on sophisticated development tools CASC Enterprise Java Beans (EJB) 4 Platform Independent 4 Runs wherever Java does 8 Language Specific 8 Potentially highest overhead All The Above 8 No Complex Intrinsic Datatype 8 No Dynamic Multidimensional Arrays 8 No Fortran 77/90/95 bindings 8 No Parallel Components GKK 62

Key to Babel’s Interoperability. . . ma Hu e tibl pa m Co n Key to Babel’s Interoperability. . . ma Hu e tibl pa m Co n SIDL C Scientific Interface Definition Language pil om e tibl pa m Co er IOR Intermediate Object Representation XML e. Xtensible Markup ible Language pat m Co eb W CASC GKK 63

UCRL-VG-142097 REV 1 This work was performed under the auspices of the U. S. UCRL-VG-142097 REV 1 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 CASC GKK 64