Data dependency

A data dependency in computer science is a situation in which a program statement (instruction) refers to the data of a preceding statement.

(i2 tries to read a source before i1 writes to it) A read after write (RAW) data hazard refers to a situation where an instruction refers to a result that has not yet been calculated or retrieved.

However, in a pipeline, when operands are fetched for the 2nd operation, the results from the first have not yet been saved, and hence a data dependency occurs.

For example: The write back (WB) of i2 must be delayed until i1 finishes executing.

A violation of a true dependency leads to a read-after-write (RAW) hazard.

A violation of an anti-dependency leads to a write-after-read (WAR) hazard.

A violation of an output dependency leads to an write-after-write (WAW) hazard.

That is, they may be removed through renaming of variables, as in the below modification of the above example: Conventional programs are written assuming the sequential execution model.

Recklessly executing multiple instructions without considering related dependences may cause danger of getting wrong results, namely hazards.

Data dependencies are relevant in various areas of computing, particularly in processor design, compiler construction, parallel computing, and concurrent programming.