Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 7. Using Automatic Parallelizati... > Ensuring That Code in a Parallel Reg...

Ensuring That Code in a Parallel Region Is Executed in Order

In some cases, it may be necessary to ensure that a section of code is executed in the same order as the serial code would execute it. Unfortunately, such an ordering is unlikely to allow the code to get the full benefit of using multiple threads, but it should enable some gains to be attained from parallelization.

OpenMP supports the ordered directive, which ensures that the order of parallel execution is the same as the serial ordering. The directive needs to be applied to the parallel region, and the loop also needs to be identified as an ordered loop using the ordered clause on the parallel for directive.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint