Efficient Set Sharing using ZBDDs endez-Lojo 1 Mario M ak 2 Ond - - PowerPoint PPT Presentation

efficient set sharing using zbdds
SMART_READER_LITE
LIVE PREVIEW

Efficient Set Sharing using ZBDDs endez-Lojo 1 Mario M ak 2 Ond - - PowerPoint PPT Presentation

Efficient Set Sharing using ZBDDs endez-Lojo 1 Mario M ak 2 Ond rej Lhot Manuel Hermenegildo 1 , 3 1 University of New Mexico (USA) 2 University of Waterloo (Canada) 3 IMDEA-Software and Technical University of Madrid (Spain) July 31, 2008


slide-1
SLIDE 1

Efficient Set Sharing using ZBDDs

Mario M´ endez-Lojo1 Ondˇ rej Lhot´ ak2 Manuel Hermenegildo1,3

1University of New Mexico (USA) 2University of Waterloo (Canada) 3IMDEA-Software and Technical University of Madrid (Spain)

July 31, 2008

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 1 / 14

slide-2
SLIDE 2

Background: sharing property

A set of variables share if they reach the same memory location.

G2

1

G G0

f g O

1 2 3

O

2

O1 O0

3

V V V V f g O O O O

1 3 3 2 1 2

V V V V g O O f

1 2 3

O3

2 1

O0 V V V V

The three memory states have the same sharing representation: {{v0, v1, v2} , {v3}} — “v0 reaches an object which is also reachable from v1 and v2, while v3 cannot reach an object reachable from any of the other variables.” We say that v0, v1 and v2 share, while v3 shares with itself.

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 2 / 14

slide-3
SLIDE 3

Background: why set sharing

  • Our analysis tracks which variables definitely do not share.
  • We use Abstract Interpretation [CC77] to ensure the correctness
  • f this information at any program point.
  • One of the uses of sharing information is for parallelization:
  • Assume that, in the example of the previous slide, the analysis is able

to infer that the set sharing at runtime is indeed {{v0, v1, v2} , {v3}}.

  • Assume two invocations m(v0, v1, v2) and n(v3), just after that state.
  • These two method calls can be safely parallelized since they are

independent: execution of m(v0, v1, v2) cannot affect that of n(v3) and they can proceed in parallel without interference. (This is of course a safe approximation of independence.)

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 3 / 14

slide-4
SLIDE 4

Background: tracking sharing in a program

We use a set of sets of variables to approximate all the possible sharing sets (program states) that occur at a given program point: SHp = {{v0, v1} , {v0, v1, v2} , {v3}} “In the set of memory states approximated by SH at program point p, v0 may share with v1 and v2, or just with v1; v3 may point to a non-null location.”

2

V

1

V f g O

1 2 3

O

2

O1 O0

3

V V V V f g O O O O

3 3 2 1

V V g O O f

1 2 3 2 1

O0 V V V V

Analysis ensures that v3 definitely does not share with v0, or v1, or v2.

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 4 / 14

slide-5
SLIDE 5

Background: store-aware set sharing

Sharing can be combined with structural information. In the previous slides we described sharing in terms of local variables, but set sharing can talk about any pointer. For example, this linked list:

V O0 O1 P0 P1 P2 P3

next data data next

...

O O3

2

Can be abstracted as ({v0 = (data:p0, next:p1)}

  • shape

, {{v0, p0} , {vo, p1}}

  • set sharing

) A statement like v1 = v0.data will result in a final abstract state: ({v0 = (data:p0, next:p1)} , {{v0, v1, p0} , {vo, p1}})

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 5 / 14

slide-6
SLIDE 6

Motivation

  • Our initial work [MLH08] showed that with set sharing we can

achieve more precise results than with a related analysis [SS05] (pair sharing), for a set of small benchmarks.

  • But the original implementation of set sharing did not scale:
  • Based on lists of lists.
  • We will show that even a BitSet list will not work.
  • The main problem is the combinatorial nature of the domain.
  • Some abstract operations are exponential in both memory and time.
  • Initial idea: use Binary Decision Diagrams (BDDs) –but they are

not designed to (naturally) represent sets of sets.

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 6 / 14

slide-7
SLIDE 7

Zero-supressed BDDs

ZBDDs [iM93] are a data structure similar to BDDs, but designed to encode sets of combinations.

  • A ZBDD is a rooted directed acyclic graph (DAG) of

non-terminal and terminal ( 0 , 1 ) nodes.

  • Each path through the ZBDD that ends at the 1 node defines a

set of variables (those that the path leaves along a 1-edge).

  • ZBDDs work particularly well when representing sparse sets.

1 1 1

V2 V1

1

V0

Universe of variables={v0, v1, v2, v3} ZBDD represents v0v 1v2v 3 + v 0v1v 2v 3 = {{v0, v2} , {v1}}

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 7 / 14

slide-8
SLIDE 8

Set sharing + ZBDDs

  • Idea: replace the naive implementation by a ZBDD-based version,

which is expected to at least use less memory.

  • Efficient algorithms exist for common operations on the set of

sets encoded by a ZBDD: union, difference, intersection... Set ZBDD example SH1∪SH2 SH1+SH2

