• No results found

· · · · · γ J K ] γ J K C 6

Figure 5.8: Visualization of the local consistency property of the abstract transformerJ K]with the concretization function γ : D

Abs → D. The trans- formerJ KC of CS applies the transformer of OS to every state d ∈ D.

5.7 Soundness

We show the soundness of the abstraction by sketching a proof of the local consistency of the Abstract Semantics AS with respect to the Operational Semantics OS. To this end, we define the concretization function γ : DAbs

D that maps states of AS to states of the implicitly defined Collecting Semantics of OS. To define γ, we first introduce a set of properties similar to the SIMD properties of AS:

uni(d, x) = ∀xi∈ ρ(x).xi= xi0 aligned(d, x) = ρ0(x) % S = 0

consec(d, x) = ∀ij∈ #.j 6= 0 =⇒ ρij(x) = ρij−1(x) + 1

unknown(d, x) = (¬uni(d, x) ∧ ¬consec(d, x)) ∨ (uni(d, x) ∧ consec(d, x)) vtype(x) = operation x has vectorizable result type

novec(x) = operation x has no vector equivalent se(x) = operation x may have side effects nvop(x) = ∃y ∈ operands(x).¬vtype(y)

Note that these properties are defined on the vector semantics of OS, i.e., each value in ρ is a vector. Accesses to values of an individual instance i are denoted as ρi(x) or xi.

5.7.1 Local Consistency

The concretization function γ : DAbs→ D maps from the Abstract Semantics

to the Collecting Semantics: γ(DAbs) =

[

x∈DAbs

γ(DAbs, x) =                                           

{d|uni(d, x) ∧ aligned(d, xi0)} if DAbs(x) = ua

{d|uni(d, x) ∧ ¬aligned(d, xi0)} if DAbs(x) = u

{d|consec(d, x) ∧ aligned(d, xi0)} if DAbs(x) = ca

{d|consec(d, x) ∧ aligned(d, xi0) ∧ (novec(x) ∨ nvop(x)} if DAbs(x) = cas

{d|consec(d, x) ∧ aligned(d, xi0) ∧ se(x)} if DAbs(x) = cag

{d|consec(d, x) ∧ ¬aligned(d, xi0)} if DAbs(x) = c

{d|consec(d, x) ∧ ¬aligned(d, xi0) ∧ (novec(x) ∨ nvop(x))} if DAbs(x) = cs

{d|consec(d, x) ∧ ¬aligned(d, xi0) ∧ se(x)} if DAbs(x) = cg

{d|unknown(d, x)} if DAbs(x) = k

{d|unknown(d, x) ∧ (novec(x) ∨ nvop(x))} if DAbs(x) = ks

{d|unknown(d, x) ∧ se(x)} if DAbs(x) = kg

{d|¬vtype(x) ∧ uni(d, x)} if DAbs(x) = nu

{d|¬vtype(x) ∧ ¬uni(d, x)} if DAbs(x) = ns

{d|¬vtype(x) ∧ ¬uni(d, x) ∧ se(x)} if DAbs(x) = ng

Figure 5.9: The concretization function γ : DAbs → D. Additional clauses vtype(x), ¬se(x), and ¬novec(x) are omitted in all rules that do not have the corresponding negated clause.

where γ(DAbs, x) is defined as shown in Figure 5.9: The sets µ and @ are

not tracked in the Abstract Semantics, and # is never updated since it is only required to refer to the elements of different instances of the SIMD group.

The Abstract Semantics is sound if γ is locally consistent, i.e., if it exhibits the property

J K

C

◦ γ 6 γ ◦J K

].

where “6” relates the precision of two abstraction states and J KC is the

transformer of CS that is implicitly defined as the application of the trans- former of OS to every state d ∈ D. This means that for every operation f (x), the concretization from AS to CS via γ yields a result that is at most as precise as the direct application of f (x) in CS. Figure 5.8 depicts the consistency property.

In the following, we take a detailed look at the local consistency of three operations: x ← tid, x ← phi((v1, b1), (v2, b2)), and x ← store(a, v).

Analogous manual inspection of the other rules shows that γ and the transformation rules shown in Sections 5.5 and 5.6 are indeed locally con- sistent. Hence, the information carried by the Abstract Semantics can be

5.7 Soundness 69

computed using fixed-point algorithms. Note that not all rules of the ab- stract transformer are monotone since sequential and guarded properties can be stripped in some rules. This reflects the fact that these properties only describe the program point without influencing its uses. Thus, the convergence of the analysis is not affected.

Note that γ ignores blend, by all, and divergent information. Instead, every possible configuration of these is taken into account when testing local consistency.

Instance Identifier

First, direct application of the abstract transformer (Section 5.6.3) to the initial state DAbs

Jx ← tidK ]

(DAbs, B, A, L) = (DAbs⊕ {x 7→ ca} , B, A, L),

yields an update of x in DAbs to ca. Concretization of this state with

γ(DAbs, x) produces a set of states D1 which only contains states in which x

