how to identify dependency between statements automatically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sunil17
    New Member
    • Aug 2010
    • 1

    #1

    how to identify dependency between statements automatically

    suppose if there are two statements in a for loop
    for(i=0;i<n;i++ )
    {

    A(I) = B ( I ) + C(I)
    B(I + 2) = A(I - 1) + C(I -1)
    A(I + 1) = B(2*I + 3) + 1
    }
    suppose if we run these for I values like 1,2,3

    FOR I value 1
    S(2) :A(2) = B(2) + C(2)
    T(2) :B(4) = A(1) + C(1)
    U(2) :A(3) = B(7) + 1
    FOR I value 2
    S(3) :A(3) = B(3) + C(3)
    T(3) :B(5) = A(2) + C(2)
    U(3) :A(4) = B(9) + 1

    here in B(5) has to be wait for A(2).in sequential programming is concerned it is ok.suppose if it is parallel program it will create ambiguity.

    how to identify this types of loop automatically in a program.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    There is no automatic checking that your data has arrived before you use it.

    So if you have an array of 3 elements and you receive element 1 from the user, then it's up to you to not require element 2 or 3 in a calculation until element and 3 have been received.

    All processing is sequential.

    If you use parallel processing (multiple cores) on shared data then you have to control access to the shared data to avoid a race.

    The same would apply to multiple threads using shared data but this isn't actually a parallel process. It's one process interrupting itself to appear parallel.

    Comment

    Working...