OpenMP And C++

3,095 views

Published on

Presentation about the problems encountered while programming with OpenMP using C++

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,095
On SlideShare
0
From Embeds
0
Number of Embeds
27
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

OpenMP And C++

  1. 1. OpenMP and C++ Sb î rlea Drago ș
  2. 2. Summary <ul><li>Why use C++ and OpenMP </li></ul><ul><ul><li>Why are there problems </li></ul></ul><ul><li>Objects in OpenMP clauses </li></ul><ul><li>Parallelization of C++ loops </li></ul><ul><ul><li>STL Iterator loop problems </li></ul></ul><ul><li>STL Dataypes problems </li></ul>
  3. 3. Why use C++ and OpenMP? <ul><li>OpenMP = fast implementation for parallel programs </li></ul><ul><li>C++ = fast and mentenable implementation for large programs </li></ul><ul><li>Both are useful when TTM is important </li></ul>
  4. 4. Why are there problems? <ul><li>The OpenMP specification includes C++ </li></ul><ul><li>Compiler implementations do offer consistent behaviour </li></ul><ul><li>OpenMP standard too restrictive for C++ syntax parallelization </li></ul>
  5. 5. Objects in OpenMP clauses
  6. 6. Objects in OpenMP clauses <ul><li>Shared = All threads access the same storage area for each shared object </li></ul><ul><ul><li>C all to dummyfunc expected </li></ul></ul>
  7. 7. Objects in OpenMP clauses <ul><li>Private = Each thread should have its own instance of a variable. </li></ul><ul><ul><li>A new list item of the same type, with automatic storage duration, is allocated. </li></ul></ul><ul><ul><li>Calls to constructor, dummyfunc , destructor expected </li></ul></ul>
  8. 8. Objects in OpenMP clauses <ul><li>Firstprivate = Each thread should have its own instance of a variable, and the variable should be initialized with the value of the variable before the parallel construct. </li></ul><ul><ul><li>Copy constructor, dummyfunc, destructor calls expected </li></ul></ul>
  9. 9. Objects in OpenMP clauses <ul><li>Lastprivate = the enclosing context's version of the variable is set equal to the private version of whichever thread executes the final iteration (for-loop construct) or last section (#pragma sections). </li></ul><ul><ul><li>Assignment operator call expected </li></ul></ul>
  10. 10. Parallelization of C++ loops <ul><li>OpenMP Requirement: “signed integer variable” as loop index </li></ul><ul><li>Size_t loop index stops parallelization </li></ul><ul><li>STL iterators stop parallelization </li></ul>
  11. 11. STL Iterator problem
  12. 12. STL Iterator problem
  13. 13. High Level code Parallelization <ul><li>Options: </li></ul><ul><li>Internal parallelization </li></ul><ul><li>Mixed parallelization </li></ul>
  14. 14. STL datatypes <ul><li>std:vallarray </li></ul><ul><ul><li>Guaranteed initialization with 0 </li></ul></ul><ul><ul><li>All data in memory of one processor (ccNUMA disadvantage) </li></ul></ul><ul><li>Solutions: </li></ul><ul><ul><li>STL modification => compiler dependent </li></ul></ul><ul><ul><li>Custom allocator (std:vector) </li></ul></ul><ul><ul><li>Solaris page migration=>Solaris dependent </li></ul></ul>
  15. 15. Reference <ul><li>OpenMP and C++ </li></ul><ul><ul><li>By Christian Terboven and Dieter an Mey </li></ul></ul>
  16. 16. Questions? <ul><li>Thank You! </li></ul>

×