Lawrence Livermore National Laboratory Toward Multi

Download Report

Transcript Lawrence Livermore National Laboratory Toward Multi

Toward Multi-Language, Multi-Component
Interface Contract Enforcement
Workshop on Component-Based High Performance Computing (CBHPC ‘09)
November 15-16, 2009
Tammy Dahlgren and Irina Abramova
[email protected]
[email protected]
Lawrence Livermore National Laboratory, P. O. Box 808, Livermore, CA 94551
This work performed under the auspices of the U.S. Department of Energy by
Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344
LLNL-PRES-420084
Toward Multi-Language, Multi-Component Interface Contract
Enforcement
 Overarching Goal
• Improve the quality of component-based scientific applications
 Approach
• Support specifying
interface contracts
in SIDL*
• Integrate automated
contract enforcement
in the Babel
middleware
 Support enforcement strategies for different software development
life-cycle phases
 Recent Work
• Hardening and expanding enforcement
• Demonstrating enforcement with clients and servers in different languages
• Demonstrating enforcement in multi-component programs
Lawrence Livermore National Laboratory
*SIDL = Scientific Interface Definition Language
2
Toward Multi-Language, Multi-Component Interface Contract
Enforcement
 Motivation and Background
 Contract Enforcement
 Multi-Component Contract Enforcement
Lawrence Livermore National Laboratory
3
Common Component Architecture Forum’s vision of plugand-play components depends on common interfaces.
 Each implementation must conform
to the same specification.
• Require same basic inputs
• Provide same basic services
• Implementations can vary significantly
to include differences in…
 Algorithms
 Solution accuracies
 Underlying data structures
 Implementation language(s)
 C, C++
 FORTRAN 77, Fortran 90, …
 Python
 Java