is bound to consecutive/aligned values:

{d|consec(d, x) ∧ aligned(d, xi0)} .

On the other hand, concretization of the initial state DAbs with γ(DAbs, x)

produces a set of states D2. Application of the (vector-lifted) transformer Jx ← tidK(d) = ρ ⊕ {x 7→ {#0, . . . , #W −1}}

to every state d = (ρ, µ, @, #) of D2produces a set of states D3in which x is bound to the values of the corresponding set of instance identifier vectors #. These values are by definition consecutive and aligned.

To summarize, the sets D1 include all those sets in which x is bound to consecutive/aligned values. Since this includes all possible consecutive and aligned values in addition to those represented by the sets # ∈ D3, the concretized state is at most equally precise as the state obtained by first applying the abstract transformer. Thus, the consistency property holds.

Phi Functions

First, direct application of the abstract transformer (Section 5.6.5) to the initial state DAbs

Jx ← phi((v1, b1), (v2, b2))K ](DAbs, B, A, L) = (DAbs⊕      x 7→     

DAbs(v1) tphiDAbs(v2) if x /∈ B

k if x ∈ B ∧ DAbs(v1) v kg ∧ DAbs(v2) v kg ns otherwise      ,

∀d ∈ DAbs.(d is branch ∧ d w ca) =⇒ B ⊕  x 7→  blendd if disjointPaths(d,x) B(x) otherwise  , A, L)

yields an update of DAbs and B. Since the update of B does not have any

direct effect on the concretization, we can ignore how it is updated. The following cases have to be distinguished to investigate the effects of the phi operation:

• x is blend and either v1 or v2is nu or less precise. • x is blend and v1 and v2 are more precise than nu. • x is not blend.

In the first case, x in DAbsis updated to ns by the abstract transformer.

Concretization with γ(DAbs, x) yields a set of states D1which includes all states in which x is bound to a nonvectorizable/sequential value.

On the other hand, concretization of the initial state DAbswith γ(DAbs, x)

produces a set of states D2. Application of the (vector-lifted) transformer Jx ← phi((v1, b1), (v2, b2))K(d) = ρ ⊕ n x 7→ n ρ 0(v1) if @0(b1) = true ρ0(v2) if @0(b2) = true , . . . , ρW −1(v1) if @W −1(b1) = true ρW −1(v2) if @W −1(b2) = true oo

to every state d ∈ D2 produces a set of states D3 in which x is bound to vectors for which the element at index i is selected from either v1 or v2 depending on the state of @i of the corresponding instance. This means the

values in the sets can satisfy any property because only one of v1, v2must be nu or less precise, and none of its values may be selected. The values of D1 cannot be less precise than ns, since ng requires the operation to have side effects, which is never the case for a phi. Thus, the consistency property holds.

5.7 Soundness 71

The second case is similar, with x being updated to k by the abstract transformer, and yielding a set of states D1 in which x is bound to an unknown value after concretization. Since the application of the transformer of OS to every state can again yield arbitrary properties as precise as or more precise than k, the consistency property holds as above.

In the third case, the abstract value of x after application of the abstract transformer can be any except for ng, depending on the values of v1 and v2. Because the result of the transfer function tphiis at most as precise as the least precise operand, D3 can never be more precise than the sets obtained by application of the transformer of OS before concretization. The result of this transformer can be as precise as the most precise operand and is at least as precise as the least precise operand. Thus, the consistency property holds for this case as well.

Store Operations

First, direct application of the abstract transformer (Section 5.6.6) to the initial state DAbs

Jx ← store(a, v)K ](DAbs, B, A, L) = (DAbs⊕              x 7→             

u if DAbs(a) v nu ∧ DAbs(v) v nu

k if x ∈ A ∧ cg w DAbs(a) w ca ∧ DAbs(v) v kg ks if x ∈ A ∧ DAbs(a) w k ∧ DAbs(v) v kg kg if x /∈ A ∧ DAbs(a) w k ∧ DAbs(v) v kg ns otherwise, if x ∈ A ng otherwise, if x /∈ A              , B, A, L)

yields an update of x in DAbs. However, x in this particular case is not an

abstraction of actual values because the store does not return anything. It is an abstraction that describes properties of the operation only. Concretization with γ(DAbs, x) yields a set of states D1 with values of x corresponding to

its abstract value. However, because we do not track the state of values in memory in DAbs, and because x is never used by any operation, the result

of the concretization has no influence on the rest of the analysis.

On the other hand, concretization of the initial state DAbswith γ(DAbs, x)

produces a set of states D2. Application of the (vector-lifted) transformer Jx ← store(a, v)K(d) =

µ0⊕ {ρ0(a) 7→ ρ0(v)} , . . . , µW −1⊕ {ρW −1(a) 7→ ρW −1(v)}

to every state d ∈ D2produces a set of states D3 in which for every µi ∈ d,

the address ρi(a) is updated to ρi(v) for every active instance. This state D3 is more precise than D1which always produces an empty set for µ. Thus, the consistency property holds.