{{v0, v1}} + {{v0} , {v2}} = {{v0} , {v0, v1} , {v2}}

SH1⊎SH2 SH1∗SH2

{{v0, v1}} ∗ {{v0} , {v2}} = {{v0, v1} , {v0, v1, v2}}

SHv SH//v

{{v0, v1}} // {{v0}} = {{v0}}

SH−v SH %v

{{v0, v1}} % {{v0}} = {{v1}}

  • We do not need to alter the existing set sharing semantics!
  • Example: approximatting the effects of a variable load.

SEI

πv(SH)

= ({{res}} ⊎SHv)∪SH−v

(sets ops)

= res∗(SH//v) + SH %v

(primitive ZBDD ops)

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 8 / 14

slide-9
SLIDE 9

Transfer functions in terms of ZBDD operations

  • In practice, we replace certain combinations of primitive

(+,∗, %,⊎) operations by a custom, equivalent ZBDD algorithm.

  • Example: approximatting the effects of a variable load.

SEI

πv(SH)

= ({{res}} ⊎SHv)∪SH−v

(sets ops)

= res∗(SH//v) + SH %v

(primitive ZBDD ops)

= setResEqTo(SH, v)

(dedicated ZBDD op)

The dedicated algorithm setResEqTo runs faster.

  • Example: approximatting the effects of a field load.

SEI

πv.f(SH)

= SH∪({{v, res}} ⊎

  • S∈SHv

P(S|−v))

(sets)

= SH+v∗res∗powUnion(SH/v)

(ZBDD)

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 9 / 14

slide-10
SLIDE 10

A dedicated algorithm: powerset computation

Approximatting the effects of a field load (v.f) and store (v.f=expr) in state SH implies computing: powUnion(SH) =

  • S∈SH

P(S) The native implementation of powUnion is a key factor in the

  • verall performance of the analysis.
  • Standard computation of the powerset presents a combinatorial

explosion in both memory and running time. P({v0, v1, v2}) = {{} , {v0} , {v1} , {v2} , {v0, v1} , {v0, v2} , {v1, v2} , {v0, v1, v2}}

  • The same powerset is compactly represented by a ZBDD.

1 1 1

V0 V1

2

V

1

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 10 / 14

slide-11
SLIDE 11

Experimental results - memory usage

We compare a BitSet and a ZBDD-based implementation.

  • The BitSet representation uses 50 bytes per set (N ≤ 32).
  • The ZBDD version behaves better for large set sharings (5x

improvement).

10 20 30 40 50 100 200 300 400 500 600 700 800 900 1000

Memory usage (Mbytes) Number of sharings (in thousands)

Memory usage of BitSet vs. ZBDD (vd=0.28)

BitSet ZBDD

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 11 / 14

slide-12
SLIDE 12

Experimental results - performance (I)

  • Some BitSet-based operations are faster: for example,

computing the effects of a variable store.

  • Variable load semantics are calculated in similar times.

200 400 600 800 1000 1200 50 100 150 200 250 300 350 400 450 500

Time (ms.) Number of sharings (in thousands)

Var Store (vd=0.21)

BitSet ZBDD

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 12 / 14

slide-13
SLIDE 13

Experimental results - performance (II)

Powerset calculations set a major performance difference when computing the effects of a field load or store.

50000 100000 150000 200000 250000 100 200 300 400 500

Time (ms.) Number of sharings (in thousands)

Field Load (vd=0.26)

BitSet ZBDD

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 13 / 14

slide-14
SLIDE 14

Conclusions and future work

  • ZBDDs are adequate for encoding large sets of sets.
  • Any analysis based on the set of sets representation can probably

benefit from ZBDDs.

  • We focused on set sharing:
  • Memory usage is improved because of the compact ZBDD encoding.
  • Better performance is achieved through efficient powerset

computations.

  • We are currently reimplementing the full (Java) analysis so it is

ZBDD-based.

  • It will allow us to evaluate the gain in performance in the framework.
  • The expected gain in scalability will allow assessing the actual impact
  • f the analysis in a client application (parallelization).

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 14 / 14

slide-15
SLIDE 15

[CC77]

  • P. Cousot and R. Cousot.

Abstract Interpretation: a Unified Lattice Model for Static Analysis of Programs by Construction or Approximation of Fixpoints. In Fourth ACM Symposium on Principles of Programming Languages, pages 238–252, 1977. [iM93] Shin ichi Minato. Zero-Suppressed BDDs for Set Manipulation in Combinatorial Problems. In DAC, pages 272–277, 1993. [MLH08] M. M´ endez-Lojo and M. Hermenegildo. Precise Set Sharing Analysis for Java-style Programs. In 9th International Conference on Verification, Model Checking and Abstract Interpretation (VMCAI’08), number 4905 in LNCS, pages 172–187. Springer-Verlag, January 2008.

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 14 / 14

slide-16
SLIDE 16

[SS05]

  • S. Secci and F. Spoto.

Pair-sharing analysis of object-oriented programs. In Static Analysis Symposium (SAS), pages 320–335, 2005.

Mendez-Lojo et al (UNM,UW,UPM) Efficient Set Sharing using ZBDDs July 31, 2008 14 / 14