pyCthon
pyCthon

Reputation: 12341

proper openmp implementation with for ,if and else

My question is in regard to the situation in the pseudo code below, for my situation is it possible to use one parallel region for the entire code or should i just seperate parallel regions because of the if and else statements

for loop
    {
        //some code , possible reduction here
    }

    if something
    {  
        for (loop 1)
        { 
            //some code2, another exasperated reduction here                         
        }
    }
    else 
    {
        for (loop 2)
        { 
           //some code 3 , special function here
        }
    }

  if (another case)
  {
    for (for loop 3)
    {
        // some code 4, another special function
    }
  }
}

Upvotes: 0

Views: 130

Answers (1)

Yes, you can use one parallel region for the whole code. Just make sure to account for all reductions occuring in all possible execution branches.

Upvotes: 1

Related Questions