Transcription of OpenMP Application Programming Interface …
1 OpenMPApplication ProgrammingInterfaceExamplesVersion November 2016 Source codes for OpenMP Examples can be downloaded from 1997-2016 OpenMP Architecture Review to copy without fee all or part of this material is granted, provided the OpenMPArchitecture Review Board copyright notice and the title of this document appear. Notice isgiven that copying is by permission of OpenMP Architecture Review page intentionally left blankContentsIntroduction1 Examples21. Parallel A Simple Parallel Loop .. TheparallelConstruct.
2 Controlling the Number of Threads on Multiple Nesting Levels .. Interaction Between thenum_threadsClause andomp_set_dynamic.. Fortran Restrictions on thedoConstruct .. ThenowaitClause .. ThecollapseClause .. in Loop Constructs .. Theparallel sectionsConstruct .. ThefirstprivateClause and thesectionsConstruct .. ThesingleConstruct .. TheworkshareConstruct .. ThemasterConstruct .. Parallel Random Access Iterator Loop .. Theomp_set_dynamicandomp_set_num_threads Routines.
3 Theomp_get_num_threadsRoutine .. 382. OpenMP Theproc_bindClause .. Spread Affinity Policy .. Close Affinity Policy .. Master Affinity Policy .. Affinity Query Functions .. 483. ThetaskandtaskwaitConstructs .. Task Priority .. Task Dependences .. Flow Dependence .. Anti-dependence .. Output Dependence .. Concurrent Execution with Dependences .. Matrix multiplication .. ThetaskgroupConstruct .. ThetaskyieldConstruct .. ThetaskloopConstruct.
4 854.. onparallelConstruct .. withmapClause .. withto/frommap-types .. with Array Sections .. withifClause .. dataConstruct .. Simpletarget dataConstruct .. dataRegion Enclosing MultipletargetRegions .. dataConstruct with Orphaned Call .. dataConstruct withifClause .. enter dataandtarget exit dataConstructs .. updateConstruct .. Simpletarget dataandtarget updateConstructs .. updateConstruct withifClause .. targetConstruct .. targetandend declare targetfor a Function.
5 TargetConstruct for Class Type .. 117iiOpenMP Examples Version - November targetandend declare targetfor Variables .. targetandend declare targetwithdeclare simd. targetDirective withlinkClause .. withomp_get_num_teamsandomp_get_team_num Routines .. ,teams, anddistributeConstructs .. teams, and Distribute Parallel Loop Constructs .. teamsand Distribute Parallel Loop Constructs with SchedulingClauses .. teamsanddistribute simdConstructs .. teamsand Distribute Parallel Loop SIMD Constructs .. AsynchronoustargetExecution and Dependences.
6 Asynchronoustargetwith Tasks .. ontargetConstruct .. AsynchronoustargetwithnowaitanddependCla uses .. Array Sections in Device Constructs .. Device Routines .. Target Memory and Device Pointers Routines .. 1525. simdConstructs .. Loop-Carried Lexical Forward Dependence .. 1656. ThecriticalConstruct .. Worksharing Constructs Inside acriticalConstruct .. Binding ofbarrierRegions .. TheatomicConstruct .. Restrictions on theatomicConstruct .. TheflushConstruct without a List.
7 TheorderedClause and theorderedConstruct .. Doacross Loop Nest .. Lock Routines .. Theomp_init_lockRoutine .. Theomp_init_lock_with_hintRoutine .. Ownership of Locks .. Simple Lock Routines .. Nestable Lock Routines .. 2067. Data ThethreadprivateDirective .. Thedefault(none)Clause .. TheprivateClause .. Fortran Private Loop Iteration Variables .. Fortran Restrictions onsharedandprivateClauses with Common Blocks .. Fortran Restrictions on Storage Association with theprivateClause.
8 C/C++ Arrays in afirstprivateClause .. ThelastprivateClause .. ThereductionClause .. ThecopyinClause .. ThecopyprivateClause .. C++ Reference in Data-Sharing Clauses .. FortranASSOCIATEC onstruct .. 2478. Memory The OpenMP Memory Model .. Race Conditions Caused by Implied Copies of Shared Variables in Fortran .. 2569. Program Conditional Compilation .. Internal Control Variables (ICVs) .. Placement offlush,barrier,taskwaitandtaskyieldDire ctives .. Cancellation Constructs.
9 267ivOpenMP Examples Version - November Nested Loop Constructs .. Restrictions on Nesting of Regions .. 275A. Document Revision Changes from to .. Changes from to .. Changes from to .. Changes from to .. 282 ContentsvIntroduction1 This collection of Programming examples supplements the OpenMP API for Shared Memory2 Parallelization specifications, and is not part of the formal specifications. It assumes familiarity3with the OpenMP specifications, and shares the typographical conventions used in that This first release of the OpenMP Examples reflects the OpenMP Version examples are being developed and will be published in future releases of this OpenMP API specification provides a model for parallel Programming that is portable across7shared memory architectures from different vendors.
10 Compilers from numerous vendors support8the OpenMP directives, library routines, and environment variables demonstrated in this document allow10users to create and manage parallel programs while permitting portability. The directives extend the11C, C++ and Fortran base languages with single program multiple data (SPMD) constructs, tasking12constructs, device constructs, worksharing constructs, and synchronization constructs, and they13provide support for sharing and privatizing data. The functionality to control the runtime14environment is provided by library routines and environment variables.