.…..
Application
Component
Repository
Component
Component
Component
A B C
Different development processes (and rigor)  varying quality
Lawrence Livermore National Laboratory
See http://www.scidac.gov/compsci/TASCS.html.
5
Contracts added to common interface specifications can be
used to improve the quality of the resulting applications.
....
void getEntArrAdj( in array<opaque> entity_handles, in int entity_handles_size,
in EntityType entity_type_requested, inout array<opaque> adj_entity_handles,
out int adj_entity_handles_size, inout array<int> offset, out int offset_size)
throws TSTTB.Error, sidl.PreViolation, sidl.PostViolation;
require /* Precondition clause defines obligations on callers */
passed_entity_handles: entity_handles != null;
handles_is_1d: dimen(entity_handles) = = 1;
handles_size_okay: irange(entity_handles_size, 0, size(entity_handles));
ensure /* Postcondition clause defines obligations on all implementations */
adj_handles_returned: adj_entity_handles != null;
adj_handles_is_1d: dimen(adj_entity_handles) = = 1;
irange(adj_entity_handles_size, 0, size(adj_entity_handles));
offset_returned: offset != null;
dimen(), irange(),
offset_is_1d: dimen(offset) = = 1;
nonDecr(), and
offset_size_okay: offset_size = = entity_handles_size + 1;
size() are built-in
offset_values_okay: irange(offset, 0, offset_size);
SIDL functions
offset_non_decreasing: nonDecr(offset);
available to
claim_no_side_effects: is pure;
O(|offset|)
contract clauses.
Lawrence Livermore National Laboratory
Source: tstt.sidl v0.7 (http://www.tstt-scidac.org/).
6
…
Concerns over the performance overhead of their enforcement
in some software life cycle phases have been addressed.
Program
Initiation
Program
Termination
Total Execution Time
Enforcement
Overhead
Program
Preconditions
Component method(s)
Postconditions
≤ X% ?
Invariants
According to an informal poll*, Computational Scientists are typically willing
to incur no more than 10% overhead when adopting new technologies.
Lawrence Livermore National Laboratory
*Conducted by members of the Common Component Architecture Forum (http://www.cca-forum.org).
7
..
A variety of enforcement policies are supported that include
traditional and sampling-based techniques.
Enforcement
Policy
Always
Never
Decision Basis
Baseline
Contract Clause
Classification*
AllClasses
Constant
Constant
Linear
Linear
Method Calls
Postconditions
Characteristics
MethodCalls
Postconditions
Preconditions
Preconditions
Simple Expressions
SimpleExpressions
Periodic
Random
Adaptive Fit
Adaptive Timing
Sampling
Performance
AllClasses
AllClasses
Enforcement
Frequency*
Always
Never
Always
Periodic
Random
AdaptiveFit
AdaptiveTiming
Lawrence Livermore National Laboratory
*There are actually several more options available, but those listed have been used so far in studies.
8
.
Experiments conducted on multiple single-component
programs provided some insights regarding enforcement.
Chiefly, sufficient work must be performed within the methods (not,
in these cases, in the programs) to offset contract checking.
Lawrence Livermore National Laboratory
Data Source: Dahlgren, CBSE ’07.
*Early experiments conducted using prototype implementation in Babel.
9
Toward Multi-Language, Multi-Component Interface Contract
Enforcement
 Motivation and Background
 Contract Enforcement
 Multi-Component Contract Enforcement
Lawrence Livermore National Laboratory
10
Enforcement routines are automatically generated and
supported by the Babel scientific middleware toolkit.
Annotated
Scientific
Interface
Definition
Language
(SIDL) files
……..
Interface Contract Enforcement
Stub Code
Intermediate Rep
Skeleton Code
Enforcement Execution Traces
Impl Code
Component
or
Library
Lawrence Livermore National Laboratory
11
The path taken through the generated middleware layers
depends on the enforcement policy.
…….
stub_method() {…}
d_epv
epv
cepv
Intermediate
Object
.
.
Representation .
.
(IOR)
.
.
layer
check_method() {…}
Stub
layer
Application
(External)
Component
or Library
Skeleton
layer
skel_method() {…}
Implementation
layer
impl_method() {…}
The associated assertion checks are generated in ANSI C in the IOR layer.
Lawrence Livermore National Laboratory
Enforcement disabled
Enforcement enabled
12
Upcoming release of Babel will illustrate clients in each
programming language calling implementations in others.
C
Python
C++
Client
FORTRAN
77
Java
Fortran 90
…...
package vect version 1.0 {
…
class Utils {
…
static bool vuAreEqual(in array<double> u,
in array<double> v,
in double tol)
throws
sidl.PreViolation;
require
not_null_u : u != null;
u_is_1d : dimen(u) == 1;
not_null_v : v != null;
v_is_1d : dimen(v) == 1;
same_size : size(u) == size(v);
non_negative_tolerance: tol >= 0.0;
ensure
no_side_effects : is pure;
…
}
}
Lawrence Livermore National Laboratory
Based on: ${BABEL}/regression/contracts/vect.sidl
13
The C client calls methods implemented in each of the
programming languages (during separate executions).
…..
#include “sidl_EnfPolicy.h”
…
C
Python
C++
Client
(C)
FORTRAN
77
Java
Fortran 90
int main(int argc, char** argv) {
sidl_BaseInterface exception = NULL;
struct sidl_double__array *u = NULL;
…
u = sidl_double__array_create1d(max_size);
…
sidl_EnfPolicy_setEnforceAll(
sidl_ContractClass_ALLCLASSES, TRUE,
&exception); SIDL_CHECK(exception);
…
int x = vec_Utils_vuAreEqual(u, u,
(sidl_BaseInterface*)(&exception));
…
sidl__array_deleteRef((struct sidl__array*)u);
…
}
Lawrence Livermore National Laboratory
Based on: ${BABEL}/regression/contracts/runC/vectortest.c
14
The C++ client calls methods implemented in each of the
programming languages (during separate executions).
….
#include “sidl_EnfPolicy.hxx”
…
C
Python
C++
Client
(C++)
FORTRAN
77
Java
Fortran 90
int main(int argc, char** argv) {
…
::sidl::array<double> u =
::sidl::array<double>::create1d(max_size);
…
::sidl::EnfPolicy::setEnforceAll(
::sidl::ContractClass_ALLCLASSES, true);
…
bool x = vect::Utils::vuAreEqual(u, u, tol);
…
u.deleteRef();
}
Lawrence Livermore National Laboratory
Based on: ${BABEL}/regression/contracts/runCxx/vectortest.cxx
15
...
The FORTRAN 77 client calls methods implemented in each
of the programming languages (during separate executions).
…
C
Python
C++
Client
(F77)
FORTRAN
77
Java
Fortran 90
program vectortest
implicit none
…
integer*8 exception, u
include ‘sidl_ContractClass.inc’
…
call sidl_double__array_createRow_f(1, low, up, u)
…
call sidl_EnfPolicy_setEnforceAll_f(
$
ALLCLASSES, .true., exception);
…
logical x
call vect_Utils_vuAreEqual(u, u, tol, x, exception)
…
call sidl_double__array_deleteRef_f(u, throwaway)
…
stop
end
Lawrence Livermore National Laboratory
Based on: ${BABEL}/regression/contracts/runF77/vectortest.f
16
..
The Java client calls methods implemented in each of the
programming languages (during separate executions).
C
Python
C++
Client
(Java)
FORTRAN
77
Java
Fortran 90
import sidl.EnfPolicy;
import sidl.Double.Array1;
…
public class vectortest {
…
private sidl.EnfPolicy d_policy = new sidl.EnfPolicy();
private Array1 d_u = new Array1(0, S_MAX_SIZE-1,
false);
…
private void run() throws InterruptedException {
…
d_policy.setEnforceAll(
sidl.ContractClass.ALLCLASSES, true);
…
boolean x = vect.Utils.vuAreEqual(u, u, tol);
…
}
…
}
Lawrence Livermore National Laboratory
Based on: ${BABEL}/regression/contracts/runJava/vectortest.java
17
.
The Python client calls methods implemented in each of the
programming languages (during separate executions).
import sidl.EnfPolicy
…
C
Python
def driver(counter):
u = zeros((MAX_SIZE, ), float64)
C++
…
Client
(Python)
sidl.EnfPolicy.setEnforceAll(
sidl.ContractClass.ALLCLASSES, TRUE);
FORTRAN
77
Java
…
x = vect.Utils.vuAreEqual(u, u, tol);
Fortran 90
…
}
Lawrence Livermore National Laboratory
Based on: ${BABEL}/regression/contracts/runPython/vectortest
18
Toward Multi-Language, Multi-Component Interface Contract
Enforcement
 Motivation and Background
 Contract Enforcement
 Multi-Component Contract Enforcement
Lawrence Livermore National Laboratory
19
Multi-language, multi-component examples based on simple
implementations of fundamental graph search algorithms.
Breadth-First
Depth-First
• Traversal starts at the root, then
explores all neighboring nodes
before exploring (unvisited)
neighbors of nearest nodes, and so
on
• Output: List of reachable vertices,
each with depth (or hop count)
• Traversal starts at the root, then
recursively expands each child node
• Output: Vertex ordering (or
precedence)
• O(|V| + |E|) time and space
• O(|V| + |E|)
1
time and space
2
3
4
2
8
3
5
6
9
7
10
...
11
Lawrence Livermore National Laboratory
Note: Vertex ordering of DFS are not necessarily unique.
1
4
5
6
8
7
9
10
11
20
..
Main components of the CCA application are: Driver,
InitGraph, BreadthFirstSrchJ, and DepthFirstSrch.
Component
Lang
Uses Port(s)
Provides Port(s)
Driver
C++
GraphSource,
InitGraphPort,
GraphSrchPort
GoPort
GraphCFactory
C++
---
GraphSource
GraphC1Factory*
C++
---
GraphSource
GraphC2Factory**
C++
---
GraphSource
InitGraph
Java
DataSource
InitGraphPort
BreadthFirstSrchJ
Java
---
GraphSrchPort
DepthFirstSrch
Java
---
GraphSrchPort
ListCFactory
C++
---
ListSource
IntDataFactory
C++
---
DataSource
Contract checking defined for four graph classes, all implemented in C.
Lawrence Livermore National Laboratory
*Creates Graph with flawed insEdge(). **Creates Graph with flawed insVertex().
21
.
The CCA GUI was used to test each algorithm.
C++
Java
C++
Lawrence Livermore National Laboratory
Max depth (or hop count) for a 258 Vertex (774 edge) graph was 14.
Java
22
Summary and Future Work
 Executable SIDL contracts are an aid to improving the quality
of multi-language, component-based applications
• Explicit obligations on callers and callees
• Enforcement decoupled from implementation
• Consistent contract checking across languages
 Recent work focused on
• Hardening, extending, and demonstrating enforcement for all
supported languages
• Preliminary work demonstrating multi-component enforcement
 Current Priorities*:
• Complete F90 client  C, C++, F77, F90, Java, and Python impls
• Expand multi-component, CCA enforcement examples and conduct
study
• Update the Babel User’s Guide
Lawrence Livermore National Laboratory
*Not necessarily in this order
23
Toward Multi-Language, Multi-Component Interface Contract
Enforcement
Thank you for your attention.
Any Questions?
Lawrence Livermore National Laboratory
24
For more information related to this work, refer to the
following web sites.
 Components Project/Babel
• http://www.llnl.gov/casc/components
• Note: Experiments were conducted using experimental
prototypes of the Babel toolkit. However, the latest version of
Babel supports global enforcement and enforcement tracing.
 Common Component Architecture Forum
• http://cca-forum.org
 Center for Technology for Advanced
Scientific Component Software
• SciDAC’s Plug and Play
Supercomputing
• http://www.scidac.gov/compsci/TASCS.html
Lawrence Livermore National Laboratory
25
Toward Multi-Language, Multi-Component Interface Contract
Enforcement
Supplemental Material
Lawrence Livermore National Laboratory
26
Results reported earlier were based on thirteen trial sets
formed from five programs and up to five input sets.
Component Program
A
Simplicial
Mesh
Volume
Mesh
Vector
Utilities
Description
Retrieve all faces from the mesh then, for each face, retrieve the
adjacent vertices.
AA
Retrieve all faces from the mesh in sets based on size of input
array. Sizes 1, 14587 (10%), and 145870 (100%).
MA
Retrieve faces as in program A plus, for each set of faces,
retrieve their corresponding adjacent vertices. Input sizes were
the same as those used for program A.
MT
Exercise and check consistency of five mesh interfaces: core,
single entity query and traversal, entity array query and traversal,
single entity mesh modification, and entity array mesh
modification.
VT
Exercise all supported functions to include successful execution;
one or more precondition violations; and one or more
postcondition violations. Sizes 6 (original), 10, 100, 1000, and
10000.
Lawrence Livermore National Laboratory
Volume mesh implementation is GRUMMP 0.2.2b; vector utilities from Babel regression tests.
27
Of sampling-based policies, performance-driven enforcement
traces detected significantly more violations during trials.
*
Lawrence Livermore National Laboratory
Data Source: Dahlgren, CBSE ’07.
*
*Based on execution time per entity or element (when appropriate) 28