OpenMP and C++ Sb î rlea Drago ș
Summary Why use C++ and OpenMP Why are there problems Objects in OpenMP clauses Parallelization of C++ loops STL Iterator loop problems STL Dataypes problems
Why use C++ and OpenMP? OpenMP = fast implementation for parallel programs C++ = fast and mentenable implementation for large programs Both are useful when TTM is important
Why are there problems? The OpenMP specification includes C++ Compiler implementations do offer consistent behaviour OpenMP standard too restrictive for C++ syntax parallelization
Objects in OpenMP clauses
Objects in OpenMP clauses Shared = All threads access the same storage area for each shared object C all to dummyfunc expected
Objects in OpenMP clauses Private = Each thread should have its own instance of a variable. A new list item of the same type, with automatic storage duration, is allocated. Calls to constructor, dummyfunc , destructor expected
Objects in OpenMP clauses 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. Copy constructor, dummyfunc, destructor calls expected
Objects in OpenMP clauses 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). Assignment operator call expected
Parallelization of C++ loops OpenMP Requirement: “signed integer variable” as loop index Size_t loop index stops parallelization STL iterators stop parallelization
STL Iterator problem
STL Iterator problem
High Level code Parallelization Options: Internal parallelization Mixed parallelization
STL datatypes std:vallarray Guaranteed initialization with 0 All data in memory of one processor (ccNUMA disadvantage) Solutions: STL modification => compiler dependent Custom allocator (std:vector) Solaris page migration=>Solaris dependent
Reference OpenMP and C++ By Christian Terboven and Dieter an Mey
Questions? Thank You!

OpenMP And C++

  • 1.
    OpenMP and C++Sb î rlea Drago ș
  • 2.
    Summary Why useC++ and OpenMP Why are there problems Objects in OpenMP clauses Parallelization of C++ loops STL Iterator loop problems STL Dataypes problems
  • 3.
    Why use C++and OpenMP? OpenMP = fast implementation for parallel programs C++ = fast and mentenable implementation for large programs Both are useful when TTM is important
  • 4.
    Why are thereproblems? The OpenMP specification includes C++ Compiler implementations do offer consistent behaviour OpenMP standard too restrictive for C++ syntax parallelization
  • 5.
  • 6.
    Objects in OpenMPclauses Shared = All threads access the same storage area for each shared object C all to dummyfunc expected
  • 7.
    Objects in OpenMPclauses Private = Each thread should have its own instance of a variable. A new list item of the same type, with automatic storage duration, is allocated. Calls to constructor, dummyfunc , destructor expected
  • 8.
    Objects in OpenMPclauses 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. Copy constructor, dummyfunc, destructor calls expected
  • 9.
    Objects in OpenMPclauses 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). Assignment operator call expected
  • 10.
    Parallelization of C++loops OpenMP Requirement: “signed integer variable” as loop index Size_t loop index stops parallelization STL iterators stop parallelization
  • 11.
  • 12.
  • 13.
    High Level codeParallelization Options: Internal parallelization Mixed parallelization
  • 14.
    STL datatypes std:vallarrayGuaranteed initialization with 0 All data in memory of one processor (ccNUMA disadvantage) Solutions: STL modification => compiler dependent Custom allocator (std:vector) Solaris page migration=>Solaris dependent
  • 15.
    Reference OpenMP andC++ By Christian Terboven and Dieter an Mey
  • 16.