Lably
Skip to content

Data dependency

Programming situation where an instruction refers to a prior instruction's data

  • 6 min read
  • 4 chapters

Related on Lably

Through Computer science, Statement (computer science) and Compiler

Description

Assuming statement S1 and S2, S2 depends on S1 if:

[I(S1)∩O(S2)]∪[O(S1)∩I(S2)]∪[O(S1)∩O(S2)]≠∅

where:

  • I(Si) is the set of memory locations read by Si,
  • O(Sj) is the set of memory locations written by Sj, and
  • there is a feasible run-time execution path from S1 to S2.

These conditions are called Bernstein's Conditions, named after Arthur J. Bernstein.

Three cases exist:

  • Anti-dependence: I(S1)∩O(S2)≠∅, S1→S2 and S1 reads something before S2 overwrites it
  • Flow (data) dependence: O(S1)∩I(S2)≠∅, S1→S2 and S1 writes before something read by S2
  • Output dependence: O(S1)∩O(S2)≠∅, S1→S2 and both write the same memory location.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in From Lably lessons